Skip to content

Commit 1d183a4

Browse files
authored
Merge pull request #246 from GSA/5701-automate-lighthouse
Light House Config (WIP)
2 parents 7c0815b + 5e10fe7 commit 1d183a4

3 files changed

Lines changed: 65 additions & 1 deletion

File tree

.github/workflows/commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ jobs:
133133
smoke-url: https://catalog-dev.data.gov/
134134
smoke-path: /
135135
basic_auth_user: ${{ secrets.BASIC_AUTH_USER }}
136-
basic_auth_password: ${{ secrets.BASIC_AUTH_PASSWORD }}
136+
basic_auth_password: ${{ secrets.BASIC_AUTH_PASSWORD }}

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,52 @@ jobs:
5858
smoke-url: https://catalog.data.gov/
5959
smoke-path: /
6060
# basic auth on prod is turned off
61+
62+
lighthouse:
63+
name: Lighthouse CI Audit
64+
needs: deploy-prod
65+
runs-on: ubuntu-latest
66+
continue-on-error: true
67+
steps:
68+
- name: Check out the code
69+
uses: actions/checkout@v4
70+
71+
- name: Set up Node.js
72+
uses: actions/setup-node@v4
73+
with:
74+
node-version: "20"
75+
76+
- name: Install Lighthouse CI
77+
run: npm install -g @lhci/cli
78+
79+
- name: Collect Lighthouse results
80+
run: |
81+
lhci collect \
82+
--url="https://catalog.data.gov" \
83+
--url="https://catalog.data.gov/organization" \
84+
--url="https://catalog.data.gov/organization/gsa" \
85+
--url="https://catalog.data.gov/dataset/gsa-enterprise-data-inventory-edi" \
86+
--numberOfRuns=1
87+
88+
- name: Upload to filesystem
89+
run: |
90+
lhci upload \
91+
--target=filesystem \
92+
--outputDir=./lighthouse-results
93+
94+
- name: Assert thresholds
95+
run: |
96+
output=$(lhci assert --config=lighthouserc.yml 2>&1) || {
97+
echo "$output" | while IFS= read -r line; do
98+
[[ -n "$line" ]] && echo "::error::$line"
99+
done
100+
exit 1
101+
}
102+
103+
- name: Upload Lighthouse results
104+
uses: actions/upload-artifact@v4
105+
if: always()
106+
with:
107+
name: lighthouse-results
108+
path: ./lighthouse-results/**/*.html
109+
retention-days: 7

lighthouserc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ci:
2+
assert:
3+
assertions:
4+
categories:performance:
5+
- error
6+
- minScore: 0.4
7+
categories:accessibility:
8+
- error
9+
- minScore: 0.75
10+
categories:best-practices:
11+
- error
12+
- minScore: 0.75
13+
categories:seo:
14+
- error
15+
- minScore: 0.75

0 commit comments

Comments
 (0)