Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress integration test workflow #32279

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/cypress-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Cypress Integration Test Workflow

on:
workflow_dispatch:
inputs:
product:
description: 'individual product to be tested'
required: true
# TO-DO: create a solution that maintains an updated list of active products within src/applications
branch:
description: 'branch with currently failing e2e tests in CI'
required: true
# TO-DO: add a commit input to allow devs to determine a commit point of failure in the branch

env:
BUILDTYPE: vagovprod
VETS_WEBSITE_CHANNEL_ID: ''

jobs:
validate-and-set-product-selection:
name: Set product directory for testing
runs-on: ubuntu-latest
steps:
- name: Run integration helper script
run: |
chmod +x ./script/github-actions/cypress-integration-test.sh
./scripts/integration-helper.sh "${{ github.event.inputs.product }}"

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}

- name: Install dependencies
uses: ./.github/workflows/install
timeout-minutes: 30
with:
key: ${{ hashFiles('yarn.lock') }}
yarn_cache_folder: .cache/yarn
path: |
.cache/yarn
node_modules

- 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: Generate build details
run: |
cat > build/${{ env.BUILDTYPE }}/BUILD.txt << EOF
BUILDTYPE=${{ env.BUILDTYPE }}
NODE_ENV=production
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}")
CHANGE_TARGET=null
RUN_ID=${{ github.run_id }}
RUN_NUMBER=${{ github.run_number }}
REF=${{ github.sha }}
BUILDTIME=$(date +%s)
EOF

- 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

call-integration-test-workflow:
name: Call Integration Test Workflow
uses: department-of-veterans-affairs/vagov-cypress-integration-tests/.github/workflows/cypress-test-integration-workflow.yml@main
secrets: inherit

notify-failure:
name: Notify Failure
runs-on: ubuntu-latest
if: ${{ failure() || cancelled() }}
needs: call-integration-test-workflow

steps:
- name: Checkout
uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017

- name: Notify Slack
uses: ./.github/workflows/slack-notify
continue-on-error: true
with:
payload: '{"attachments": [{"color": "#FF0800","blocks": [{"type": "section","text": {"type": "mrkdwn","text": "vets-website manual dev/staging deploy failed!: <https://github.com/${{github.repository}}/actions/runs/${{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 }}

3 changes: 3 additions & 0 deletions config/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ const cypressConfig = {
height: 720,
},
],
integration: {
specPattern: process.env.INTEGRATION_APP_PATH,
},
},
e2e: {
setupNodeEvents(on, config) {
Expand Down
28 changes: 28 additions & 0 deletions script/github-actions/cypress-integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

integrationHelper() {
local product="$1"
local app_path="src/applications/${product}"

if [[ ! -d "$app_path" ]]; then
echo "Error: Directory '${app_path}' does not exist."
exit 1
fi

export INTEGRATION_APP_PATTERN="${app_path}"

local slack_group
slack_group=$(jq -r --arg product "$product" '.apps[] | select(.rootFolder == $product) | .slackGroup' ./config/changed-apps-build.json)

if [[ -z "$slack_group" ]]; then
echo "Error: no slackGroup found for product '$product'"
exit 1
fi

export SLACK_GROUP="$slack_group"

echo "VETS_WEBSITE_CHANNEL_ID=$SLACK_GROUP" >> $GITHUB_ENV
echo "INTEGRATION_APP_PATTERN=$INTEGRATION_APP_PATTERN" >> $GITHUB_ENV
}

integrationHelper "$1"
8 changes: 8 additions & 0 deletions script/github-actions/integration-test-definitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const productInput = process.env.TARGET_APP_INTEGRATION_TEST;

function integrationHelper() {
process.env.INTEGRATION_APP_PATH = `src/applications/${productInput}/**/*.cypress.spec.js`;
return process.env.INTEGRATION_APP_PATH;
}

module.exports = integrationHelper;
Loading