|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Install Apache Benchmark (ab)
|
|
|
|
run: sudo apt-get update && sudo apt-get install -y apache2-utils
|
|
|
|
|
|
|
|
- name: Run Performance Test
|
|
|
|
run: |
|
|
|
|
echo "Fetching CSRF token..."
|
|
|
|
TOKEN=$(curl -c token_cookies.txt -s https://review.submit-social-housing-data.levellingup.gov.uk/${{ github.event.pull_request.number }}/account/sign-in | grep '<meta name="csrf-token"' | sed -n 's/.*content="\([^"]*\)".*/\1/p')
|
|
|
|
|
|
|
|
if [ -z "$TOKEN" ]; then
|
|
|
|
echo "Failed to retrieve CSRF token."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f token_cookies.txt ]; then
|
|
|
|
echo "token_cookies.txt exists."
|
|
|
|
else
|
|
|
|
echo "token_cookies.txt does not exist."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Logging in..."
|
|
|
|
curl -L -c login_cookies.txt -b token_cookies.txt -X POST https://review.submit-social-housing-data.levellingup.gov.uk/${{ github.event.pull_request.number }}/account/sign-in \
|
|
|
|
-d "user[email]=$PERFORMANCE_TESTING_USER_EMAIL" \
|
|
|
|
-d "user[password]=$PERFORMANCE_TESTING_USER_PASSWORD" \
|
|
|
|
-d "authenticity_token=$TOKEN"
|
|
|
|
|
|
|
|
if [ -f login_cookies.txt ]; then
|
|
|
|
echo "login_cookies.txt exists."
|
|
|
|
else
|
|
|
|
echo "login_cookies.txt does not exist."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Extract cookies for use in the benchmark
|
|
|
|
COOKIES=$(awk '/_data_collector_session/ { print $6, $7 }' login_cookies.txt | tr ' ' '=')
|
|
|
|
|
|
|
|
# Run the Apache Benchmark
|
|
|
|
ab -n 50 -c 50 -C "$COOKIES" 'https://review.submit-social-housing-data.levellingup.gov.uk/${{ github.event.pull_request.number }}/lettings-logs'
|
|
|
|
|
|
|
|
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*
|