diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index a417d1078..d2585eaa8 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,4 +1,4 @@ -name: Manual release +name: Deploy to dev on: workflow_dispatch: @@ -6,6 +6,7 @@ on: 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 @@ -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 @@ -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 }} @@ -107,7 +104,6 @@ jobs: - set-vars - start-runner - build-image - - run-integration-tests - release-terraform with: RUNNER_LABEL: ${{ needs.start-runner.outputs.label }} diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f905576dc..cfbda92b6 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -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 @@ -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 @@ -53,6 +72,7 @@ jobs: - name: Build Containers run: | + cd integration mkdir -p data/elastic/ chmod -R 777 data/ cp .env.integration .env @@ -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 diff --git a/Makefile b/Makefile index 956e1fab2..d04c7210c 100644 --- a/Makefile +++ b/Makefile @@ -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)) @@ -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: @@ -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