-
Notifications
You must be signed in to change notification settings - Fork 3
(wip) Add lighthouse CI #65
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
base: master
Are you sure you want to change the base?
Changes from all commits
d59d579
e74098f
8bd4820
1dce517
9d2e01e
bd395b9
0012e65
3cad113
22dea7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: Lighthouse CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| lighthouse: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22.x' | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Build library | ||
| run: yarn build | ||
|
|
||
| - name: Build demo | ||
| run: yarn build:demo --base=/react-mentions-ts/ | ||
|
|
||
| - name: Run Lighthouse CI | ||
| id: lighthouseci | ||
| run: | | ||
| set +e | ||
| DEBUG=lhci: npx @lhci/cli@0.15.x autorun | ||
| LHCI_EXIT_CODE=$? | ||
| ls -la .lighthouseci | ||
| set -e | ||
| ls -la | ||
| pwd | ||
|
|
||
| REPORTS_DIR=$(node -p "(() => { | ||
| const cfg = require('./lighthouserc.cjs') | ||
| const dir = (cfg && cfg.ci && cfg.ci.upload && cfg.ci.upload.outputDir) || 'lighthouse-reports' | ||
| return dir.startsWith('./') ? dir.slice(2) : dir | ||
| })()") | ||
|
|
||
| mkdir -p .lighthouseci | ||
| mkdir -p "$REPORTS_DIR" | ||
|
|
||
| if [ -f ".lighthouseci/manifest.json" ] && [ -z "$(ls -A "$REPORTS_DIR" 2>/dev/null)" ]; then | ||
| npx @lhci/cli@0.15.x upload --target=filesystem --outputDir="$REPORTS_DIR" || true | ||
| fi | ||
|
|
||
| echo "resultsPath=.lighthouseci" >> "$GITHUB_OUTPUT" | ||
| echo "reportsPath=$REPORTS_DIR" >> "$GITHUB_OUTPUT" | ||
|
|
||
| exit $LHCI_EXIT_CODE | ||
| env: | ||
| LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} | ||
|
|
||
| - name: Upload Lighthouse reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: lighthouse-reports | ||
| if-no-files-found: ignore | ||
| path: ${{ steps.lighthouseci.outputs.reportsPath }} | ||
|
|
||
| - name: Upload Lighthouse artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: lighthouse-artifacts | ||
| if-no-files-found: ignore | ||
| path: .lighthouseci | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** @type {import('@lhci/cli').LighthouseCiConfig} */ | ||
| module.exports = { | ||
| ci: { | ||
| collect: { | ||
| staticDistDir: 'demo/dist', | ||
| numberOfRuns: 2, | ||
| startServerReadyTimeout: 30_000, | ||
| settings: { | ||
| logLevel: 'verbose', | ||
| chromeFlags: '--enable-logging=stderr', | ||
| }, | ||
| }, | ||
| assert: { | ||
| preset: 'lighthouse:recommended', | ||
| assertions: { | ||
| 'categories:pwa': 'off', | ||
| }, | ||
| }, | ||
| upload: { | ||
| target: 'filesystem', | ||
| outputDir: './lighthouse-reports', | ||
| }, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |||||
| "clean": "rimraf dist", | ||||||
| "build": "yarn clean && tsup --config tsup.config.ts", | ||||||
| "build:demo": "vite build --config demo/vite.config.ts", | ||||||
| "lighthouse": "yarn build:demo && npx @lhci/cli@0.15.x autorun", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specified version For better dependency management, I recommend adding
Suggested change
|
||||||
| "typecheck": "tsc --project tsconfig.json --noEmit", | ||||||
| "format": "prettier --write \"{src,test,demo/src}/**/*.{ts,tsx}\"", | ||||||
| "lint": "eslint src", | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch name mismatch: workflow triggers on
mainbut PR target ismaster.The workflow is configured to run on the
mainbranch, but the PR indicates the target branch ismaster. This is a critical blocker—the workflow will not execute on the intended target branch. Verify the correct default branch name for the repository and update accordingly.Update the workflow trigger to match your target branch:
on: push: branches: - - main + - master pull_request:📝 Committable suggestion
🤖 Prompt for AI Agents