Skip to content

Commit

Permalink
devops: debug lhci results comment (#78)
Browse files Browse the repository at this point in the history
* devops: debug github actions

* devops: debug lhci results comment
  • Loading branch information
gaboesquivel authored Apr 6, 2024
1 parent 876c1ee commit 99da3ed
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,29 @@ jobs:
const manifest = ${{ toJSON(steps.lighthouse_audit.outputs.manifest) }};
const links = ${{ toJSON(steps.lighthouse_audit.outputs.links) }};
if (!manifest || Object.keys(manifest).length === 0) {
core.setFailed('Lighthouse audit did not generate any results.');
return;
}
# if (!manifest || Object.keys(manifest).length === 0) {
# core.setFailed('Lighthouse audit did not generate any results.');
# return;
# }
const formatResult = (res) => Math.round((res * 100));
const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴');
# const formatResult = (res) => Math.round((res * 100));
# const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴');
let comment = '';
# let comment = '';
Object.keys(manifest).forEach((page) => {
const pageLink = manifest[page].url;
comment += `*Lighthouse ran on [${pageLink}](${pageLink})*\n\n`;
comment += '| Category | Score |\n';
comment += '| --- | --- |\n';
const result = manifest[page].summary;
Object.keys(result).forEach((key) => {
const formattedScore = formatResult(result[key]);
comment += `| ${score(result[key])} ${key} | ${formattedScore} |\n`;
});
});
# Object.keys(manifest).forEach((page) => {
# const pageLink = manifest[page].url;
# comment += `*Lighthouse ran on [${pageLink}](${pageLink})*\n\n`;
# comment += '| Category | Score |\n';
# comment += '| --- | --- |\n';
# const result = manifest[page].summary;
# Object.keys(result).forEach((key) => {
# const formattedScore = formatResult(result[key]);
# comment += `| ${score(result[key])} ${key} | ${formattedScore} |\n`;
# });
# });
core.setOutput('comment', comment);
core.setOutput('comment', steps.lighthouse_audit.outputs.links);
- name: Add comment to PR
id: comment_to_pr
uses: marocchino/[email protected]
Expand Down

0 comments on commit 99da3ed

Please sign in to comment.