Skip to content

Commit

Permalink
Merge pull request #2423 from uktrade/uat
Browse files Browse the repository at this point in the history
PROD Release
  • Loading branch information
depsiatwal authored Feb 17, 2025
2 parents 0c5e583 + fe98ecc commit 99fdfa4
Show file tree
Hide file tree
Showing 13 changed files with 1,174 additions and 1,097 deletions.
220 changes: 8 additions & 212 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,11 @@ image_python_node: &image_python_node
image: cimg/python:3.9.18-node

image_postgres: &image_postgres
image: circleci/postgres:12
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password

image_postgres13: &image_postgres13
image: circleci/postgres:13
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password

image_opensearch_v1: &image_opensearch_v1
image: opensearchproject/opensearch:1.3.13
environment:
- cluster.name=cluster-001
- node.name=node-001
- discovery.type=single-node
- bootstrap.memory_lock=true
- DISABLE_INSTALL_DEMO_CONFIG=true # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- DISABLE_SECURITY_PLUGIN=true # Disables security plugin

image_opensearch: &image_opensearch
image: opensearchproject/opensearch:2.14.0
environment:
Expand Down Expand Up @@ -101,7 +85,6 @@ commands:
name: Install Dependencies
command: |
pipenv sync --dev
pipenv install endesive==1.5.9
- save_cache:
paths:
- ./.venv
Expand All @@ -125,7 +108,7 @@ jobs:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
Expand All @@ -141,31 +124,11 @@ jobs:
- upload_code_coverage:
alias: tests

tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
parallelism: 10
steps:
- setup
- run:
name: Run tests on Postgres 13
command: |
pipenv run pytest --circleci-parallelize --cov=. --cov-report xml --cov-config=.coveragerc --ignore lite_routing --ignore api/anonymised_db_dumps -k "not seeding and not elasticsearch and not performance and not migration and not db_anonymiser and not requires_transactions"
- upload_code_coverage:
alias: tests_dbt_platform

seeding_tests:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
<<: *common_env_vars
Expand All @@ -179,29 +142,11 @@ jobs:
- upload_code_coverage:
alias: seeding_tests

seeding_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
steps:
- setup
- run:
name: Run seeding tests on Postgres 13
command: |
pipenv run pytest --cov=. --cov-report xml --cov-config=.coveragerc -k seeding
- upload_code_coverage:
alias: seeding_tests_dbt_platform

anonymised_db_dump_tests:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
Expand All @@ -216,30 +161,11 @@ jobs:
- upload_code_coverage:
alias: anonymised_db_dumps

anonymised_db_dump_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
steps:
- setup
- run:
name: Run anonymised DB dump tests on Postgres 13
command: |
pipenv run pytest --cov=. --cov-report xml --cov-config=.coveragerc api/anonymised_db_dumps
- upload_code_coverage:
alias: anonymised_db_dump_tests_dbt_platform

requires_transactions_tests:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
Expand All @@ -254,30 +180,11 @@ jobs:
- upload_code_coverage:
alias: requires_transactions_tests

requires_transactions_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
steps:
- setup
- run:
name: Run requiring transactions tests on Postgres 13
command: |
pipenv run pytest --cov=. --cov-report xml --cov-config=.coveragerc -k requires_transactions
- upload_code_coverage:
alias: requires_transactions_tests_dbt_platform

migration_tests:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
Expand All @@ -293,31 +200,11 @@ jobs:
- upload_code_coverage:
alias: migration_tests

migration_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
parallelism: 5
steps:
- setup
- run:
name: Run migration tests for dbt platform
command: |
pipenv run pytest --circleci-parallelize --cov=. --cov-report xml --cov-config=.coveragerc -k migration
- upload_code_coverage:
alias: migration_tests_dbt_platform

lite_routing_tests:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
Expand All @@ -333,60 +220,10 @@ jobs:
- upload_code_coverage:
alias: lite_routing_tests

lite_routing_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
parallelism: 5
steps:
- setup
- run:
name: Run lite_routing tests for dbt platform
command: |
pipenv run pytest --circleci-parallelize --cov=. --cov-report xml --cov-config=.coveragerc -k "not migration" --ignore lite_routing/routing_rules_internal/tests/bdd lite_routing
- upload_code_coverage:
alias: lite_routing_tests_dbt_platform

lite_routing_bdd_tests:
docker:
- <<: *image_python_node
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_redis
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
parallelism: 5
steps:
- setup
- run:
name: Install cucumber reporter package
command: npm install multiple-cucumber-html-reporter
- run:
name: Create report directories
command: |
mkdir cucumber_results
- run:
name: Run lite_routing tests
command: pipenv run pytest --circleci-parallelize --gherkin-terminal-reporter -vv lite_routing/routing_rules_internal/tests/bdd --cucumberjson=cucumber_results/cuc.json
- run:
name: Generate html cucumber report
command: node generate_cucumber_report.js
when: always
- store_artifacts:
path: cucumber_html

lite_routing_bdd_tests_dbt_platform:
docker:
- <<: *image_python_node
- <<: *image_postgres13
- <<: *image_opensearch
- <<: *image_redis
working_directory: ~/lite-api
Expand Down Expand Up @@ -417,7 +254,7 @@ jobs:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
<<: *common_env_vars
Expand All @@ -431,43 +268,10 @@ jobs:
- upload_code_coverage:
alias: open_search_v1_tests

open_search_tests_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
steps:
- setup
- run:
name: Run opensearch tests on dbt platform config
command: |
pipenv run pytest --cov=. --cov-report xml --cov-config=.coveragerc -k elasticsearch
- upload_code_coverage:
alias: open_search_tests_dbt_platform

check_migrations:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
working_directory: ~/lite-api
environment:
<<: *common_env_vars
LITE_API_ENABLE_ES: True
steps:
- setup
- run:
name: Check migrations are made
command: pipenv run ./manage.py makemigrations --check

check_migrations_dbt_platform:
docker:
- <<: *image_python
- <<: *image_postgres13
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
Expand All @@ -483,7 +287,7 @@ jobs:
docker:
- <<: *image_python
- <<: *image_postgres
- <<: *image_opensearch_v1
- <<: *image_opensearch
working_directory: ~/lite-api
environment:
<<: *common_env_vars
Expand Down Expand Up @@ -672,17 +476,11 @@ workflows:
- linting
- tests
- seeding_tests
- seeding_tests_dbt_platform
- lite_routing_tests
- lite_routing_tests_dbt_platform
- lite_routing_bdd_tests
- lite_routing_bdd_tests_dbt_platform
- open_search_tests_dbt_platform
- open_search_tests
- migration_tests
- migration_tests_dbt_platform
- check_migrations
- check_migrations_dbt_platform
- check_coverage:
requires:
- tests
Expand All @@ -695,6 +493,4 @@ workflows:
- check_routing_docs
- e2e_tests
- anonymised_db_dump_tests
- anonymised_db_dump_tests_dbt_platform
- requires_transactions_tests
- requires_transactions_tests_dbt_platform
32 changes: 13 additions & 19 deletions .copilot/phases/pre_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@
# Exit early if something goes wrong
set -e

git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$AWS_ACCOUNT_ID/eu-west-2/$CODESTAR_CONNECTION_ID/uktrade"
if [ -f "./.gitmodules" ]; then
echo ".gitmodules file exists. Modifying URLs..."
account_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d':' -f5)
connection_id=$(echo $CODESTAR_CONNECTION_ARN | cut -d'/' -f2)
git_clone_base_url="https://codestar-connections.eu-west-2.amazonaws.com/git-http/$account_id/eu-west-2/$connection_id/uktrade"

git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true

cat <<EOF > ./.gitmodules
[submodule "lite-content"]
path = lite_content
url = $git_clone_base_url/lite-content.git
branch = master
[submodule "lite_routing"]
path = lite_routing
url = $git_clone_base_url/lite-routing.git
branch = main
[submodule "django_db_anonymiser"]
path = django_db_anonymiser
url = $git_clone_base_url/django-db-anonymiser.git
EOF
sed -i "s|url = [email protected]:uktrade/\(.*\).git|url = $git_clone_base_url/\1.git|g" ./.gitmodules

git submodule update --init --recursive

sed -i 's/\[packages\]/[packages]\nendesive = "~=1.5.9"/' Pipfile
pipenv lock
git submodule update --init --recursive

else
echo ".gitmodules file does not exist. No URLs to update."
fi
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ RUN pyenv global 3.9.18
RUN pip3 install pipenv
ADD Pipfile* /app/
RUN pipenv install --dev --deploy
RUN pipenv install endesive==1.5.9
ADD . /app
Loading

0 comments on commit 99fdfa4

Please sign in to comment.