Skip to content

I'm just a test

I'm just a test #9221

Workflow file for this run

name: Deploy
on:
# workflow_dispatch:
# inputs:
# version:
# type: string
# required: false
# description: 'Version of jq to install'
# default: '1.7'
# force:
# type: boolean
# required: false
# description: 'Do not check for existing jq installation before continuing.'
# default: false
push:
branches:
- "*"
- "dependabot/**"
- "!skipci*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write
contents: read
actions: read
jobs:
unit-tests:
name: Unit Tests
uses: ./.github/workflows/unittest-workflow.yml
if: github.ref == 'refs/heads/master'
secrets:
CODE_CLIMATE_ID: ${{ secrets.CODE_CLIMATE_ID }}
deploy:
runs-on: ubuntu-latest
env:
SLS_DEPRECATION_DISABLE: "*" # Turn off deprecation warnings in the pipeline
steps:
- name: set branch_name # Some integrations (Dependabot & Snyk) build very long branch names. This is a switch to make long branch names shorter.
run: |
if [[ "$GITHUB_REF" =~ ^refs/heads/dependabot/.* ]] || [[ "$GITHUB_REF" =~ ^refs/remotes/origin/snyk-upgrade-* ]] || [[ "$GITHUB_REF" =~ ^refs/remotes/origin/snyk-fix-* ]]; then
echo "branch_name=`echo ${GITHUB_REF#refs/heads/} | md5sum | head -c 10 | sed 's/^/x/'`" >> $GITHUB_ENV
else
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- name: 'Setup jq'
uses: dcarbone/[email protected]
with:
version: '${{ inputs.version }}'
force: '${{ inputs.force }}'
- name: 'Check jq'
# language=sh
run: |
which jq
jq --version
# - name: Get IP
# id: get-ip
# run: |
# #!/bin/bash
# # Get the IP address of the runner
# IP_ADDRESS=$(curl https://api.ipify.org)
# echo "Runner IP address: $IP_ADDRESS"
# # Store the IP address as an output variable
# echo "RUNNER_IP=$IP_ADDRESS/32" >> $GITHUB_OUTPUT
# - name: Show IP Address
# run: |
# #!/bin/bash
# echo "IP address from previous step: ${{ steps.get-ip.outputs.RUNNER_IP }}"
- name: Validate branch name
run: ./.github/branchNameValidation.sh $STAGE_PREFIX$branch_name
- name: set branch specific variable names
run: ./.github/build_vars.sh set_names
- name: set variable values
run: ./.github/build_vars.sh set_values
env:
AWS_DEFAULT_REGION: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
STAGE_PREFIX: ${{ secrets.STAGE_PREFIX }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
CODE_CLIMATE_ID: ${{ secrets.CODE_CLIMATE_ID }}
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock', 'plugins/**') }}
- name: set path
run: |
echo "PATH=$(pwd)/node_modules/.bin/:$PATH" >> $GITHUB_ENV
# - name: Fetch AWS IP set ARNs
# id: fetch-ip-set-arns
# run: |
# #!/bin/bash
# # Fetch AWS IP set ARNs using AWS CLI and store them in a variable
# # Get AWS IP set ARNs in JSON format
# AWS_IP_SET_ARNS=$(aws wafv2 list-ip-sets --scope=CLOUDFRONT)
# # Store the IP set ARNs in an output variable using GITHUB_OUTPUT
# echo "GITHUB_OUTPUT::aws_ip_set_arns=$AWS_IP_SET_ARNS"
# IPSET_ARN=$(echo "$AWS_IP_SET_ARNS" | jq -r '.IPSets[0].ARN')
# IPSET_NAME=$(echo "$AWS_IP_SET_ARNS" | jq -r '.IPSets[0].Name')
# IPSET_ID=$(echo "$AWS_IP_SET_ARNS" | jq -r '.IPSets[0].Id')
# IPSET_LOCK_TOKEN=$(echo "$AWS_IP_SET_ARNS" | jq -r '.IPSets[0].LockToken')
# echo "Extracted ARN: $ARN"
# echo "IPSET_ARN=$IPSET_ARN" >> $GITHUB_OUTPUT
# echo "IPSET_NAME=$IPSET_NAME" >> $GITHUB_OUTPUT
# echo "IPSET_ID=$IPSET_ID" >> $GITHUB_OUTPUT
# echo "IPSET_LOCK_TOKEN=$IPSET_LOCK_TOKEN" >> $GITHUB_OUTPUT
# - name: Show AWS IP set ARNs
# run: |
# echo "AWS IP Set ARNs: ${{ steps.fetch-ip-set-arns.outputs.IPSET_ARN }}"
# echo "AWS IP Set Name: ${{ steps.fetch-ip-set-arns.outputs.IPSET_NAME }}"
# echo "AWS IP Set ID: ${{ steps.fetch-ip-set-arns.outputs.IPSET_ID }}"
# echo "AWS IP Lock Token: ${{ steps.fetch-ip-set-arns.outputs.IPSET_LOCK_TOKEN }}"
# - name: create new ip set
# id: create-new-ip-set
# run: |
# newip=${{ steps.get-ip.outputs.RUNNER_IP }}
# oldarr=($(aws wafv2 get-ip-set --scope CLOUDFRONT --id ${{ steps.fetch-ip-set-arns.outputs.IPSET_ID }} --name ${{ steps.fetch-ip-set-arns.outputs.IPSET_NAME }} | jq -r '.IPSet.Addresses | .[]'))
# newarr=()
# for item in "${oldarr[@]}"; do
# newarr+=("$item")
# done
# newarr+=("$newip")
# addresses=$(IFS=" " ; echo "${newarr[*]}")
# echo "Updated IP addresses: $addresses"
# aws wafv2 update-ip-set --name ${{ steps.fetch-ip-set-arns.outputs.IPSET_NAME }} --scope CLOUDFRONT --id ${{ steps.fetch-ip-set-arns.outputs.IPSET_ID }} --lock-token ${{ steps.fetch-ip-set-arns.outputs.IPSET_LOCK_TOKEN }} --addresses $addresses
# - name: Temp Add Runner IP
# run: |
# aws wafv2 update-ip-set --name ${{ steps.fetch-ip-set-arns.outputs.IPSET_NAME }} --scope CLOUDFRONT --id ${{ steps.fetch-ip-set-arns.outputs.IPSET_ID }} --lock-token ${{ steps.fetch-ip-set-arns.outputs.IPSET_LOCK_TOKEN }} --addresses IP_ADDRESS ACTION_ADD=${{ steps.get-ip.outputs.RUNNER_IP }}
# - name: Delete Runner IP
# run: |
# #!/bin/bash
# aws wafv2 update-ip-set --name=${{ steps.fetch-ip-set-arns.outputs.IPSET_NAME }} --scope=CLOUDFRONT --id=${{ steps.fetch-ip-set-arns.outputs.IPSET_ID }} --lock-token=${{ steps.fetch-ip-set-arns.outputs.IPSET_LOCK_TOKEN }} --addresses ${{ steps.get-ip.outputs.RUNNER_IP }} --action=REMOVE
# - name: deploy
# run: |
# # When deploying multiple copies of this quickstart to the same AWS Account (not ideal), a prefix helps prevent stepping on each other.
# # This can optionally be set as an GitHub Actions Secret
# ./deploy.sh $STAGE_PREFIX$branch_name
- name: Endpoint
id: endpoint
run: |
APPLICATION_ENDPOINT=$(./output.sh ui ApplicationEndpointUrl $STAGE_PREFIX$branch_name)
echo "application_endpoint=$APPLICATION_ENDPOINT" >> $GITHUB_OUTPUT
echo "## Application Endpoint" >> $GITHUB_STEP_SUMMARY
echo "<$APPLICATION_ENDPOINT>" >> $GITHUB_STEP_SUMMARY
working-directory: services
outputs:
application_endpoint: ${{ steps.endpoint.outputs.application_endpoint}}
BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION: ${{ steps.set_names.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION }}
BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME: ${{ steps.set_names.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME }}
# run e2e tests after deploy completes
e2e-tests-init:
name: Initialize End To End Tests
if: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/val' && github.ref != 'refs/heads/prod' }}
needs:
- deploy
runs-on: ubuntu-latest
steps:
- name: Verify Endpoint
if: ${{ needs.deploy.outputs.application_endpoint == ''}}
run: |
echo "No endpoint set, Check if the deploy workflow was successful."
exit 1
- uses: actions/checkout@v3
- name: set branch_name
run: |
if [[ "$GITHUB_REF" =~ ^refs/heads/dependabot/.* ]]; then # Dependabot builds very long branch names. This is a switch to make it shorter.
echo "branch_name=`echo ${GITHUB_REF#refs/heads/} | md5sum | head -c 10 | sed 's/^/x/'`" >> $GITHUB_ENV
else
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- name: set branch specific variable names
id: set_names
run: ./.github/build_vars.sh set_names
- name: set variable values
id: set_values
run: ./.github/build_vars.sh set_values
env:
AWS_DEFAULT_REGION: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
INFRASTRUCTURE_TYPE: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_INFRASTRUCTURE_TYPE] || secrets.INFRASTRUCTURE_TYPE || 'development' }}
STAGE_PREFIX: ${{ secrets.STAGE_PREFIX }}
COGNITO_TEST_USERS_PASSWORD: ${{ secrets[env.BRANCH_SPECIFIC_VARNAME_COGNITO_TEST_USERS_PASSWORD] || secrets.COGNITO_TEST_USERS_PASSWORD }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Combine yarn.lock files to single file
run: find services -maxdepth 3 -name yarn.lock | xargs cat yarn.lock > combined-yarn.txt
- name: cache service dependencies
uses: actions/cache@v3
with:
path: |
services/app-api/node_modules
services/uploads/node_modules
services/stream-functions/node_modules
services/ui/node_modules
services/ui-auth/node_modules
services/ui-src/node_modules
node_modules
key: ${{ runner.os }}-${{ hashFiles('combined-yarn.txt') }}
- name: Configure AWS credentials for GitHub Actions
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: set path
run: |
echo "PATH=$(pwd)/node_modules/.bin/:$PATH" >> $GITHUB_ENV
- name: Get Runner IP
id: get-ip
run: |
#!/bin/bash
# Get the IP address of the runner
IP_ADDRESS=$(curl https://api.ipify.org)
echo "Runner IP address: $IP_ADDRESS"
# Store the IP address as an output variable
echo "RUNNER_IP=$IP_ADDRESS/32" >> $GITHUB_OUTPUT
- name: Fetch AWS IP set ARNs
id: fetch-ip-set-info
run: |
#!/bin/bash
# Fetch AWS IP set ARNs using AWS CLI and store them in a variable
AWS_IP_SET_INFO=$(aws wafv2 list-ip-sets --scope=CLOUDFRONT)
# Store the IP set ARNs in an output variable using GITHUB_OUTPUT
#echo "GITHUB_OUTPUT::aws_ip_set_arns=$AWS_IP_SET_ARNS"
#Get Values from the IP SET
IPSET_ARN=$(echo "$AWS_IP_SET_INFO" | jq -r '.IPSets[0].ARN')
IPSET_NAME=$(echo "$AWS_IP_SET_INFO" | jq -r '.IPSets[0].Name')
IPSET_ID=$(echo "$AWS_IP_SET_INFO" | jq -r '.IPSets[0].Id')
IPSET_LOCK_TOKEN=$(echo "$AWS_IP_SET_INFO" | jq -r '.IPSets[0].LockToken')
echo "Extracted ARN: $ARN"
echo "IPSET_ARN=$IPSET_ARN" >> $GITHUB_OUTPUT
echo "IPSET_NAME=$IPSET_NAME" >> $GITHUB_OUTPUT
echo "IPSET_ID=$IPSET_ID" >> $GITHUB_OUTPUT
echo "IPSET_LOCK_TOKEN=$IPSET_LOCK_TOKEN" >> $GITHUB_OUTPUT
- name: Update IP Set
id: update-ip-set
run: |
newip=${{ steps.get-ip.outputs.RUNNER_IP }}
oldarr=($(aws wafv2 get-ip-set --scope CLOUDFRONT --id ${{ steps.fetch-ip-set-info.outputs.IPSET_ID }} --name ${{ steps.fetch-ip-set-info.outputs.IPSET_NAME }} | jq -r '.IPSet.Addresses | .[]'))
newarr=()
for item in "${oldarr[@]}"; do
newarr+=("$item")
done
newarr+=("$newip")
addresses=$(IFS=" " ; echo "${newarr[*]}")
echo "Updated IP addresses: $addresses"
aws wafv2 update-ip-set --name ${{ steps.fetch-ip-set-info.outputs.IPSET_NAME }} --scope CLOUDFRONT --id ${{ steps.fetch-ip-set-info.outputs.IPSET_ID }} --lock-token ${{ steps.fetch-ip-set-info.outputs.IPSET_LOCK_TOKEN }} --addresses $addresses
outputs:
application_endpoint: ${{ needs.deploy.outputs.application_endpoint }}
setup-tests:
name: "Setup End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- deploy
with:
test-path: "init"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
child-e2e-measure-tests:
name: "Child End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
- deploy
with:
test-path: "measures/child"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
adult-e2e-measure-tests:
name: "Adult End To End Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
- deploy
with:
test-path: "measures/adult"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
health-home-e2e-measure-tests:
name: "Health Home End To End Measure Tests"
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
- deploy
with:
test-path: "measures/healthhome"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
e2e-feature-tests:
name: End To End Feature Tests
uses: ./.github/workflows/cypress-workflow.yml
needs:
- e2e-tests-init
- setup-tests
- deploy
with:
test-path: "features"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}
a11y-tests:
name: Accessibility Tests
needs:
- e2e-tests-init
- e2e-feature-tests
- child-e2e-measure-tests
- adult-e2e-measure-tests
- health-home-e2e-measure-tests
- deploy
uses: ./.github/workflows/cypress-workflow.yml
with:
test-path: "a11y"
test-endpoint: "${{ needs.e2e-tests-init.outputs.application_endpoint }}"
secrets:
slack-url: ${{ secrets.SLACK_WEBHOOK_URL }}
AWS_DEFAULT_REGION: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_DEFAULT_REGION] || secrets.AWS_DEFAULT_REGION }}
AWS_OIDC_ROLE_TO_ASSUME: ${{ secrets[needs.deploy.outputs.BRANCH_SPECIFIC_VARNAME_AWS_OIDC_ROLE_TO_ASSUME] || secrets.AWS_OIDC_ROLE_TO_ASSUME }}
cypress-user1: ${{ secrets.CYPRESS_TEST_USER_1 }}
cypress-user2: ${{ secrets.CYPRESS_TEST_USER_2 }}
cypress-user3: ${{ secrets.CYPRESS_TEST_USER_3 }}
cypress-user4: ${{ secrets.CYPRESS_TEST_USER_4 }}
cypress-password: ${{ secrets.CYPRESS_TEST_PASSWORD_1 }}