-
Notifications
You must be signed in to change notification settings - Fork 16
feat(ci): unconditionally hide prior formatting PR comments, and only post a new one in case of failure #1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
novusnota
wants to merge
23
commits into
main
Choose a base branch
from
closes-1284-silence,comments,a-check-is-speaking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−23
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e5c5c3e
feat(ci): unconditionally hide prior formatting PR comments, and only…
novusnota 5f78a67
let's fail the formatter
novusnota 4ff28e7
1
novusnota 8f7fb60
1
novusnota f861ce5
1
novusnota 793e157
1
novusnota 7db37df
1
novusnota 93e69dc
1
novusnota f8aa841
1
novusnota f0c55be
1
novusnota 80146e8
1
novusnota b30764d
1
novusnota b002656
1
novusnota fcb0eec
1
novusnota fe05f7f
1
novusnota 3160523
1
novusnota 3db3dd5
lookin' finger lickin' good
novusnota 2c47997
and now reverting the formatting back
novusnota cc15513
Merge branch 'main' into closes-1284-silence,comments,a-check-is-spea…
novusnota afc0205
Merge branch 'main' into closes-1284-silence,comments,a-check-is-spea…
novusnota 9adbb82
try { place the CI script outside of yaml file } catch (err) { throw …
novusnota 114479d
let's break it, temporarily
novusnota 5667d57
here comes the fix — comments, begone!
novusnota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| export default async function({ github, context, exec }) { | ||
| const success = JSON.parse(process.env.SUCCESS ?? 'false'); | ||
| const rawCommentText = process.env.COMMENT ?? ''; | ||
| if (!success && rawCommentText === '') { | ||
| process.exit(0); | ||
| } | ||
| const comments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| }); | ||
| for (const comment of comments.data) { | ||
| const isHidden = (await github.graphql(` | ||
| query($nodeId: ID!) { | ||
| node(id: $nodeId) { | ||
| ... on IssueComment { | ||
| isMinimized | ||
| } | ||
| } | ||
| } | ||
| `, { nodeId: comment.node_id }))?.node?.isMinimized; | ||
| await exec.exec('sleep 0.5s'); | ||
| if (isHidden) { continue; } | ||
| const body = comment.body; | ||
| const prefix = rawCommentText.slice(1, 30); | ||
| if ( | ||
| comment.user.login === 'github-actions[bot]' && | ||
| body.startsWith(prefix) | ||
| ) { | ||
| console.log('Comment node_id:', comment.node_id); | ||
| console.log(await github.graphql(` | ||
| mutation($subjectId: ID!, $classifier: ReportedContentClassifiers!) { | ||
| minimizeComment(input: { | ||
| subjectId: $subjectId, | ||
| classifier: $classifier | ||
| }) { | ||
| minimizedComment { | ||
| isMinimized | ||
| minimizedReason | ||
| } | ||
| } | ||
| } | ||
| `, { | ||
| subjectId: comment.node_id, | ||
| classifier: success ? 'RESOLVED' : 'OUTDATED', | ||
| })); | ||
| await exec.exec('sleep 0.5s'); | ||
| } | ||
| } | ||
| if (!success) { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: `${rawCommentText.slice(1, -1).replace(/\\n/g, '\n')}`, | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.