Closed pradyunsg closed 2 years ago
There's nothing to be done about this. If cancelations aren't turned into failures, you'd be getting a lot of surprise branch protection breaches. I don't think there's a way to detect a cancelation happening because of the cancelation group and it'd still be fragile (improperly set up cancelation groups can lead to workflows running against the last PR branch being canceled — skipping them would allow bypassing the branch protection). The only thing that I can advise is turning off the notifications.
Here's how cancelation happens, by the way: https://docs.github.com/en/actions/managing-workflow-runs/canceling-a-workflow#steps-github-takes-to-cancel-a-workflow-run
I've got a (terrible) idea — you could try adding an always succeeding job with if: always()
(or inspect the previous jobs for cancelations) and the workflow (probably) would be successful but the check job would still report the right status in the branch protection.
But again... That would be a terrible hack with a lot of possibile surprise effects.
By the way, there was a PR https://github.com/re-actors/alls-green/pull/7 that suggested treating cancelled
as skipped. I had to reject that implementation because it was breaking some guarantees (the new behavior was unconditional) but stated that it'd be okay to maybe make it optional.
Still, it feels dangerous to use this so I'm not sure if we should be enabling this.
I guess the solution to this is to do not cancelled()
somewhere, or possibly pass that information through to the action (i.e. explore some way of skipping the all-greens step if the workflow is cancelled).
Today, I saw if: ${{ !cancelled() }}
in one workflow. Although, I'm pretty sure that it has the same problems.
@pradyunsg let's chat about this on the tomorrow's call. I'm not sure if we understand the implications of this the same way.
Nvm, we get notifications for cancelled jobs anyway. 🤦🏽
https://github.com/pypa/pip/actions/runs/3210435710
This triggers a notification if the jobs were auto-cancelled, for example due to concurrency protections.