-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lighthouse CI + light SEO/accessiblity tweaks (#85)
* split out path and pass to lighthouse * specific path * url with paths * fix ci * lots of seo and accessibility improvements * add lighthouse scores as comment * cleanup * try this commenting system? * another test * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system? * try this commenting system?
- Loading branch information
1 parent
2c9d316
commit 5038b74
Showing
16 changed files
with
122 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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,12 @@ | ||
const paths = require('../../build/paths'); | ||
|
||
const baseUrl = 'http://127.0.0.1:8080' | ||
|
||
module.exports = { | ||
ci: { | ||
collect: { | ||
url: paths.map((path) => baseUrl + path), | ||
startServerCommand: 'npx http-server dist -p 8080', | ||
}, | ||
}, | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
name: Lighthouse CI | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
|
@@ -22,4 +25,37 @@ jobs: | |
run: npm run prd-build | ||
|
||
- name: Run Lighthouse | ||
run: npm install -g @lhci/[email protected] && lhci autorun --upload.target=temporary-public-storage | ||
run: npm install -g @lhci/[email protected] && lhci autorun --upload.target=temporary-public-storage --config=.github/workflows/.lighthouserc.js | ||
|
||
- name: Comment Lighthouse Scores | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const body = require('./.github/workflows/lighthousescores.js') | ||
const prNumber = context.payload.pull_request.number; | ||
const comments = await github.rest.issues.listComments({ | ||
owner: "kushagharahi", | ||
repo: "kushagharahi.github.io", | ||
issue_number: prNumber, | ||
}); | ||
const existingComment = comments.data.find(comment => comment.body.includes('## Lighthouse Scores')) | ||
if (existingComment) { | ||
await github.rest.issues.updateComment({ | ||
owner: "kushagharahi", | ||
repo: "kushagharahi.github.io", | ||
comment_id: existingComment.id, | ||
issue_number: prNumber, | ||
body: body, | ||
}); | ||
} else { | ||
await github.rest.issues.createComment({ | ||
owner: "kushagharahi", | ||
repo: "kushagharahi.github.io", | ||
issue_number: prNumber, | ||
body: body, | ||
}); | ||
} |
This file contains 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,19 @@ | ||
const fs = require('fs'); | ||
|
||
const reportFiles = fs.readdirSync('./.lighthouseci', { withFileTypes: true }) | ||
.filter(dirent => dirent.isFile() && dirent.name.startsWith('lhr') && !dirent.name.endsWith('.html')) | ||
.map(dirent => dirent.name); | ||
|
||
let comment = '## Lighthouse Scores\n\n'; | ||
for (const reportFile of reportFiles) { | ||
const reportContent = fs.readFileSync('./.lighthouseci/'+reportFile, 'utf8'); | ||
const report = JSON.parse(reportContent); | ||
var scores = new Map(); | ||
Object.keys(report.categories).forEach((title) => { | ||
scores[title] = report.categories[title].score * 100; | ||
}); | ||
const scoreTable = Object.entries(scores).map(([category, score]) => `- ${category}: ${score}`).join('\n'); | ||
comment += `- ${report.requestedUrl}\n\`\`\`\n${scoreTable}\n\`\`\`\n`; | ||
} | ||
|
||
module.exports = comment |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
npm-debug.log | ||
dist | ||
*.DS_Store* | ||
*.DS_Store* | ||
.lighthouseci |
This file contains 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,13 @@ | ||
module.exports = [ | ||
'/', | ||
'/blog', | ||
'/resume', | ||
'/contact', | ||
'/projects', | ||
'/blog/first_blog_post', | ||
'/blog/access_localhost_from_vm_in_host_computer', | ||
'/blog/git_command_line_cheat_sheet', | ||
'/blog/asrock_z77_extreme4_gtx_970_high_sierra_hackintosh', | ||
'/blog/managing_sfdx_static_resources_via_npm_or_yarn', | ||
'/blog/reset_the_root_password_raspbian_image' | ||
] |
This file contains 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 |
---|---|---|
|
@@ -13,5 +13,5 @@ module.exports = merge(common, { | |
// Drop Options API from bundle | ||
__VUE_PROD_DEVTOOLS__: false | ||
}), | ||
] | ||
] | ||
}); |
This file contains 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 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 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 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 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 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 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 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 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 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