Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dev deployment testing #593

Merged
merged 53 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a73c5cc
Changed build github action to use commit hash
252afh Jun 14, 2024
f67e441
Change name of deploy-dev.yml
252afh Jun 14, 2024
bfe53f3
Use absolute path for using integration test workflow
252afh Jun 14, 2024
e7d361f
Added workflow call to integration.yml
252afh Jun 14, 2024
ce09c8c
Stepped integration test workflow version to this branch commit
252afh Jun 14, 2024
fc3c123
Step hash in docker build
252afh Jun 14, 2024
3ff0f82
Step hash in docker build
252afh Jun 14, 2024
b8a63c8
Added commit hash as an argumnent to the integration test workflow
252afh Jun 17, 2024
705dceb
Stepped integration workflow hash in deploy-dev.yml and passed commit…
252afh Jun 17, 2024
22c45d1
Stepped integration hash
252afh Jun 17, 2024
3a51f13
Rename commit hash to correct var case
252afh Jun 17, 2024
10f1db5
Stepped integration hash
252afh Jun 17, 2024
9a272cd
Updated var name in deploy-dev.yml
252afh Jun 17, 2024
30f2110
Moved inputs into inputs list in integration.yml
252afh Jun 17, 2024
be714ca
Stepped integration workflow hash
252afh Jun 17, 2024
d36e422
Add cd main to integration.yml
252afh Jun 17, 2024
94518ea
Stepped integration workflow hash
252afh Jun 17, 2024
c1a5dc7
try run integration tests in deploy-dev.yml
252afh Jun 17, 2024
14f16e9
Rename step
252afh Jun 17, 2024
1a32ce6
Ad ref and path to checkout action and put requires build-image on tests
252afh Jun 17, 2024
0204db8
Temp remove build-image step
252afh Jun 17, 2024
94cebe4
Added cd main
252afh Jun 17, 2024
969ee05
Added checkout back to test step
252afh Jun 17, 2024
526d172
Revert deploy-dev.yml to use integration workflow
252afh Jun 18, 2024
06cdce0
Step integration sha reference
252afh Jun 18, 2024
ff365d0
Make sure deploy spins up env runner
252afh Jun 21, 2024
438f65f
Update image tag variables to populate on call
252afh Jun 21, 2024
b19c477
Changed integration test to checkout path to integration instead, to …
252afh Jun 21, 2024
96aa875
Stepped integration workflow sha
252afh Jun 21, 2024
62a4890
Swapped order of integration and build steps in deploy-dev.yml
252afh Jun 21, 2024
b8ca304
Add environment variable for integration tests to integration workflow
252afh Jul 1, 2024
161249c
Stepped integration workflow used in deploy-dev.yml
252afh Jul 1, 2024
e89c4f7
Don't stop runner temporarily
252afh Jul 1, 2024
ded95cf
Step integration hash
252afh Jul 1, 2024
d1aa692
Up timeout to 60 seconds for integration tests
252afh Jul 1, 2024
9510988
Add workspace export path to integration.yml
252afh Jul 1, 2024
9821844
Stepped image tag
252afh Jul 1, 2024
cb91dd1
Remove redundant lines from integration.yml
252afh Jul 1, 2024
6ee5085
Stepped integration workflow tag
252afh Jul 1, 2024
a648150
Removed integration tests and re-added stop-runner
252afh Jul 1, 2024
553cfde
Removed step to export github working dir
252afh Jul 1, 2024
3eb81f2
Removed need for integration tests to be passed
252afh Jul 1, 2024
1dd1148
Reverted timout changes in test_e2e.py
252afh Jul 1, 2024
9c17268
Reverted timout changes in test_e2e.py
252afh Jul 1, 2024
bba6867
Stepped image tag to build-docker reference
252afh Jul 1, 2024
4440d26
Removed all comments to make the deploy-dev.yml file cleaner
252afh Jul 1, 2024
386d743
Replace incorrect docker path
252afh Jul 1, 2024
3804130
Updated build-docker reference to main now it's merged in
252afh Jul 2, 2024
850cac0
Change auto-apply to only target ecs module and related resources. Re…
252afh Jul 2, 2024
77ca906
Updated variable reference in update-tags make command
252afh Jul 2, 2024
db9d642
Update docker_update_tag command to work properly
252afh Jul 2, 2024
8b906ad
Update docker_update_tag command to work properly
252afh Jul 2, 2024
fc740a3
Corrected Makefile command for docker_update_tag
252afh Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Manual release
name: Deploy to dev

on:
workflow_dispatch:
inputs:
commit-hash:
description: 'The SHA of the Git commit to use'
required: false
default: refs/heads/main
core-repo-reference:
description: 'The SHA to set the core repo to'
required: false
Expand All @@ -32,8 +33,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.COMMIT_HASH }}
path: main
- id: export
run: |
cd main
. ./.github/.github.env
echo "ec2-instance-type=${EC2_INSTANCE_TYPE}" >> $GITHUB_OUTPUT
echo "app-name=${APP_NAME}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -70,19 +75,11 @@ jobs:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}

run-integration-tests:
needs:
- set-vars
- start-runner
- build-image
uses: ../integration.yml

release-terraform:
needs:
- set-vars
- start-runner
- build-image
- run-integration-tests
uses: i-dot-ai/i-dot-ai-core-github-actions/.github/workflows/apply-terraform.yml@main
with:
APP_NAME: ${{ needs.set-vars.outputs.app-name }}
Expand All @@ -107,7 +104,6 @@ jobs:
- set-vars
- start-runner
- build-image
- run-integration-tests
- release-terraform
with:
RUNNER_LABEL: ${{ needs.start-runner.outputs.label }}
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,32 @@

name: Integration Tests

env:
ENVIRONMENT: INTEGRATION

on:
# weekday mealtimes
schedule:
- cron: '0 6,12,18 * * 1-5'
# or on-demand
workflow_dispatch:
# or on push to main
inputs:
COMMIT_HASH:
description: 'The SHA of the Git commit to use'
required: false
type: string
default: refs/heads/main
# or on push to main
push:
branches:
- 'main'
workflow_call:
inputs:
COMMIT_HASH:
description: 'The SHA of the Git commit to use'
required: false
type: string
default: refs/heads/main

permissions:
contents: read
Expand All @@ -23,7 +39,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.COMMIT_HASH }}
path: integration

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
Expand Down Expand Up @@ -53,6 +72,7 @@ jobs:

- name: Build Containers
run: |
cd integration
mkdir -p data/elastic/
chmod -R 777 data/
cp .env.integration .env
Expand All @@ -64,6 +84,7 @@ jobs:

- name: Test integration with pytest
run: |
cd integration
poetry install --only dev
poetry run playwright install --with-deps chromium
poetry run pytest tests/ --browser chromium
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,9 @@ AUTO_APPLY_RESOURCES = module.django-app.aws_ecs_task_definition.aws-ecs-task \
module.worker.aws_ecs_task_definition.aws-ecs-task \
module.worker.aws_ecs_service.aws-ecs-service \
module.worker.data.aws_ecs_task_definition.main \
module.waf.aws_wafv2_ip_set.london \
aws_secretsmanager_secret.django-app-secret \
aws_secretsmanager_secret.worker-secret \
aws_secretsmanager_secret.core-api-secret \
module.load_balancer.aws_security_group_rule.load_balancer_http_whitelist \
module.load_balancer.aws_security_group_rule.load_balancer_https_whitelist
aws_secretsmanager_secret.core-api-secret

target_modules = $(foreach resource,$(AUTO_APPLY_RESOURCES),-target $(resource))

Expand Down Expand Up @@ -180,11 +177,10 @@ docker_push:
.PHONY: docker_update_tag
docker_update_tag:
for service in django-app core-api worker; do \
MANIFEST=$$(aws ecr batch-get-image --repository-name $(ECR_REPO_NAME)-$$service --image-ids imageTag=$(IMAGE_TAG) --query 'images[].imageManifest' --output text) && \
aws ecr put-image --repository-name $(ECR_REPO_NAME)-$$service--image-tag $(tag) --image-manifest "$$MANIFEST"
MANIFEST=$$(aws ecr batch-get-image --repository-name $(ECR_REPO_NAME)-$$service --image-ids imageTag=$(IMAGE_TAG) --query 'images[].imageManifest' --output text) ; \
aws ecr put-image --repository-name $(ECR_REPO_NAME)-$$service --image-tag $(tag) --image-manifest "$$MANIFEST" ; \
done


# Ouputs the value that you're after - useful to get a value i.e. IMAGE_TAG out of the Makefile
.PHONY: docker_echo
docker_echo:
Expand Down Expand Up @@ -249,7 +245,7 @@ tf_destroy: ## Destroy terraform
.PHONY: tf_import
tf_import:
make tf_set_workspace && \
terraform -chdir=./infrastructure/aws/$(instance) import ${tf_build_args} -var-file=$(CONFIG_DIR)/${env}-input-params.tfvars ${name} ${id}
terraform -chdir=./infrastructure/aws/$(instance) import ${tf_build_args} -var-file=$(CONFIG_DIR)/${env}-input-params.tfvars ${name} ${id}

# Release commands to deploy your app to AWS
.PHONY: release
Expand Down
Loading