From 06a1671f4620624becf9c91788e12ecee479e106 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 16 Sep 2024 12:37:15 +0100 Subject: [PATCH] Move performance pipeline to staging --- .github/workflows/review_pipeline.yml | 50 -------------------------- .github/workflows/staging_pipeline.yml | 50 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/.github/workflows/review_pipeline.yml b/.github/workflows/review_pipeline.yml index 894b261d0..a1c5e1e2e 100644 --- a/.github/workflows/review_pipeline.yml +++ b/.github/workflows/review_pipeline.yml @@ -15,11 +15,6 @@ defaults: run: shell: bash -env: - app_repo_role: arn:aws:iam::815624722760:role/core-application-repo - aws_region: eu-west-2 - repository: core - jobs: infra: name: Deploy review app infrastructure @@ -43,51 +38,6 @@ jobs: permissions: id-token: write - performance: - needs: [code] - runs-on: ubuntu-latest - permissions: - id-token: write - - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - aws-region: ${{ env.aws_region }} - role-to-assume: ${{ env.app_repo_role }} - - - name: Configure AWS credentials for the environment - uses: aws-actions/configure-aws-credentials@v3 - with: - aws-region: eu-west-2 - role-to-assume: arn:aws:iam::837698168072:role/core-dev-deployment - role-chaining: true - - - name: Run Performance Test - env: - ad_hoc_task_definition: core-review-${{ github.event.pull_request.number }}-ad-hoc - cluster: core-review-${{ github.event.pull_request.number }}-app - service: core-review-${{ github.event.pull_request.number }}-app - run: | - echo $cluster - network=$(aws ecs describe-services --cluster $cluster --services $service --query services[0].networkConfiguration) - overrides='{ - "containerOverrides": [{ - "name": "app", - "command": ["bash", "-c", "export email=$STAGING_PERFORMANCE_TEST_EMAIL && export password=$STAGING_PERFORMANCE_TEST_PASSWORD && sh ./lib/tasks/performance_test.sh"] - }] - }' - arn=$(aws ecs run-task --cluster $cluster --task-definition $ad_hoc_task_definition --network-configuration "$network" --overrides "$overrides" --group migrations --launch-type FARGATE --query tasks[0].taskArn) - - echo "Waiting for performance tests to run" - task_id=${arn##*/} - task_id=${task_id%*\"} - - aws ecs wait tasks-stopped --cluster $cluster --tasks $task_id - - code=$(aws ecs describe-tasks --cluster $cluster --tasks $task_id --query "tasks[0].containers[0].exitCode") - if [ "$code == 0" ]; then exit 0; else exit 1; fi - comment: name: Add link to PR needs: [code] diff --git a/.github/workflows/staging_pipeline.yml b/.github/workflows/staging_pipeline.yml index 415a943d1..ba65e9cc3 100644 --- a/.github/workflows/staging_pipeline.yml +++ b/.github/workflows/staging_pipeline.yml @@ -13,6 +13,11 @@ on: defaults: run: shell: bash + +env: + app_repo_role: arn:aws:iam::815624722760:role/core-application-repo + aws_region: eu-west-2 + repository: core jobs: test: @@ -364,3 +369,48 @@ jobs: environment: staging permissions: id-token: write + + performance: + needs: [aws_deploy] + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{ env.aws_region }} + role-to-assume: ${{ env.app_repo_role }} + + - name: Configure AWS credentials for the environment + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: eu-west-2 + role-to-assume: arn:aws:iam::107155005276:role/core-staging-deployment + role-chaining: true + + - name: Run Performance Test + env: + ad_hoc_task_definition: core-staging-ad-hoc + cluster: core-staging-app + service: core-staging-app + run: | + echo $cluster + network=$(aws ecs describe-services --cluster $cluster --services $service --query services[0].networkConfiguration) + overrides='{ + "containerOverrides": [{ + "name": "app", + "command": ["bash", "-c", "export email=$STAGING_PERFORMANCE_TEST_EMAIL && export password=$STAGING_PERFORMANCE_TEST_PASSWORD && sh ./lib/tasks/performance_test.sh"] + }] + }' + arn=$(aws ecs run-task --cluster $cluster --task-definition $ad_hoc_task_definition --network-configuration "$network" --overrides "$overrides" --group migrations --launch-type FARGATE --query tasks[0].taskArn) + + echo "Waiting for performance tests to run" + task_id=${arn##*/} + task_id=${task_id%*\"} + + aws ecs wait tasks-stopped --cluster $cluster --tasks $task_id + + code=$(aws ecs describe-tasks --cluster $cluster --tasks $task_id --query "tasks[0].containers[0].exitCode") + if [ "$code == 0" ]; then exit 0; else exit 1; fi