Skip to content

Commit

Permalink
fix: Make check runs work again
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Sep 10, 2024
1 parent 2b52642 commit 5c2409c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
build:
name: "Build"
runs-on: ubuntu-latest
permissions:
checks: write
outputs:
name: ${{ steps.web-ext-build.outputs.name }}
steps:
Expand Down Expand Up @@ -61,7 +63,8 @@ jobs:
runs-on: ubuntu-latest
needs: build
env:
HAS_SIGN_KEY: ${{ secrets.AMO_SIGN_KEY != '' && secrets.AMO_SIGN_SECRET != '' }}
#HAS_SIGN_KEY: ${{ secrets.AMO_SIGN_KEY != '' && secrets.AMO_SIGN_SECRET != '' }}

Check warning on line 66 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Build

66:8 [comments] missing starting space in comment
HAS_SIGN_KEY:
steps:
- name: "Checkout"
if: env.HAS_SIGN_KEY
Expand Down Expand Up @@ -115,8 +118,8 @@ jobs:
name: "Self-test: ATN release"
runs-on: ubuntu-latest
needs: build
env:
HAS_SIGN_KEY: ${{ secrets.ATN_SIGN_KEY != '' && secrets.ATN_SIGN_SECRET != '' }}
#env:

Check warning on line 121 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Build

121:6 [comments] missing starting space in comment
#HAS_SIGN_KEY: ${{ secrets.ATN_SIGN_KEY != '' && secrets.ATN_SIGN_SECRET != '' }}

Check warning on line 122 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Build

122:6 [comments] missing starting space in comment
steps:
- name: "Checkout"
if: env.HAS_SIGN_KEY
Expand Down
22 changes: 12 additions & 10 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ export default class WebExtAction {
shouldExitProgram: false
});

let nonfatal = results.notices.concat(results.warnings).map(linterToAnnotation);
let fatal = results.errors.map(linterToAnnotation);
let summary = results.summary;
let summaryLine = `${summary.errors} Errors, ${summary.warnings} Warnings, ${summary.notices} Notices`;

await check.complete(summaryLine, nonfatal, fatal);

if (!check.ready) {
if (check.ready) {
await check.complete(
results.errors.map(linterToAnnotation),
results.warnings.map(linterToAnnotation),
results.notices.map(linterToAnnotation)
);
} else {
console.log(results.notices.concat(results.warnings).concat(results.errors).map(linterToString).join("\n") + "\n");
}
console.log(summaryLine);

if (fatal.length) {
let summary = results.summary;
let summaryLine = `${summary.errors} Errors, ${summary.warnings} Warnings, ${summary.notices} Notices`;
if (results.errors.length) {
throw new Error(summaryLine);
} else {
console.log(summaryLine);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/checkrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export default class CheckRun {
}
}

async complete(errorCount, warningCount, annotations) {
async complete(errors, warnings, notices) {
if (!this.ready) {
return;
}

let conclusion = "success";
if (errorCount > 0) {
if (errors.length > 0) {
conclusion = "failure";
} else if (warningCount > 0) {
} else if (warnings.length > 0) {
conclusion = "neutral";
}

Expand All @@ -60,15 +60,15 @@ export default class CheckRun {
conclusion: conclusion,
output: {
title: this.name,
summary: `${errorCount} errors, ${warningCount} warnings`,
annotations: annotations,
summary: `${errors.length} errors, ${warnings.length} warnings, ${notices.length} notices`,
annotations: errors.concat(warnings).concat(notices)
},
};

try {
await this.octokit.rest.checks.update(data);
} catch (e) {
console.log(JSON.stringify(data, null, 2));
console.error(JSON.stringify(data, null, 2));
throw e;
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/extension/borderify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
Just draw a border round the document.body.
*/
document.body.style.border = "5px solid red";


var varia = "foo";

document.innerHTML = varia;

0 comments on commit 5c2409c

Please sign in to comment.