Skip to content

Commit 235bf3f

Browse files
GeorgeSapkinAnsuel
authored andcommitted
formal: fix posting summaries to the PR
Don't post empty formality check summaries to the PR. Fix job URL. Clean-up formatting. Fixes: 1079ad9 ("formal: post summary to the PR") Signed-off-by: George Sapkin <george@sapk.in>
1 parent 6d06d51 commit 235bf3f

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

.github/scripts/process_formalities.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ const SUMMARY_HEADER=`
4141
<summary>Failed checks</summary>
4242
4343
Issues marked with an :x: are failing checks.
44-
`
44+
`;
4545

4646
const SUMMARY_FOOTER=`
4747
</details>
48-
`
48+
`;
4949

5050
async function hideOldSummaries({ github, owner, repo, issueNumber }) {
5151
const result = await github.graphql(GET_COMMENTS_QUERY, { owner, repo, issueNumber });
@@ -61,17 +61,19 @@ async function hideOldSummaries({ github, owner, repo, issueNumber }) {
6161
}
6262
}
6363

64-
function getJobUrl({ context, jobId }) {
65-
return `https://github.com/GeorgeSapkin/openwrt-packages/actions/runs/${context.runId}/job/${jobId}?pr=${context.issue.number}#${STEP_ANCHOR}`;
64+
function getJobUrl({ context, jobId }) {
65+
return `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${jobId}?pr=${context.issue.number}#${STEP_ANCHOR}`;
6666
}
6767

6868
function getSummaryMessage({ context, jobId, summary }) {
6969
return `
7070
${SUMMARY_HEADER}
71+
7172
${summary}
73+
7274
${SUMMARY_FOOTER}
7375
For more details, see the [full job log](${getJobUrl({ context, jobId })}).
74-
`
76+
`;
7577
}
7678

7779
async function processFormalities({ github, context, jobId, summary }) {
@@ -80,14 +82,19 @@ async function processFormalities({ github, context, jobId, summary }) {
8082

8183
await hideOldSummaries({ github, owner, repo, issueNumber });
8284

85+
summary = summary.trim();
86+
if (summary.length === 0) {
87+
return;
88+
}
89+
8390
console.log("Posting new summary comment");
8491
const body = getSummaryMessage({ context, jobId, summary });
8592
return github.rest.issues.createComment({
8693
issue_number: issueNumber,
8794
owner,
8895
repo,
8996
body,
90-
})
97+
});
9198
}
9299

93100
module.exports = processFormalities;

0 commit comments

Comments
 (0)