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

Optimised to use Cypress base actions #1246

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
58 changes: 40 additions & 18 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,49 @@ jobs:
with:
ref: ${{ github.ref }}

- name: Setup node.js
uses: actions/setup-node@v4
- name: Prepare Cypress cache
uses: cypress-io/github-action@v6
with:
node-version: ${{ env.NODE_VERSION }}

- name: Npm install
run: npm install
runTests: false
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests

- name: Run cypress (dev)
- name: 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 }}
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}}
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

- name: Run cypress (staging)
- name: Run (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 }}
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: '-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 +104,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
Loading