Skip to content
Closed
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
36 changes: 18 additions & 18 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,46 @@ jobs:
- if: steps.should_run.outputs.shouldrun == 'true'
name: Lighthouse Audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826 #version 10.1 https://github.com/treosh/lighthouse-ci-action/releases/tag/10.1.0
uses: treosh/lighthouse-ci-action@v12
with:
urls: |
https://deploy-preview-$PR_NUMBER--asyncapi-website.netlify.app/
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
artifactName: lighthouse-results # Simplified artifact name to ensure validity
temporaryPublicStorage: true
env:
PR_NUMBER: ${{ github.event.pull_request.number}}
PR_NUMBER: ${{ github.event.pull_request.number }}

- if: steps.should_run.outputs.shouldrun == 'true'
name: Lighthouse Score Report
id: lighthouse_score_report
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_audit.outputs.links }}
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const result = JSON.parse(steps.lighthouse_audit.outputs.manifest).categories;
const links = JSON.parse(steps.lighthouse_audit.outputs.links);
const formatResult = (res) => Math.round(res * 100);
const score = (res) => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴';
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
`⚡️ [Lighthouse report](${links[0]}) for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
`| ${score(result.performance.score)} Performance | ${formatResult(result.performance.score)} |`,
`| ${score(result.accessibility.score)} Accessibility | ${formatResult(result.accessibility.score)} |`,
`| ${score(result['best-practices'].score)} Best practices | ${formatResult(result['best-practices'].score)} |`,
`| ${score(result.seo.score)} SEO | ${formatResult(result.seo.score)} |`,
`| ${score(result.pwa.score)} PWA | ${formatResult(result.pwa.score)} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
`*Lighthouse ran on [${links[0]}](${links[0]})*`
].join('\n');
core.setOutput("comment", comment);

- if: steps.should_run.outputs.shouldrun == 'true'
name: LightHouse Statistic Comment
id: lighthouse_statistic_comment
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # version 2.8 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.8.0
uses: marocchino/sticky-pull-request-comment@v3.0
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
number: ${{ github.event.pull_request.number }}
Expand Down
40 changes: 21 additions & 19 deletions .github/workflows/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{
"ci": {
"assert": {
"assertions": {
"categories:accessibility": ["error", {"minScore": 0.98}],
"categories:best-practices": ["error", {"minScore": 0.92}],
"categories:seo": ["error", {"minScore": 1.00}]
}
},
"collect": {
"settings": {
"skipAudits": [
"robots-txt",
"canonical",
"tap-targets",
"is-crawlable",
"works-offline",
"offline-start-url"
]
}
"ci": {
"assert": {
"assertions": {
"categories:accessibility": ["error", {"minScore": 0.95}],
"categories:best-practices": ["error", {"minScore": 0.90}],
"categories:seo": ["error", {"minScore": 0.95}],
"categories:performance": ["error", {"minScore": 0.85}]
}
},
"collect": {
"settings": {
"skipAudits": [
"robots-txt",
"canonical",
"tap-targets",
"is-crawlable",
"works-offline",
"offline-start-url",
"uses-http2"
]
}
}
}
}
Loading