-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add lighthouse test to CI #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ECWireless
wants to merge
11
commits into
main
Choose a base branch
from
339-slow-livepeer-home-page-without-cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,780
−17
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7f78e30
feat: add lighthouse test to CI
ECWireless 9671795
feat: try testing Vercel preview deployment
ECWireless 30fa595
fix: checkout lighthouse config in CI
ECWireless 06ae2e5
feat: make heavy homepage components dynamic
ECWireless c91e6f3
fix: revert making heavy home components dynamic
ECWireless 81d3c25
feat: collect the voting and treasury page
ECWireless 60aec03
feat: render OrchestratorList after layout paints
ECWireless 65bf63f
feat: add additional pages to Lighthouse CI
ECWireless d998945
feat: add baseline metrics to .lighthouserc.json
ECWireless 824013e
chore: reduce TBT threshold in Lighthouse config
ECWireless e65c8bd
chore: reduce TBT threshold further
ECWireless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| name: Lighthouse (Vercel Preview URL) | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| deployments: read | ||
|
|
||
| jobs: | ||
| lhci-preview: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 | ||
|
|
||
| steps: | ||
| - name: ⬇️ Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: 🟢 Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: 🔎 Wait for Vercel Deployment + grab Preview URL | ||
| id: vercel | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const sha = context.payload.pull_request.head.sha; | ||
| const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); | ||
| for (let i = 0; i < 40; i++) { | ||
| const { data: deployments } = await github.rest.repos.listDeployments({ | ||
| owner, repo, sha, per_page: 20, | ||
| }); | ||
| const previewDeployments = deployments.filter(d => | ||
| String(d.environment || "").toLowerCase().includes("preview") | ||
| ); | ||
| const candidates = (previewDeployments.length ? previewDeployments : deployments) | ||
| .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | ||
| if (candidates.length) { | ||
| const dep = candidates[0]; | ||
| const { data: statuses } = await github.rest.repos.listDeploymentStatuses({ | ||
| owner, repo, deployment_id: dep.id, per_page: 20, | ||
| }); | ||
| const success = statuses.find(s => s.state === "success" && s.target_url); | ||
| if (success?.target_url) { | ||
| core.setOutput("preview_url", success.target_url); | ||
| core.info(`Found preview URL: ${success.target_url}`); | ||
| return; | ||
| } | ||
| const failure = statuses.find(s => (s.state === "error" || s.state === "failure")); | ||
| if (failure) throw new Error(`Deployment failed: ${failure.description || failure.state}`); | ||
| } | ||
| core.info(`Waiting for Vercel preview deployment... (${i + 1}/40)`); | ||
| await sleep(15000); | ||
| } | ||
| throw new Error("Timed out waiting for Vercel preview deployment URL."); | ||
| - name: 📦 Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9.15.9 | ||
| run_install: false | ||
|
|
||
| - name: 🔎 Run Lighthouse CI against Vercel Preview | ||
| env: | ||
| PREVIEW_URL: ${{ steps.vercel.outputs.preview_url }} | ||
| run: | | ||
| echo "Running Lighthouse CI on: $PREVIEW_URL" | ||
| pnpm dlx @lhci/cli collect --config=./.lighthouserc.json \ | ||
| --url="$PREVIEW_URL/" \ | ||
| --url="$PREVIEW_URL/orchestrators" \ | ||
| --url="$PREVIEW_URL/leaderboard" \ | ||
| --url="$PREVIEW_URL/transactions" \ | ||
| --url="$PREVIEW_URL/voting" \ | ||
| --url="$PREVIEW_URL/treasury" | ||
| pnpm dlx @lhci/cli assert --config=./.lighthouserc.json | ||
| pnpm dlx @lhci/cli upload --config=./.lighthouserc.json --target=temporary-public-storage | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "ci": { | ||
| "collect": { | ||
| "numberOfRuns": 2, | ||
| "settings": { "preset": "desktop", "formFactor": "desktop" } | ||
| }, | ||
| "assert": { | ||
| "assertions": { | ||
| "categories:performance": ["error", { "minScore": 0.6 }], | ||
| "largest-contentful-paint": ["error", { "maxNumericValue": 3400 }], | ||
| "cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }], | ||
| "total-blocking-time": ["error", { "maxNumericValue": 425 }] | ||
| }, | ||
| "baselinePerformanceMetrics": { | ||
| "description": "Baseline Lighthouse metrics used to derive the assertion thresholds above. Update these values when the application's performance characteristics change.", | ||
| "largest-contentful-paint-ms": 3400, | ||
| "cumulative-layout-shift": 0.1, | ||
| "total-blocking-time-ms": 425, | ||
| "performance-score": 0.6 | ||
| } | ||
| }, | ||
| "upload": { "target": "temporary-public-storage" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.