-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (125 loc) · 4.14 KB
/
cypress.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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 }}