Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane committed Jul 5, 2024
1 parent 101b990 commit fb00366
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,14 @@ jobs:
archive: false
pr_comment: true
- uses: actions/github-script@v7
if: false
with:
script: |
const expectedComment = `The latest Buf updates on your PR.
<table><tr><th>Name</th><th>Status</th></tr><tr><td>build</td><td>✅ passed</td></tr><tr><td>lint</td><td>⏩ skipped</td></tr><tr><td>format</td><td>❌ failed</td></tr><tr><td>breaking</td><td>✅ passed</td></tr></table>
<!-- Buf results -->`
const expects = [
"The latest Buf updates on your PR.",
"✅ passed",
"❌ failed (1)",
"⏩ skipped",
];
const commentTag = "<!-- Buf results -->";
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request?.number;
Expand All @@ -186,11 +187,11 @@ jobs:
core.setFailed('Missing comment on pull request.');
return;
}
if (!previousComment.body?.includes(expectedComment)) {
core.setFailed('Comment does not match expected.');
core.info(`Expected: ${expectedComment}`);
core.info(`Comment: ${previousComment.body}`);
return;
for (const line of expects) {
if (!previousComment.body?.includes(line)) {
core.setFailed(`Comment does not include expected line: ${line}`);
return;
}
}
await github.rest.issues.updateComment({
owner: owner,
Expand Down
15 changes: 6 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45835,18 +45835,15 @@ function createSummary(inputs, steps, moduleNames) {
}),
],
];
console.log("moduleNames", moduleNames);
// If push or archive is enabled add a link to the registry.
//if (inputs.push) table.push(["push", message(steps.push?.status)]);
//if (inputs.archive) table.push(["archive", message(steps.archive?.status)]);
let output = core.summary.addTable(table);
if (inputs.push && moduleNames.length > 0) {
const modules = moduleNames.map((moduleName) => `<a href="https://${moduleName.name}">${moduleName.name}</a>`);
output = output.addRaw(`Pushed ${modules.join(", ")} to registry.`, true);
output = output.addRaw(`Pushed to ${modules.join(", ")}.`, true);
}
if (inputs.archive && moduleNames.length > 0) {
const modules = moduleNames.map((moduleName) => `<a href="https://${moduleName.name}">${moduleName.name}</a>`);
output = output.addRaw(`Archived ${modules.join(", ")} with ${inputs.archive_labels.join(", ")} labels.`, true);
output = output.addRaw(`Archived labels ${inputs.archive_labels.join(", ")} to ${modules.join(", ")}.`, true);
}
return output;
}
Expand Down Expand Up @@ -46111,13 +46108,13 @@ function pass() {
function message(result) {
switch (result?.status) {
case Status.Passed:
return "✅ passed";
return "<code>✅ passed</code>";
case Status.Failed:
return `❌ failed (${result.stdout.split("\n").length - 1})`;
return `<code>❌ failed (${result.stdout.split("\n").length - 1})</code>`;
case Status.Skipped:
return "⏩ skipped";
return "<code>⏩ skipped</code>";
default:
return "🚫 cancelled";
return "<code>🚫 cancelled</code>";
}
}

Expand Down
15 changes: 6 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,22 @@ function createSummary(
}),
],
];
console.log("moduleNames", moduleNames);
// If push or archive is enabled add a link to the registry.
//if (inputs.push) table.push(["push", message(steps.push?.status)]);
//if (inputs.archive) table.push(["archive", message(steps.archive?.status)]);
let output = core.summary.addTable(table);
if (inputs.push && moduleNames.length > 0) {
const modules = moduleNames.map(
(moduleName) =>
`<a href="https://${moduleName.name}">${moduleName.name}</a>`,
);
output = output.addRaw(`Pushed ${modules.join(", ")} to registry.`, true);
output = output.addRaw(`Pushed to ${modules.join(", ")}.`, true);
}
if (inputs.archive && moduleNames.length > 0) {
const modules = moduleNames.map(
(moduleName) =>
`<a href="https://${moduleName.name}">${moduleName.name}</a>`,
);
output = output.addRaw(
`Archived ${modules.join(", ")} with ${inputs.archive_labels.join(", ")} labels.`,
`Archived labels ${inputs.archive_labels.join(", ")} to ${modules.join(", ")}.`,
true,
);
}
Expand Down Expand Up @@ -438,12 +435,12 @@ function pass(): Result {
function message(result: Result | undefined): string {
switch (result?.status) {
case Status.Passed:
return "✅ passed";
return "<code>✅ passed</code>";
case Status.Failed:
return `❌ failed (${result.stdout.split("\n").length - 1})`;
return `<code>❌ failed (${result.stdout.split("\n").length - 1})</code>`;
case Status.Skipped:
return "⏩ skipped";
return "<code>⏩ skipped</code>";
default:
return "🚫 cancelled";
return "<code>🚫 cancelled</code>";
}
}

0 comments on commit fb00366

Please sign in to comment.