-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (186 loc) · 6.65 KB
/
browser-quality-advisory.yml
File metadata and controls
213 lines (186 loc) · 6.65 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Browser Quality Advisory
on:
pull_request:
push:
branches: ["main"]
schedule:
- cron: "0 9 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: browser-quality-advisory-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_VERSION: "8.0.x"
NODE_VERSION: "22"
LIGHTHOUSE_BASE_URL: "http://127.0.0.1:5073"
jobs:
advisory:
name: A11y + Lighthouse (Advisory)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: tests/browser/package-lock.json
- name: Install advisory dependencies
run: npm --prefix tests/browser ci
- name: Install Playwright runtime (chromium + webkit)
run: npx --prefix tests/browser playwright install --with-deps chromium webkit
- name: Run advisory accessibility lane
continue-on-error: true
run: |
npx --prefix tests/browser playwright test \
--config tests/browser/playwright.config.js \
--project chromium \
--project mobile-safari \
--grep "@advisory"
- name: Start app for Lighthouse
env:
ASPNETCORE_ENVIRONMENT: Development
DatabaseProvider: Sqlite
ConnectionStrings__DefaultConnection: Data Source=${{ github.workspace }}/tests/browser/.tmp/leadportal-lighthouse.db
SeedAdmin__Email: admin@dirxhealth.com
SeedAdmin__Password: Admin@123
LocalStorage__RootPath: ${{ github.workspace }}/tests/browser/.tmp/uploads
SEED_DEMO_DATA: true
shell: bash
run: |
set -euo pipefail
mkdir -p tests/browser/.tmp/uploads tests/browser/lighthouse tests/browser/test-results
dotnet run \
--project LeadManagementPortal/LeadManagementPortal.csproj \
--urls "${LIGHTHOUSE_BASE_URL}" \
> tests/browser/test-results/lighthouse-app.log 2>&1 &
echo $! > tests/browser/.tmp/lighthouse.pid
- name: Wait for app readiness
shell: bash
run: |
set -euo pipefail
for i in {1..60}; do
if curl -fsS "${LIGHTHOUSE_BASE_URL}/Account/Login" > /dev/null; then
exit 0
fi
sleep 2
done
echo "Application did not become ready in time."
exit 1
- name: Run Lighthouse audits
continue-on-error: true
shell: bash
run: |
set -euo pipefail
routes=(
"/"
"/Account/Login"
"/Account/AccessDenied"
)
for route in "${routes[@]}"; do
slug="$(echo "$route" | sed 's#^/##; s#[^a-zA-Z0-9]#-#g')"
if [ -z "$slug" ]; then
slug="home"
fi
npx --prefix tests/browser lighthouse \
"${LIGHTHOUSE_BASE_URL}${route}" \
--chrome-flags="--headless --no-sandbox" \
--only-categories=performance,accessibility,best-practices,seo \
--output=html \
--output=json \
--output-path="tests/browser/lighthouse/${slug}"
done
- name: Stop Lighthouse app
if: always()
shell: bash
run: |
set +e
if [ -f tests/browser/.tmp/lighthouse.pid ]; then
kill "$(cat tests/browser/.tmp/lighthouse.pid)" 2>/dev/null || true
fi
- name: Upload advisory artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: browser-quality-advisory
path: |
tests/browser/playwright-report/
tests/browser/test-results/
tests/browser/lighthouse/
if-no-files-found: ignore
retention-days: 14
deployed-surface-smoke:
name: Deployed Surface Smoke (${{ matrix.browser }})
runs-on: ubuntu-latest
timeout-minutes: 30
continue-on-error: true
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve deploy URL
id: target
env:
SALESREPPORTAL_BASE_URL: ${{ vars.SALESREPPORTAL_BASE_URL }}
shell: bash
run: |
set -euo pipefail
if [ -z "${SALESREPPORTAL_BASE_URL:-}" ]; then
echo "should_probe=false" >> "$GITHUB_OUTPUT"
echo "url=" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "should_probe=true" >> "$GITHUB_OUTPUT"
echo "url=${SALESREPPORTAL_BASE_URL}" >> "$GITHUB_OUTPUT"
- name: Skip summary when deploy URL missing
if: steps.target.outputs.should_probe != 'true'
shell: bash
run: |
{
echo "### Deployed surface smoke skipped"
echo "- Missing repo variable: SALESREPPORTAL_BASE_URL"
echo "- Configure it with your canonical deployed portal URL to enable this advisory lane."
} >> "$GITHUB_STEP_SUMMARY"
- name: Setup Node
if: steps.target.outputs.should_probe == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: tests/browser/package-lock.json
- name: Install dependencies
if: steps.target.outputs.should_probe == 'true'
run: npm --prefix tests/browser ci
- name: Install Playwright browser runtime
if: steps.target.outputs.should_probe == 'true'
run: npx --prefix tests/browser playwright install --with-deps ${{ matrix.browser }}
- name: Probe deployed login surface
if: steps.target.outputs.should_probe == 'true'
env:
BROWSER: ${{ matrix.browser }}
SURFACE_NAME: deployed-login
SURFACE_URL: ${{ steps.target.outputs.url }}/Account/Login
REQUIRED_SELECTORS: body||form
MIN_BODY_TEXT_LENGTH: "80"
SCREENSHOT_DIR: tests/browser/playwright-report/surfaces
run: node scripts/ci/browser-surface-smoke.mjs
- name: Upload deployed surface artifacts
if: always() && steps.target.outputs.should_probe == 'true'
uses: actions/upload-artifact@v4
with:
name: deployed-surface-smoke-${{ matrix.browser }}
path: |
tests/browser/playwright-report/surfaces/
if-no-files-found: ignore
retention-days: 14