E2E Tests #9345
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
commit_sha: | |
description: Run the full E2E test suite on a specific commit | |
required: true | |
workflow_run: | |
workflows: [Continuous Integration] | |
types: [completed] | |
branches: [main] | |
env: | |
NUM_CONTAINERS: '8' | |
BUILDTYPE: vagovprod | |
jobs: | |
set-commit-sha: | |
name: Set commit sha | |
runs-on: ubuntu-latest | |
outputs: | |
COMMIT_SHA: ${{ env.COMMIT_SHA }} | |
steps: | |
- name: Get commit sha from workflow_run | |
if: ${{ github.event_name == 'workflow_run' }} | |
run: echo 'COMMIT_SHA=${{ github.event.workflow_run.head_sha }}' >> $GITHUB_ENV | |
- name: Get commit sha from workflow_dispatch | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: echo 'COMMIT_SHA=${{ github.event.inputs.commit_sha }}' >> $GITHUB_ENV | |
determine-build-type: | |
name: Determine if commit has full build | |
runs-on: ubuntu-latest | |
needs: set-commit-sha | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Install dependencies | |
uses: ./.github/workflows/install | |
with: | |
key: ${{ hashFiles('yarn.lock') }} | |
yarn_cache_folder: .cache/yarn | |
path: | | |
.cache/yarn | |
node_modules | |
- name: List changed files | |
id: changed-files | |
run: echo all_changed_files=$(git diff-tree --no-commit-id --name-only -r ${{ needs.set-commit-sha.outputs.COMMIT_SHA }}) >> $GITHUB_OUTPUT | |
- name: Get app entries for changed files | |
id: get-changed-apps | |
run: echo app_entries=$(node script/github-actions/get-changed-apps.js) >> $GITHUB_OUTPUT | |
env: | |
CHANGED_FILE_PATHS: ${{ steps.changed-files.outputs.all_changed_files }} | |
- name: Cancel workflow if commit has full build | |
if: ${{ github.event_name == 'workflow_run' && steps.get-changed-apps.outputs.app_entries == '' }} | |
uses: andymckay/cancel-action@0.2 | |
build: | |
name: Build | |
runs-on: self-hosted | |
needs: set-commit-sha | |
env: | |
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/VA-Internal-S2-RCA1-v1.cer.pem | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Install dependencies | |
uses: ./.github/workflows/install | |
with: | |
key: ${{ hashFiles('yarn.lock') }} | |
yarn_cache_folder: .cache/yarn | |
path: | | |
.cache/yarn | |
node_modules | |
# Temporarily disabled due to apparent memory issues caused by code coverage tools | |
# - name: Add istanbul for Cypress code coverage reporting | |
# run: | | |
# sed -i -e 's/\"istanbul\",//g' babel.config.json | |
# sed -i -e 's/\"lodash\",/\"lodash\", \"istanbul\",/g' babel.config.json | |
- name: Configure AWS Credentials | |
uses: ./.github/workflows/configure-aws-credentials | |
with: | |
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: us-gov-west-1 | |
- name: Get Mapbox Token | |
uses: ./.github/workflows/inject-secrets | |
with: | |
ssm_parameter: /dsva-vagov/vets-website/dev/mapbox_token | |
env_variable_name: MAPBOX_TOKEN | |
- name: Build | |
run: yarn build --verbose --buildtype=${{ env.BUILDTYPE }} | |
timeout-minutes: 30 | |
- name: Compress and archive build | |
run: tar -C build/${{ env.BUILDTYPE }} -cjf ${{ env.BUILDTYPE }}.tar.bz2 . | |
- name: Upload build artifact | |
uses: ./.github/workflows/upload-artifact | |
with: | |
name: ${{ env.BUILDTYPE }}.tar.bz2 | |
path: ${{ env.BUILDTYPE }}.tar.bz2 | |
retention-days: 1 | |
cypress-tests-prep: | |
name: Prep for Cypress Tests | |
runs-on: ubuntu-latest | |
needs: set-commit-sha | |
outputs: | |
tests: ${{ steps.tests.outputs.selected }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Install dependencies | |
uses: ./.github/workflows/install | |
with: | |
key: ${{ hashFiles('yarn.lock') }} | |
yarn_cache_folder: .cache/yarn | |
path: | | |
.cache/yarn | |
node_modules | |
- name: Set TESTS variable | |
run: node script/github-actions/select-cypress-tests.js | |
env: | |
RUN_FULL_SUITE: true | |
CHANGED_FILE_PATHS: '' | |
- name: Set output of TESTS | |
id: tests | |
run: echo selected=$TESTS >> $GITHUB_OUTPUT | |
cypress-tests: | |
name: Cypress E2E Tests | |
runs-on: self-hosted | |
needs: [set-commit-sha, build, cypress-tests-prep] | |
if: | | |
needs.build.result == 'success' && | |
needs.cypress-tests-prep.result == 'success' | |
container: | |
image: public.ecr.aws/cypress-io/cypress/browsers:node16.14.2-slim-chrome103-ff102 | |
options: -u 1001:1001 -v /usr/local/share:/share | |
strategy: | |
fail-fast: false | |
max-parallel: 12 | |
matrix: | |
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] | |
env: | |
CHROMEDRIVER_FILEPATH: /share/chrome_driver/chromedriver | |
NODE_EXTRA_CA_CERTS: /share/ca-certificates/VA-Internal-S2-RCA1-v1.cer.crt | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Configure AWS credentials | |
uses: ./.github/workflows/configure-aws-credentials | |
with: | |
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: us-gov-west-1 | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Download production build artifact | |
uses: ./.github/workflows/download-artifact | |
with: | |
name: ${{ env.BUILDTYPE }}.tar.bz2 | |
- name: Unpack build | |
run: | | |
mkdir -p build/${{ env.BUILDTYPE }} | |
tar -C build/${{ env.BUILDTYPE }} -xjf ${{ env.BUILDTYPE }}.tar.bz2 | |
- name: Install dependencies | |
uses: ./.github/workflows/install | |
with: | |
key: ${{ hashFiles('yarn.lock') }} | |
yarn_cache_folder: .cache/yarn | |
path: | | |
.cache/yarn | |
/github/home/.cache/Cypress | |
node_modules | |
- name: Start server | |
run: node src/platform/testing/e2e/test-server.js --buildtype=${{ env.BUILDTYPE }} --port=3001 & | |
# Temporarily disabled due to apparent memory issues caused by code coverage tools | |
# - name: Instrument code | |
# run: npx nyc instrument --compact=false src .nyc_output | |
- name: Run Cypress tests | |
run: node script/github-actions/run-cypress-tests.js | |
timeout-minutes: 40 | |
env: | |
CYPRESS_CI: true | |
CODE_COVERAGE: true | |
STEP: ${{ matrix.ci_node_index }} | |
TESTS: ${{ needs.cypress-tests-prep.outputs.tests }} | |
APP_URLS: '' | |
NUM_CONTAINERS: 12 | |
# Temporarily disabled due to apparent memory issues caused by code coverage tools | |
# - name: View code coverage summary | |
# run: npx nyc report --reporter=text-summary | |
# Temporarily disabled due to apparent memory issues caused by code coverage tools | |
# - name: Create coverage artifact | |
# uses: ./.github/workflows/upload-artifact | |
# if: ${{ always() }} | |
# with: | |
# name: code-coverage-artifacts | |
# path: coverage/coverage-summary.json | |
- name: Archive test videos | |
uses: ./.github/workflows/upload-artifact | |
if: ${{ failure() }} | |
with: | |
name: cypress-video-artifacts-${{ matrix.ci_node_index }} | |
path: cypress/videos | |
- name: Archive test screenshots | |
uses: ./.github/workflows/upload-artifact | |
if: ${{ failure() }} | |
with: | |
name: cypress-screenshot-artifacts-${{ matrix.ci_node_index }} | |
path: cypress/screenshots | |
- name: Archive Mochawesome test results | |
uses: ./.github/workflows/upload-artifact | |
if: ${{ always() }} | |
with: | |
name: cypress-mochawesome-test-results-${{ matrix.ci_node_index }} | |
path: cypress/results | |
retention-days: 1 | |
testing-reports-prep: | |
name: Testing Reports Prep | |
runs-on: ubuntu-latest | |
needs: [set-commit-sha, determine-build-type] | |
continue-on-error: true | |
outputs: | |
app_list: ${{ env.APPLICATION_LIST }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Install dependencies | |
uses: ./.github/workflows/install | |
with: | |
key: ${{ hashFiles('yarn.lock') }} | |
yarn_cache_folder: .cache/yarn | |
path: | | |
.cache/yarn | |
node_modules | |
- name: Generate new application list | |
run: yarn generate-app-list | |
- name: Configure AWS credentials | |
uses: ./.github/workflows/configure-aws-credentials | |
with: | |
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: us-gov-west-1 | |
- name: Get va-vsp-bot token | |
uses: ./.github/workflows/inject-secrets | |
with: | |
ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN | |
env_variable_name: VA_VSP_BOT_GITHUB_TOKEN | |
- name: Init Dashboard Data Repo | |
uses: ./.github/workflows/init-data-repo | |
- name: Set Up BigQuery Creds | |
uses: ./.github/workflows/configure-bigquery | |
- name: Upload app list to BigQuery | |
run: yarn generate-app-list | |
working-directory: qa-standards-dashboard-data | |
testing-reports-cypress: | |
name: Testing Reports - Cypress E2E Tests | |
runs-on: ubuntu-latest | |
needs: | |
[set-commit-sha, testing-reports-prep, cypress-tests-prep, cypress-tests] | |
continue-on-error: true | |
if: ${{ always() && needs.cypress-tests-prep.outputs.tests != '[]' && (needs.cypress-tests.result == 'success' || needs.cypress-tests.result == 'failure') }} | |
env: | |
APPLICATION_LIST: ${{ needs.testing-reports-prep.outputs.app_list }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
# ------------------------ | |
# | Upload BigQuery Data | | |
# ------------------------ | |
- name: Configure AWS credentials | |
uses: ./.github/workflows/configure-aws-credentials | |
with: | |
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: us-gov-west-1 | |
- name: Get va-vsp-bot token | |
uses: ./.github/workflows/inject-secrets | |
with: | |
ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN | |
env_variable_name: VA_VSP_BOT_GITHUB_TOKEN | |
- name: Init Dashboard Data Repo | |
uses: ./.github/workflows/init-data-repo | |
- name: Set Up BigQuery Creds | |
uses: ./.github/workflows/configure-bigquery | |
- name: Get AWS IAM role | |
uses: ./.github/workflows/inject-secrets | |
with: | |
ssm_parameter: /frontend-team/github-actions/parameters/AWS_FRONTEND_NONPROD_ROLE | |
env_variable_name: AWS_FRONTEND_NONPROD_ROLE | |
- name: Set UUID for Mochawesome reports | |
run: echo "UUID=$(uuidgen)" >> $GITHUB_ENV | |
- name: Configure AWS Credentials (2) | |
uses: ./.github/workflows/configure-aws-credentials | |
with: | |
aws_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: us-gov-west-1 | |
role: ${{ env.AWS_FRONTEND_NONPROD_ROLE }} | |
role_duration: 900 | |
session_name: vsp-frontendteam-githubaction | |
# -------------------------------------- | |
# | Publish Cypress E2E Testing Report | | |
# -------------------------------------- | |
- name: Download Cypress E2E Mochawesome test results | |
uses: ./.github/workflows/download-artifact | |
with: | |
pattern: cypress-mochawesome-test-results-* | |
path: qa-standards-dashboard-data/src/testing-reports/data | |
merge-multiple: true | |
- name: Download Cypress E2E video artifacts | |
if: ${{ needs.cypress-tests.result == 'failure' }} | |
uses: ./.github/workflows/download-artifact | |
with: | |
pattern: cypress-video-artifacts-* | |
path: qa-standards-dashboard-data/videos/${{ env.UUID }} | |
merge-multiple: true | |
- name: Create Cypress E2E report and post results to BigQuery | |
run: yarn cypress-mochawesome-to-bigquery | |
working-directory: qa-standards-dashboard-data | |
env: | |
IS_MASTER_BUILD: true | |
TEST_EXECUTIONS_TABLE_NAME: cypress_test_suite_executions | |
TEST_RESULTS_TABLE_NAME: cypress_test_results | |
TEST_REPORTS_FOLDER_NAME: vets-website-cypress-reports | |
TEST_RETRIES_TABLE_NAME: cypress_retry_records | |
NUM_CONTAINERS: 12 | |
- name: Upload Cypress E2E test videos to s3 | |
if: ${{ needs.cypress-tests.result == 'failure' }} | |
run: aws s3 cp qa-standards-dashboard-data/videos/${{ env.UUID }} s3://testing-tools-testing-reports/vets-website-cypress-reports/videos/${{ env.UUID }} --acl public-read --region us-gov-west-1 --recursive | |
- name: Upload Cypress E2E test report to s3 | |
run: aws s3 cp qa-standards-dashboard-data/mochawesome-report s3://testing-tools-testing-reports/vets-website-cypress-reports --acl public-read --region us-gov-west-1 --recursive | |
# ------------------------- | |
# | Cypress Tests Summary | | |
# ------------------------- | |
- name: Publish Cypress test results | |
if: ${{ always() }} | |
uses: ./.github/workflows/checks-action | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Cypress Tests Summary | |
conclusion: ${{ needs.cypress-tests.result }} | |
output: | | |
{"summary":${{ env.MOCHAWESOME_REPORT_RESULTS }}} | |
# e2e-code-coverage-cypress: | |
# name: E2E Code Coverage Reports | |
# runs-on: ubuntu-latest | |
# needs: | |
# [set-commit-sha, testing-reports-prep, cypress-tests-prep, cypress-tests] | |
# continue-on-error: true | |
# if: ${{ always() && (needs.cypress-tests.result == 'success' || needs.cypress-tests.result == 'failure') }} | |
# env: | |
# APPLICATION_LIST: ${{ needs.testing-reports-prep.outputs.app_list }} | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
# with: | |
# ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
# - name: Configure AWS credentials | |
# uses: aws-actions/configure-aws-credentials@v4 | |
# with: | |
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# aws-region: us-gov-west-1 | |
# mask-aws-account-id: true | |
# - name: Get GitHub token | |
# uses: department-of-veterans-affairs/action-inject-ssm-secrets@latest | |
# with: | |
# ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN | |
# env_variable_name: VA_VSP_BOT_GITHUB_TOKEN | |
# - name: Init Dashboard Data Repo | |
# uses: ./.github/workflows/init-data-repo | |
# - name: Install dependencies | |
# uses: ./.github/workflows/install | |
# with: | |
# key: ${{ hashFiles('yarn.lock') }} | |
# yarn_cache_folder: .cache/yarn | |
# path: | | |
# .cache/yarn | |
# node_modules | |
# - name: Generate new application list | |
# run: yarn generate-app-list | |
# - name: Get va-vsp-bot token | |
# uses: department-of-veterans-affairs/action-inject-ssm-secrets@latest | |
# with: | |
# ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN | |
# env_variable_name: VA_VSP_BOT_GITHUB_TOKEN | |
# - name: Set Up BigQuery Creds | |
# uses: ./.github/workflows/configure-bigquery | |
# # -------------------------------------- | |
# # | Publish Code Coverage Report | | |
# # -------------------------------------- | |
# - name: Download Code Coverage test results | |
# uses: ./.github/workflows/download-artifact | |
# with: | |
# name: code-coverage-artifacts | |
# path: qa-standards-dashboard-data/src/testing-reports/data | |
# - name: Push E2E Code Coverage Results to BigQuery | |
# run: yarn e2e-code-coverage-to-bigquery | |
# working-directory: qa-standards-dashboard-data | |
notify-failure: | |
name: Notify Failure | |
runs-on: ubuntu-latest | |
needs: [set-commit-sha, cypress-tests] | |
if: ${{ failure() }} | |
env: | |
VETS_WEBSITE_CHANNEL_ID: C02V265VCGH #status-vets-website | |
steps: | |
- name: Checkout | |
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017 | |
with: | |
ref: ${{ needs.set-commit-sha.outputs.COMMIT_SHA }} | |
- name: Notify Slack - \#status-vets-website | |
uses: ./.github/workflows/slack-notify | |
continue-on-error: true | |
env: | |
SSL_CERT_DIR: /etc/ssl/certs | |
with: | |
payload: '{"attachments": [{"color": "#FF0800","blocks": [{"type": "section","text": {"type": "mrkdwn","text": "@qa-standards-team Full E2E test suite run in `vets-website` failed: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>"}}]}]}' | |
channel_id: ${{ env.VETS_WEBSITE_CHANNEL_ID }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Notify Slack - \#gha-test-status | |
uses: ./.github/workflows/slack-notify | |
continue-on-error: true | |
env: | |
SSL_CERT_DIR: /etc/ssl/certs | |
with: | |
payload: '{"attachments": [{"color": "#FF0800","blocks": [{"type": "section","text": {"type": "mrkdwn","text": "Full E2E test suite run in `vets-website` failed: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>"}}]}]}' | |
channel_id: C026PD47Z19 #gha-test-status | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |