Conversation
ipanfilo
left a comment
There was a problem hiding this comment.
Maybe make approach more generic - ci_level% label specifies CI level to use.
| const toCancel = runs.data.workflow_runs.filter(run => { | ||
| const prMatch = (run.pull_requests || []).some(pr => pr.number === prNumber); | ||
| const active = run.status === 'queued' || run.status === 'in_progress'; | ||
| if (action === 'synchronize') { |
There was a problem hiding this comment.
reopened action does not seem handled in this code
There was a problem hiding this comment.
Now handled as an early-skip
| // If a label was added, cancel runs with a lower level than the added label | ||
| if (action === 'labeled') { | ||
| const isLowerThanAdded = runLevel > 0 && runLevel < addedLevel; | ||
| return prMatch && active && isLowerThanAdded && run.id !== currentRunId; |
There was a problem hiding this comment.
can is LowerThanAdded be if run.id === currentRunId?
| .map(label => label.name.toLowerCase()); | ||
|
|
||
| // Determine if a CI level label was removed and what level it was | ||
| const removedLabel = (context.payload.label?.name || '').toLowerCase(); |
There was a problem hiding this comment.
Why is it removedLabel? For labeled event it is addedLabel.
Maybe unlabeled events are not needed at all? If higher lablel is added - CI with new level is triggered. Otherwise the last CI run should still be relevant.
There was a problem hiding this comment.
If a PR has labels ci-level 1 and ci-level 3 but then ci-level 3 is removed, then we still need to run ci-level 1 tests.
There was a problem hiding this comment.
If a PR has labels
ci-level 1andci-level 3but thenci-level 3is removed, then we still need to runci-level 1tests.
It ran Level 3 before, why does it need run Level 1 now? The next time something is changed, yes, but why now?
There was a problem hiding this comment.
Originally it was in case the highest-level test wasn't finished, in which case the commit still wouldn't necessarily have a passed test on the next-highest level yet. I've adjusted the script to explicitly check for tests of at least the new level, and skip dispatch if it exists.
Description
With this PR, testing is mediated by labels such as:
ci-level {1, 2, 3}. No tests will be run without at least one label present. At any given time, the highest-level label will take precedence, and only its corresponding level of tests will be run. The workflow triggers on labeling, unlabeling, and pushing commits. When removing a label, the workflow will check to see if there are any labels remaining and if there are, it will dispatch to the highest of them.Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: