Skip to content

Commit

Permalink
Optimised to use Cypress base actions
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Dec 11, 2024
1 parent 393d8ed commit 5c5db89
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Cypress tests
name: Cypress Tests using Cypress Docker Image

on:
workflow_call:
Expand Down Expand Up @@ -29,14 +29,18 @@ on:
concurrency:
group: ${{ github.workflow }}

env:
NODE_VERSION: 18.x

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.PrepareConversions/Dfe.PrepareConversions.CypressTests
Expand All @@ -45,31 +49,55 @@ jobs:
with:
ref: ${{ github.ref }}

- name: Setup node.js
uses: actions/setup-node@v4
- name: Prepare Cypress cache
uses: cypress-io/github-action@v6
env:
db: ${{ secrets.DB_CONNECTION_STRING }}
url: ${{ secrets.AZURE_ENDPOINT }}
cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
academisationApiUrl: ${{secrets.CYPRESS_ACADEMISATION_API_URL}}
academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}
with:
node-version: ${{ env.NODE_VERSION }}
runTests: false
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests

- name: Npm install
run: npm install

- name: Run cypress (dev)
- name: Cypress run (dev)
if: inputs.environment == 'dev'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
uses: cypress-io/github-action@v6
env:
db: ${{ secrets.DB_CONNECTION_STRING }}
url: ${{ secrets.AZURE_ENDPOINT }}
cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
academisationApiUrl: ${{secrets.CYPRESS_ACADEMISATION_API_URL}}
academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Run cypress (staging)
if: inputs.environment == 'staging'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',grep='-dao',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
uses: cypress-io/github-action@v6
env:
db: ${{ secrets.DB_CONNECTION_STRING }}
url: ${{ secrets.AZURE_ENDPOINT }}
cypressTestSecret: ${{ secrets.CYPRESS_TEST_SECRET }}
academisationApiUrl: ${{secrets.CYPRESS_ACADEMISATION_API_URL}}
academisationApiKey: ${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}
grep: '-dao'
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Upload screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: screenshots-dev
name: screenshots-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots

- name: Generate report
Expand All @@ -82,7 +110,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: reports-dev
name: reports-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/mochareports

- name: Report results
Expand Down

0 comments on commit 5c5db89

Please sign in to comment.