Skip to content

Commit de88756

Browse files
committed
fix log link
1 parent 714688c commit de88756

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

.github/workflows/validate-downstream.yml

+38-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
pull_request:
33

4-
name: Check pyQuil Compatibility
4+
name: Check pyQuil Compatibility
55

66
jobs:
77
check-pyquil:
@@ -62,15 +62,41 @@ jobs:
6262
const mypyFailed = '${{ steps.mypy.outcome }}' === 'failure';
6363
const ruffFailed = '${{ steps.ruff.outcome }}' === 'failure';
6464
const pytestFailed = '${{ steps.pytest.outcome }}' === 'failure';
65-
6665
const constructLogURL = (stepId) => {
67-
68-
return `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.id }}?pr=${{ context.issue.number }}`
66+
return `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ job.id }}?pr=${{ github.context.issue.number }}`
6967
};
7068
69+
// Fetch the existing comment with this identifier, if it exists
70+
const identifier = `pyQuil-checks-comment`;
71+
const comments = await github.rest.issues.listComments({
72+
owner,
73+
repo,
74+
issue_number,
75+
});
76+
const existingComment = comments.data.find(comment => comment.body.startsWith(`<!-- ${identifier} -->`);
77+
78+
const postOrUpdateComment = function (body) => {
79+
if (existingComment) {
80+
await github.rest.issues.updateComment({
81+
owner,
82+
repo,
83+
comment_id: existingComment.id,
84+
body
85+
});
86+
} else {
87+
await github.rest.issues.createComment({
88+
owner,
89+
repo,
90+
issue_number,
91+
body
92+
});
93+
}
94+
}
95+
96+
var body = ""
7197
7298
if (mypyFailed || ruffFailed || pytestFailed) {
73-
let body = `⚠️ **pyQuil Compatibility Checks Failed**:\n\n| Tool | Status |;
99+
let body += `⚠️ **pyQuil Compatibility Checks Failed**:\n\n| Tool | Status |;
74100
75101
if (mypyFailed) {
76102
body += `| mypy | ❌ Failed |\n`;
@@ -79,29 +105,13 @@ jobs:
79105
body += `| ruff | ❌ Failed |\n`;
80106
}
81107
if (pytestFailed) {
82-
body += `| pytest | ❌ Failed | [View Logs](${constructLogURL('pytest')}) |\n`;
108+
body += `| pytest | ❌ Failed |\n`;
83109
}
84110
85-
body += `\n**Note**: These failures don't necessarily block the PR but both authors and reviewers should check the results for unintentional breaking changes.\n[View Logs]()\n`;
86-
87-
// Post the failure comment
88-
await github.rest.issues.createComment({
89-
issue_number: context.issue.number,
90-
owner: context.repo.owner,
91-
repo: context.repo.repo,
92-
body: body
93-
});
94-
95-
// Fail the job to show a red X
96-
core.setFailed("One or more pyQuil checks failed.");
97-
} else { // or post success
98-
let body = `✅ **pyQuil Compatibility Checks Passed** on Python \`${{ matrix.python-version }}\`. Great job!`;
99-
100-
// Post the success comment
101-
await github.rest.issues.createComment({
102-
issue_number: context.issue.number,
103-
owner: context.repo.owner,
104-
repo: context.repo.repo,
105-
body: body
106-
});
111+
body += `\n**Note**: These failures don't necessarily block the PR but both authors and reviewers should check the results for unintentional breaking changes.\n[View Logs](${ constructLogURL })\n`;
112+
}
113+
else {
114+
body += `✅ **pyQuil Compatibility Checks Passed**. Great job!`;
107115
}
116+
117+
postOrUpdateComment(body);

0 commit comments

Comments
 (0)