f5dec95a83
refactor: 重构页面导航和滚动逻辑,提升用户体验 test: 更新测试配置和用例,增加覆盖率和稳定性 perf: 优化性能指标和阈值,适应开发环境需求 ci: 添加Lighthouse CI工作流,集成性能测试 docs: 更新API文档和健康检查端点 fix: 修复登录页面和表单提交问题 style: 调整响应式布局和可访问性改进 chore: 更新依赖项和脚本配置
74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
name: Lighthouse CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
lighthouse:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build application
|
|
run: npm run build
|
|
|
|
- name: Run Lighthouse CI
|
|
run: npm run lighthouse
|
|
env:
|
|
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
|
|
|
|
- name: Upload Lighthouse results
|
|
uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: lighthouse-results
|
|
path: lighthouse-reports
|
|
|
|
- name: Comment PR with results
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// 读取结果
|
|
const resultsPath = path.join(process.cwd(), 'lighthouse-reports', 'manifest.json');
|
|
if (fs.existsSync(resultsPath)) {
|
|
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf-8'));
|
|
|
|
// 生成评论
|
|
const comment = `## 📊 Lighthouse CI Results
|
|
|
|
${results.map(r => `
|
|
### ${r.url}
|
|
- **Performance**: ${(r.summary.performance * 100).toFixed(0)}/100
|
|
- **Accessibility**: ${(r.summary.accessibility * 100).toFixed(0)}/100
|
|
- **Best Practices**: ${(r.summary['best-practices'] * 100).toFixed(0)}/100
|
|
- **SEO**: ${(r.summary.seo * 100).toFixed(0)}/100
|
|
`).join('\n')}
|
|
|
|
[View Full Report](${results[0].url})`;
|
|
|
|
// 发布评论
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: comment
|
|
});
|
|
}
|