Skip to content

Commit

Permalink
Combine reports into single artifact (cypress workflow)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Dec 20, 2024
1 parent 5b50cd1 commit b22e6fa
Showing 1 changed file with 54 additions and 57 deletions.
111 changes: 54 additions & 57 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,100 +39,97 @@ jobs:
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 }}

# Step 1: Install Cypress for Transfers Tests
- name: Install Cypress for Transfers
run: npm install cypress
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests
- run: |
INPUT=${{ github.event.inputs.environment }}
ENVIRONMENT=${INPUT:-"development"}
if [[ $ENVIRONMENT == 'development' ]]
then
echo "GREP=-dao" >> $GITHUB_ENV
else
echo "GREP=" >> $GITHUB_ENV
fi
- name: Run Transfers Tests (${{ inputs.environment }})
if: inputs.environment == 'staging' || inputs.environment == 'dev'
- 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: edge
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests
browser: ${{ matrix.browser }}
working-directory: ${{ matrix.working_dir }}
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false

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

# Step 2: Install Cypress for Conversions Tests
- name: Install Cypress for Conversions
run: npm install cypress
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
- 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

- name: Run Conversions (dev)
if: inputs.environment == 'dev'
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 }}
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:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false
ref: ${{ github.ref }}

- name: Run Conversions (staging)
if: inputs.environment == 'staging'
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: '-dao'
- uses: actions/setup-node@v4
with:
browser: ${{ matrix.browser }}
working-directory: ./Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
wait-on: ${{ secrets.AZURE_ENDPOINT }}
install: false
node-version: 20

- name: Upload screenshots (Conversions)
if: ${{ failure() }}
uses: actions/upload-artifact@v4
- run: npm ci
working-directory: ${{ env.working_dir }}

- name: Download reports
uses: actions/download-artifact@v4
with:
name: screenshots-conversions-${{ inputs.environment }}-${{ matrix.browser }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots
pattern: reports-${{ inputs.environment }}-*
path: ${{ env.working_dir }}/reports
merge-multiple: true

# Step 3: Generate Combined Report
- name: Generate combined report
if: always()
working-directory: ${{ env.working_dir }}
run: |
mkdir mochareports
npm run generate:html:report --prefix Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests
npm run generate:html:report --prefix Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests
mv Dfe.PrepareConversions/Dfe.PrepareTransfers.CypressTests/mochareports/*.html mochareports/
mv Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/mochareports/*.html mochareports/
echo "Combined reports generated"
npx mochawesome-merge mochareports/*.html > mochareports/combined-reports-${{ inputs.environment }}-${{ matrix.browser }}.html
npm run generate:html:report
- name: Upload combined report
if: always()
uses: actions/upload-artifact@v4
with:
name: combined-reports-${{ inputs.environment }}-${{ matrix.browser }}
name: combined-reports-${{ inputs.environment }}
path: mochareports

- name: Report results to Slack
Expand Down

0 comments on commit b22e6fa

Please sign in to comment.