Skip to content

workflows/backport: cancel concurrent runs#414800

Merged
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-backport-concurrency
Jun 9, 2025
Merged

workflows/backport: cancel concurrent runs#414800
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-backport-concurrency

Conversation

@wolfgangwalther
Copy link
Contributor

When backporting a change to 24.11 and 25.05 at the same time by adding the two labels immediately after merging the PR, three backport jobs will run concurrently: One for the merge and one for each label added. Each of those jobs will try to create both PRs, which will lead to two of the jobs failing for sure.

With a concurrency group and cancelling in-progress jobs, only one of those jobs will remain. This reduces notification noise.

Example of 3 runs at the same time: #414784.

Things done


Add a 👍 reaction to pull requests you find important.

When backporting a change to 24.11 and 25.05 at the same time by adding
the two labels immediately *after* merging the PR, three backport jobs
will run concurrently: One for the merge and one for each label added.
Each of those jobs will try to create both PRs, which will lead to two
of the jobs failing for sure.

With a concurrency group and cancelling in-progress jobs, only one of
those jobs will remain. This reduces notification noise.
@github-actions github-actions bot added 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion Discuss policies to work in and around Nixpkgs backport release-24.11 labels Jun 7, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jun 7, 2025
@wolfgangwalther wolfgangwalther mentioned this pull request Jun 8, 2025
3 tasks
@MattSturgeon
Copy link
Contributor

I was actually thinking about this after running into the same issue with the workflow in Nixvim.

With a concurrency group and cancelling in-progress jobs, only one of those jobs will remain.

I may be wrong, but I believe cancelled jobs still (kinda) count as a failure, at least enough to trigger an email notification?

There may also be the potential for race conditions here; as it's the already running job that gets cancelled. E.g. maybe the job could get cancelled after pushing the backport branch but before creating the PR? Or at least, after doing some backporting work but before finishing. Not sure if these are practical or theoretical issues though.

Maybe there's a way to use a non-cancelling concurrency group, but have the subsequent jobs "skip" if the backport has already happened?

Or maybe I'm just over-thinking this?

@wolfgangwalther
Copy link
Contributor Author

I may be wrong, but I believe cancelled jobs still (kinda) count as a failure, at least enough to trigger an email notification?

Yes. I already brought this up in #412608, so those cancelled jobs are happening more frequently already. The only solution is to set up an email filter for them, because https://github.com/orgs/community/discussions/13015 is far from being solved.

There may also be the potential for race conditions here; as it's the already running job that gets cancelled. E.g. maybe the job could get cancelled after pushing the backport branch but before creating the PR? Or at least, after doing some backporting work but before finishing. Not sure if these are practical or theoretical issues though.

I thought about this case, too. For #412608, I looked quite a bit into how cancellation of jobs works and there is a grace period before forced shutdown. So I'm hoping that once the backport action is ready to push stuff, the push + creation of the PR will actually be rather fast - thus they might still finish in time. Of course.. that depends on how this action deals with cancellation requests. If this becomes a problem, we might look into #412659 (comment), aka rolling our own backport action, which could do better in this regard.

So, for now, I'm willing to try and see.

Maybe there's a way to use a non-cancelling concurrency group, but have the subsequent jobs "skip" if the backport has already happened?

That would be an alternative, if the backport action would support it silently. It does not, right now. When you already had a backport for 25.05, for example, and then add a backport for 24.11 later, the action will try to create both again and fail loudly for 25.05. If this would happen in an idempotent way, then that would be much better, yes.

Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I already brought this up in #412608, so those cancelled jobs are happening more frequently already.

So, for now, I'm willing to try and see.

SGTM

@wolfgangwalther wolfgangwalther merged commit e95f670 into NixOS:master Jun 9, 2025
16 of 18 checks passed
@wolfgangwalther wolfgangwalther deleted the ci-backport-concurrency branch June 9, 2025 12:07
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Jun 9, 2025

Successfully created backport PR for release-24.11:

@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Jun 9, 2025

Successfully created backport PR for release-25.05:

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Jun 9, 2025
@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Jun 13, 2025

This didn't work too well, yet:

@MattSturgeon
Copy link
Contributor

MattSturgeon commented Jun 13, 2025

This didn't work too well, yet:
* The run was cancelled - but still tried to push and posted comments: NixOS/nixpkgs/actions/runs/15632399091

😢 I guess the only solution is to look into rolling our own backport action, and/or contributing fixes/features to the existing upstream action?

Maybe we can try and go for something that skips jobs instead of cancelling them, as discussed earlier 🤔


If nixpkgs did come up with a first-party action, would there be value in having it in a separate repo? Either a NixOS or nix-community org repo. Currently at least Stylix, Nixvim, and home-manager have implemented backport workflows based on the nixpkgs workflow, using the same upstream action. So maybe they'd want to make use of whatever implementation nixpkgs came up with? I guess one step at a time 😁

@wolfgangwalther
Copy link
Contributor Author

Yeah, an idempotent backport action seems best. If the backport already happened - do nothing. Also, some failure cases I have observed were like "branch was created, put PR creation failed". In this case it would be great, if the later action could pick up where the earlier one left off and just create the PR for the existing branch.

@MattSturgeon
Copy link
Contributor

In this case it would be great, if the later action could pick up where the earlier one left off and just create the PR for the existing branch.

Or at least force-push over the earlier attempt's branch

@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Jun 13, 2025

I think force-pushing would potentially result in triggering the CI on the backport PR up to 3x - and whenever someone plays with the labels after the PR had already been created.

Although that brings up an interesting aspect: If the backport label is removed, a still-open PR could also be closed automatically.

@wolfgangwalther
Copy link
Contributor Author

I guess the only solution is to look into rolling our own backport action, and/or contributing fixes/features to the existing upstream action?

For now, I opened an upstream issue at korthout/backport-action#470.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants