|
|
|
name: Review app pipeline
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: review-${{ github.event.pull_request.number }}
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
- reopened
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
env:
|
|
|
|
app_repo_role: arn:aws:iam::815624722760:role/core-application-repo
|
|
|
|
aws_region: eu-west-2
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
infra:
|
|
|
|
name: Deploy review app infrastructure
|
|
|
|
uses: communitiesuk/submit-social-housing-lettings-and-sales-data-infrastructure/.github/workflows/create_review_app_infra.yml@main
|
|
|
|
with:
|
|
|
|
key: ${{ github.event.pull_request.number }}
|
|
|
|
app_repo_role: arn:aws:iam::815624722760:role/core-application-repo
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
|
|
|
|
code:
|
|
|
|
name: Deploy review app code
|
|
|
|
needs: [infra]
|
|
|
|
uses: ./.github/workflows/aws_deploy.yml
|
|
|
|
with:
|
|
|
|
aws_account_id: 837698168072
|
|
|
|
aws_role_prefix: core-dev
|
|
|
|
aws_task_prefix: core-review-${{ github.event.pull_request.number }}
|
|
|
|
concurrency_tag: ${{ github.event.pull_request.number }}
|
|
|
|
environment: review
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
|
|
|
|
performance:
|
|
|
|
needs: [code]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
with:
|
|
|
|
aws_role_prefix: core-dev
|
|
|
|
aws_task_prefix: core-review-${{ github.event.pull_request.number }}
|
|
|
|
environment: review
|
|
|
|
|
|
|
|
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: Login to Amazon ECR
|
|
|
|
id: ecr-login
|
|
|
|
uses: aws-actions/amazon-ecr-login@v1
|
|
|
|
with:
|
|
|
|
mask-password: "true"
|
|
|
|
|
|
|
|
- name: Run Performance Test
|
|
|
|
env:
|
|
|
|
ad_hoc_task_definition: ${{ inputs.aws_task_prefix }}-ad-hoc
|
|
|
|
cluster: ${{ inputs.aws_task_prefix }}-app
|
|
|
|
service: ${{ inputs.aws_task_prefix }}-app
|
|
|
|
email: performance_testing_user@example.com
|
|
|
|
password: password
|
|
|
|
run: |
|
|
|
|
network=$(aws ecs describe-services --cluster $cluster --services $service --query services[0].networkConfiguration)
|
|
|
|
overrides='{ "containerOverrides" : [{ "name" : "app", "command" : ["bundle", "exec", "rake", "performance:run_ab[$email,$password]"]}]}'
|
|
|
|
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 test task to complete"
|
|
|
|
temp=${arn##*/}
|
|
|
|
id=${temp%*\"}
|
|
|
|
aws ecs wait tasks-stopped --cluster $cluster --tasks $id
|
|
|
|
succeeded=$(aws ecs describe-tasks --cluster $cluster --tasks $id --query "tasks[0].stopCode == 'EssentialContainerExited' && to_string(tasks[0].containers[0].exitCode) == '0'")
|
|
|
|
if [ $succeeded == true ]; then exit 0; else exit 1; fi
|
|
|
|
env:
|
|
|
|
PERFORMANCE_TESTING_USER_EMAIL: coordinator1@example.com
|
|
|
|
PERFORMANCE_TESTING_USER_PASSWORD: password
|
|
|
|
|
|
|
|
comment:
|
|
|
|
name: Add link to PR
|
|
|
|
needs: [code]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
issues: write
|
|
|
|
pull-requests: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Comment on PR with URL
|
|
|
|
uses: unsplash/comment-on-pr@v1.3.0
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
msg: "Created review app at https://review.submit-social-housing-data.levellingup.gov.uk/${{ github.event.pull_request.number }}"
|
|
|
|
check_for_duplicate_msg: true
|
|
|
|
duplicate_msg_pattern: Created review app at*
|