-
Notifications
You must be signed in to change notification settings - Fork 9
fix(rerun-ci): Fixes the rerun-ci tooling to request a rerun from CircleCI #71
Conversation
…cleCI Previously, rerunning CI with the tooling would simply request a new run of the workflow on the branch. Instead, we should request a rerun via the API to allow only running the failing jobs rather than rerunning the successful jobs.
gkalpak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like being able to proparly run a workflow as a PR (which to my understanding is what this change allows us to do (among other things)). But I think it might also be useful to run the whole workflow (i.e. including the passed jobs) at HEAD (for example, to verify against recently merged commits).
Could we have too labels (one that reruns the whole workflow and one that reruns the failed jobs only)? 🙏
| for (const status of statuses) { | ||
| if (status.context.startsWith('ci/circleci:')) { | ||
| targetUrl = status.target_url; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super-nit: This could be simplified as:
| for (const status of statuses) { | |
| if (status.context.startsWith('ci/circleci:')) { | |
| targetUrl = status.target_url; | |
| break; | |
| } | |
| } | |
| const targetUrl = statuses.find(x => x.context.startsWith('ci/circleci:'))?.target_url; |
| /** | ||
| * The matcher results of the regex to select the job ID of the job which the status represents. | ||
| */ | ||
| const jobIdMatcher = targetUrl.match(`https://circleci.com/gh/${owner}/${repo}/(\d+)\?`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this string is converted to the RegExp you intend it to be converted 😁
What you have now will basically match https://circleci.com/gh/${owner}/${repo}/ followed by zero or more d letters 😁
You were probably going for something like:
| const jobIdMatcher = targetUrl.match(`https://circleci.com/gh/${owner}/${repo}/(\d+)\?`); | |
| const jobIdMatcher = targetUrl.match(`https://circleci\\.com/gh/${owner}/${repo}/(\\d+)\\?`); |
| } | ||
|
|
||
| /** The job ID. */ | ||
| const job = jobIdMatcher[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you mean:
| const job = jobIdMatcher[0]; | |
| const job = jobIdMatcher[1]; |
Previously, rerunning CI with the tooling would simply request a new run of the workflow
on the branch. Instead, we should request a rerun via the API to allow only running
the failing jobs rather than rerunning the successful jobs.