Run Cypress tests #7
Workflow file for this run
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: Run Cypress tests | |
on: | |
workflow_call: | |
inputs: | |
environment: | |
required: true | |
type: string | |
secrets: | |
USERNAME: | |
required: true | |
AZURE_WEB_ENDPOINT: | |
required: true | |
AZURE_API_ENDPOINT: | |
required: true | |
AZURE_API_KEY: | |
required: true | |
CYPRESS_TEST_SECRET: | |
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" | |
] | |
container: | |
image: cypress/browsers:22.12.0 | |
defaults: | |
run: | |
working-directory: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Prepare Cypress cache | |
uses: cypress-io/github-action@v6 | |
with: | |
runTests: false | |
browser: ${{ matrix.browser }} | |
working-directory: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests | |
- name: Run (dev) | |
if: inputs.environment == 'development' | |
uses: cypress-io/github-action@v6 | |
env: | |
CYPRESS_username: ${{ secrets.USERNAME }} | |
CYPRESS_grepTags: '-smoke' | |
CYPRESS_url: ${{ secrets.AZURE_WEB_ENDPOINT }} | |
CYPRESS_apiKey: ${{ secrets.AZURE_API_KEY }} | |
CYPRESS_authKey: ${{ secrets.CYPRESS_TEST_SECRET }} | |
with: | |
browser: ${{ matrix.browser }} | |
working-directory: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests | |
wait-on: ${{ secrets.AZURE_ENDPOINT }} | |
spec: cypress/e2e/smoke/* | |
install: false | |
- name: Run (test) | |
if: inputs.environment == 'test' | |
uses: cypress-io/github-action@v6 | |
env: | |
CYPRESS_username: ${{ secrets.USERNAME }} | |
CYPRESS_url: ${{ secrets.AZURE_WEB_ENDPOINT }} | |
CYPRESS_apiKey: ${{ secrets.AZURE_API_KEY }} | |
CYPRESS_authKey: ${{ secrets.CYPRESS_TEST_SECRET }} | |
with: | |
browser: ${{ matrix.browser }} | |
working-directory: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests | |
wait-on: ${{ secrets.AZURE_ENDPOINT }} | |
spec: cypress/e2e/smoke/* | |
install: false | |
- name: Upload screenshots | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots-${{ inputs.environment }}-${{ matrix.browser }} | |
path: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/cypress/screenshots | |
- name: Generate report | |
if: always() | |
run: | | |
mkdir mochareports | |
npm run generate:html:report | |
- name: Upload report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: reports-${{ inputs.environment }}-${{ matrix.browser }} | |
path: Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects.CypressTests/mochareports | |
- name: Report results | |
if: always() | |
run: npm run cy:notify -- --custom-text="Environment ${{ inputs.environment }}, See more information https://github.com/DFE-Digital/manage-free-schools-projects/actions/runs/${{github.run_id}}" | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |