-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (164 loc) · 6.21 KB
/
regressionStaging.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: "| Staging | Regression Pack |"
on:
schedule:
- cron: "00 00 * * *"
workflow_dispatch:
jobs:
cypress-run:
environment: trade-tariff
env:
CYPRESS_BASE_URL: "https://staging.trade-tariff.service.gov.uk"
CYPRESS_ADMIN_OTP_SECRET: ${{ secrets.ADMIN_OTP_SECRET }}
CYPRESS_ADMIN_PASSWORD: ${{ secrets.CYPRESS_ADMIN_PASSWORD }}
CYPRESS_ADMIN_USERNAME: ${{ secrets.CYPRESS_ADMIN_USERNAME }}
CYPRESS_STAGING_ADMIN_SUFFIX: "staging"
CYPRESS_SPACE: "STAGING"
CYPRESS_STAGING_BASIC_AUTH: ${{ secrets.CYPRESS_STAGING_BASIC_AUTH }}
CYPRESS_STAGING_BASIC_PASSWORD: ${{ secrets.CYPRESS_STAGING_BASIC_PASSWORD }}
CYPRESS_STAGING_BASIC_USERNAME: ${{ secrets.CYPRESS_STAGING_BASIC_USERNAME }}
CYPRESS_grepTags: "-smokeTest+-notStaging"
name: "RegressionTests - Staging"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
containers: [0, 1, 2, 3]
outputs:
output0: ${{ steps.cypress-outcome.outputs.test-status-0 }}
output1: ${{ steps.cypress-outcome.outputs.test-status-1 }}
output2: ${{ steps.cypress-outcome.outputs.test-status-2 }}
output3: ${{ steps.cypress-outcome.outputs.test-status-3 }}
steps:
- run: date
- name: Checkout repository code
uses: actions/checkout@v4
- name: Generate lists of specs
id: speclist
run: |
find cypress/e2e -type f -name '*.cy.js' > all_specs.txt
split -n l/4 -d -a 1 all_specs.txt spec_group_
echo "specfiles=$(paste -d, -s spec_group_${{ matrix.containers }})" >> $GITHUB_OUTPUT
- name: Run cypress tests with chrome
id: cypress
uses: cypress-io/github-action@v6
continue-on-error: true
with:
spec: ${{ steps.speclist.outputs.specfiles }}
quiet: true
browser: chrome
- name: Cypress test outcome
id: cypress-outcome
run: |
echo "test-status-${{ matrix.containers }}=${{ steps.cypress.outcome }}" >> $GITHUB_OUTPUT
- name: Upload E2E test reports
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.containers }}
path: ./cypress/reports/
gen-report:
name: Generate test report
needs: cypress-run
if: always()
runs-on: ubuntu-22.04
outputs:
date-output: ${{ steps.date.outputs.date }}
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%d-%m-%Y')" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm install --save-dev mochawesome mochawesome-merge mochawesome-report-generator
- name: Create reports directory
run: mkdir reports
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: test-reports-0
path: reports/0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: test-reports-1
path: reports/1
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: test-reports-2
path: reports/2
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: test-reports-3
path: reports/3
- name: Move reports to mochawesome-report directory
run: |
mkdir -p mochawesome-report
for container in {0..3}; do
download_path=reports/$container
for file in $(find $download_path -type f -name 'mochawesome*.json'); do
mv "$file" mochawesome-report/$(basename "$file" .json)-"$container".json
done
done
- name: Merge and generate reports
run: |
mkdir report
npx mochawesome-merge mochawesome-report/*.json > report/index.json
npx marge --inline report/index.json -o report/
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: E2E Test Reports
path: report/
- name: Checkout reports repo
uses: actions/checkout@v4
with:
ref: reports
path: reports_repo
- name: Copy report into reports repo
run: |
cd reports_repo
DATE=$(date +%d-%m-%Y)
[ -e docs/staging/$DATE ] && rm -rf docs/staging/$DATE
cp -a ../report/ docs/staging/$DATE
pushd docs/staging/$DATE
rm -rf assets
rm -rf screenshots
ln -s ../../assets/
popd
git add docs .
- name: Commit todays report to reports branch
run: |
cd reports_repo
git config --local user.email "tradetarrif+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Staging report for $(date +%d-%m-%Y)" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: reports
directory: reports_repo
notify-slack:
name: Send slack notification based on test results
needs: [cypress-run, gen-report]
if: always()
runs-on: ubuntu-22.04
steps:
- name: Determine test outcome
id: determine-outcome
run: |
if [[ "${{ needs.cypress-run.outputs.output0 }}" == "success" && "${{ needs.cypress-run.outputs.output1 }}" == "success" && "${{ needs.cypress-run.outputs.output2 }}" == "success" && "${{ needs.cypress-run.outputs.output3 }}" == "success" ]]; then
echo "result=success" >> $GITHUB_OUTPUT
else
echo "result=failure" >> $GITHUB_OUTPUT
fi
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: "tariffs-regression"
SLACK_USERNAME: "Staging Regression"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON_EMOJI: ":alphabet-yellow-s:"
SLACK_COLOR: ${{ steps.determine-outcome.outputs.result }}
SLACK_TITLE: Cypress finished with - ${{ steps.determine-outcome.outputs.result }}
SLACK_MESSAGE: https://trade-tariff.github.io/trade-tariff-testing/staging/${{ needs.gen-report.outputs.date-output }}/