Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Lighthouse CI
on: [push, pull_request]

jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Build project
env:
NEXT_PUBLIC_GRAPHQL_URL: "https://swewoocommerce.dfweb.no/graphql"
NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL: "https://via.placeholder.com/200"
NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL: "https://via.placeholder.com/600"
run: pnpm build

- name: Start server
env:
NEXT_PUBLIC_GRAPHQL_URL: "https://swewoocommerce.dfweb.no/graphql"
NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL: "https://via.placeholder.com/200"
NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL: "https://via.placeholder.com/600"
run: |
pnpm start &
echo "Waiting for server to be ready..."
while ! nc -z localhost 3000; do
sleep 5
done
# Additional wait to ensure full initialization
sleep 20

- name: Run Lighthouse CI
run: |
pnpm lhci:perf
pnpm lhci:desktop
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Stop server
if: always()
run: |
pkill -f "next start" || true
32 changes: 32 additions & 0 deletions lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"ci": {
"collect": {
"numberOfRuns": 1,
"url": [
"http://localhost:3000/",
"http://localhost:3000/produkter",
"http://localhost:3000/kategorier"
],
"port": 3000,
"settings": {
"onlyCategories": [
"performance",
"accessibility",
"best-practices",
"seo"
],
"skipAudits": ["uses-http2"]
}
},
"upload": { "target": "temporary-public-storage" },
"assert": {
"assertions": {
"categories:performance": ["warn", { "minScore": 0.6 }],
"categories:accessibility": ["warn", { "minScore": 0.9 }],
"categories:best-practices": ["warn", { "minScore": 0.9 }],
"categories:seo": ["warn", { "minScore": 0.9 }],
"uses-http2": "off"
}
}
}
}
Loading
Loading