Skip to content

Cypress Tests using Cypress Docker Image #20

Cypress Tests using Cypress Docker Image

Cypress Tests using Cypress Docker Image #20

Workflow file for this run

name: Cypress Tests using Cypress Docker Image
on:
workflow_call:
inputs:
environment:
required: true
type: string
secrets:
AZURE_ENDPOINT:
required: true
CYPRESS_TEST_SECRET:
required: true
CYPRESS_ACADEMISATION_API_URL:
required: true
CYPRESS_ACADEMISATION_API_KEY:
required: true
DB_CONNECTION_STRING:
required: true
SLACK_WEBHOOK_URL:
required: true
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
required: true
type: environment
concurrency:
group: ${{ github.workflow }}
jobs:
cypress-tests:
name: Run Cypress Tests
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
strategy:
matrix:
browser: [
"edge"
]
project: [
"conversions",
"transfers"
]
include:
- project: "transfers"
working_dir: "./Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests"
- project: "conversions"
working_dir: "./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests"
container:
image: cypress/browsers:22.12.0
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- run: |
INPUT=${{ github.event.inputs.environment }}
ENVIRONMENT=${INPUT:-"Dev"}
if [[ $ENVIRONMENT == 'Staging' ]]
then
echo "GREP=-dao" >> $GITHUB_ENV
else
echo "GREP=" >> $GITHUB_ENV
fi
- name: Run (${{ inputs.environment }})
uses: cypress-io/github-action@v6
env:
CYPRESS_db: ${{ secrets.DB_CONNECTION_STRING }}
CYPRESS_url: ${{ secrets.AZURE_ENDPOINT }}
CYPRESS_cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
CYPRESS_academisationApiUrl: ${{ secrets.CYPRESS_ACADEMISATION_API_URL }}
CYPRESS_academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY }}
CYPRESS_grep: ${{ env.GREP }}
with:
browser: ${{ matrix.browser }}
working-directory: ${{ matrix.working_dir }}
wait-on: ${{ secrets.AZURE_ENDPOINT }}
- name: Upload screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ matrix.project }}-${{ inputs.environment }}-${{ matrix.browser }}
path: ${{ matrix.working_dir }}/cypress/screenshots
- name: Upload reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: reports-${{ inputs.environment }}-${{ matrix.project }}-${{ matrix.browser }}
path: ${{ matrix.working_dir }}/cypress/reports
build-reports:
name: Build combined reports
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: cypress-tests
env:
working_dir: "./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
working-directory: ${{ env.working_dir }}
- name: Download reports
uses: actions/download-artifact@v4
with:
pattern: reports-${{ inputs.environment }}-*
path: ${{ env.working_dir }}/reports
merge-multiple: true
- name: Generate combined report
working-directory: ${{ env.working_dir }}
run: |
mkdir mochareports
npm run generate:html:report
- name: Upload combined report
if: always()
uses: actions/upload-artifact@v4
with:
name: combined-reports-${{ inputs.environment }}
path: mochareports
- name: Report results to Slack
if: always()
run: npm run cy:notify -- --custom-text="Environment ${{ inputs.environment }}, See more information https://github.com/DFE-Digital/prepare-academy-conversions/actions/runs/${{github.run_id}}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}