Skip to content
Draft
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
76 changes: 76 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Lighthouse CI

on:
push:
branches:
- main
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Branch name mismatch: workflow triggers on main but PR target is master.

The workflow is configured to run on the main branch, but the PR indicates the target branch is master. 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- main
- master
🤖 Prompt for AI Agents
In .github/workflows/lighthouse.yml around line 6 the workflow is set to trigger
on branch "main" while the PR target (and repository default) is "master";
update the workflow trigger to the correct branch name (replace "main" with
"master" or adjust to the repository's actual default branch), verify any other
branch names in the file match the repo, and commit the change so the workflow
will run on the intended target branch.

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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/coverage
/demo/dist
/demo/build
.lighthouseci

npm-debug.log*

Expand All @@ -13,4 +14,4 @@ npm-debug.log*
/dist
*.tgz
/attw*
.npm-cache
.npm-cache
5 changes: 3 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-mentions-ts demo</title>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
<script>
tailwind.config = {
window.tailwind = window.tailwind || {}
window.tailwind.config = {
theme: {
extend: {
colors: {
Expand All @@ -22,6 +22,7 @@
},
}
</script>
<script defer src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
</head>
<body>
<div id="root"></div>
Expand Down
24 changes: 24 additions & 0 deletions lighthouserc.cjs
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',
},
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The specified version 0.15.x for @lhci/cli does not exist on npm, which will cause this script to fail. The latest version is 0.13.0.

For better dependency management, I recommend adding @lhci/cli to your devDependencies (yarn add -D @lhci/cli@^0.13.0). This will ensure version consistency across all environments.

Suggested change
"lighthouse": "yarn build:demo && npx @lhci/cli@0.15.x autorun",
"lighthouse": "yarn build:demo && npx @lhci/cli@^0.13.0 autorun",

"typecheck": "tsc --project tsconfig.json --noEmit",
"format": "prettier --write \"{src,test,demo/src}/**/*.{ts,tsx}\"",
"lint": "eslint src",
Expand Down
Loading