Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134309: Fix premature cancellation of CI tests when multiple PRs have the same branch name#134310

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AA-Turner merged 12 commits intopython:mainfromabstractedfox:fix-ci
May 22, 2025

Conversation

abstractedfox
Copy link
Contributor

@abstractedfoxabstractedfox commentedMay 20, 2025
edited by bedevere-appbot
Loading

PerGitHub, "When you define a concurrency key, GitHub Actions ensures that only one workflow or job with that key runs at any given time." Under the current config, concurrency group names for pull requests are made unique (against those of other pull requests) only by the name of the branch, so if pull requests were made for identically named branches around the same time, CI would fail. (This affected commit#134234 )

This PR addresses that by using more unique attributes to name each concurrency group. This should also help with debugging any future issues that concern the name of a concurrency group.

abstractedfoxand others added9 commitsMay 19, 2025 10:39
Addresses issue encountered during PyCon US sprints where having multiple workflows with the same concurrency group causes one of the two to be canceled.Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@bedevere-app

This comment was marked as outdated.

@abstractedfox

This comment was marked as resolved.

@bedevere-app

This comment was marked as outdated.

Comment on lines 18 to 26
group: >-
${{
github.workflow
}}-${{
github.ref_name
}}-${{
github.event.pull_request.number
|| github.sha
}}
Copy link
Member

Choose a reason for hiding this comment

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

Remove whitespace

Suggested change
group:>-
${{
github.workflow
}}-${{
github.ref_name
}}-${{
github.event.pull_request.number
|| github.sha
}}
group:${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}-reusable

Copy link
Contributor

Choose a reason for hiding this comment

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

It was me who asked for wrapped lines FTR.

Also, we decided to drop the reusable suffix. We talked about it with Cam a lot yesterday.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think wrapped lines meaningfully help here, and because of the interpolation markers it just adds more visual clutter.

Fine with keeping or removing-reusable, it wasn't mentioned in the PR so I thought it was unintentional.

@AA-Turner
Copy link
Member

I'm surprised that this happens, I had thought thatgithub.run_id was a unique number?

A

@sergey-miryanov
Copy link
Contributor

Is it worth doing? I always thought that this behavior was to avoid consuming resources, since the previous push will have obsolete results.

@AA-Turner
Copy link
Member

The problem is when new/inexperienced users create a PR from the default branch, all of the concurrency keys collide as there is no namespacing. This becomes an issue at events like the US PyCon.

I've considered suggesting a workflow to auto-close PRs from the default branch, as they come with various problems, but I've held off as it does seem a little heavy handed.

A simpler fix would just be to prepend the account name of the fork, but I don't know if there's an easy GH context variable for that (currently on mobile).

A

webknjaz reacted with thumbs up emoji

@hugovk
Copy link
Member

A simpler fix would just be to prepend the account name of the fork, but I don't know if there's an easy GH context variable for that (currently on mobile).

github.triggering_actor is the "username of the user that initiated the workflow run".

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context

@@ -15,7 +15,15 @@ permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
group: >-
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a comment to explain why we have to put these information into the group? I understand that it's a way to create a global unique identifier.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Just to clarify, the info from lines 19-26 or just what's on line 18?

Copy link
Contributor

Choose a reason for hiding this comment

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

The entire thing I imagine.

Copy link
Member

Choose a reason for hiding this comment

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

Document how the group string is created.

Proposed different fix after doing some further testing. This ensuresthat concurrency workflows will have a unique name in any situation thattriggers them, and better navigates some quirks in github actions.The improved comments should make it more visible how the namingworks.Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@abstractedfox
Copy link
ContributorAuthor

I'd like some opinions here (/nudging@webknjaz and@CAM-Gerlach if they would like to weigh in), I did some extra testing on a boilerplate repo and it seems like github may have changed how some of these work.github.event.pull_requestdoesn't contain a field for pr number anymore, andgithub.ref_name gives{PR number}/merge for PR's and only the branch name for any other actions that may trigger the workflow. I changed it to keepgithub.ref_name (since it at least includes the PR number when the actionis a PR) followed by either the name of the branch (PR) or the git sha (not PR) (this is also explained in a comment in the code). This should solve the uniqueness problem and still be more debuggable in the future. Thoughts?

@webknjaz
Copy link
Contributor

@webknjaz
Copy link
Contributor

@hugovk FYI that actor isn't always the PR author, it might be somebody from core restarting the workflow, or closing+reopening the issue, or adding a commit on top.

I'll try to spend some time thinking this though in the morning... Maybe check w/ Kira IRL.

@hugovk
Copy link
Member

@hugovk FYI that actor isn't always the PR author, it might be somebody from core restarting the workflow, or closing+reopening the issue, or adding a commit on top.

Ah right,github.actor should be constant:

The username of the user that triggered the initial workflow run. If the workflow run is a re-run, this value may differ from github.triggering_actor. Any workflow re-runs will use the privileges of github.actor, even if the actor initiating the re-run (github.triggering_actor) has different privileges.
 

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Copy link
Member

@hugovkhugovk left a comment

Choose a reason for hiding this comment

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

Thanks!

@hugovkhugovk added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 21, 2025
Copy link
Contributor

@webknjazwebknjaz left a comment

Choose a reason for hiding this comment

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

LGTM and addresses all of my original concerns.

@AA-TurnerAA-Turner merged commit979d81a intopython:mainMay 22, 2025
46 checks passed
@miss-islington-app
Copy link

Thanks@abstractedfox for the PR, and@AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 22, 2025
…cy key (pythonGH-134310)When inexperienced users create a PR from their default branch, all of the concurrency keyscollide as there is no namespacing. This becomes an issue at events with many new contributors,where workflow runs are cancelled on other pull requests.Disambiguate by adding the username of the relevant 'actor' to the concurrency key.(cherry picked from commit979d81a)Co-authored-by: Kira <coldcaption@gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>Authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 22, 2025
…cy key (pythonGH-134310)When inexperienced users create a PR from their default branch, all of the concurrency keyscollide as there is no namespacing. This becomes an issue at events with many new contributors,where workflow runs are cancelled on other pull requests.Disambiguate by adding the username of the relevant 'actor' to the concurrency key.(cherry picked from commit979d81a)Co-authored-by: Kira <coldcaption@gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>Authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app
Copy link

GH-134484 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 22, 2025
@bedevere-app
Copy link

GH-134485 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 22, 2025
AA-Turner added a commit that referenced this pull requestMay 22, 2025
…ncy key (GH-134310) (#134485)gh-134309: Add ``github.actor`` to the GitHub Actions concurrency key (GH-134310)When inexperienced users create a PR from their default branch, all of the concurrency keyscollide as there is no namespacing. This becomes an issue at events with many new contributors,where workflow runs are cancelled on other pull requests.Disambiguate by adding the username of the relevant 'actor' to the concurrency key.(cherry picked from commit979d81a)Authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Kira <coldcaption@gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
AA-Turner added a commit that referenced this pull requestMay 22, 2025
…ncy key (GH-134310) (#134484)gh-134309: Add ``github.actor`` to the GitHub Actions concurrency key (GH-134310)When inexperienced users create a PR from their default branch, all of the concurrency keyscollide as there is no namespacing. This becomes an issue at events with many new contributors,where workflow runs are cancelled on other pull requests.Disambiguate by adding the username of the relevant 'actor' to the concurrency key.(cherry picked from commit979d81a)Authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Kira <coldcaption@gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner left review comments

@AA-TurnerAA-TurnerAA-Turner left review comments

@webknjazwebknjazwebknjaz approved these changes

@hugovkhugovkhugovk approved these changes

@ezio-melottiezio-melottiAwaiting requested review from ezio-melottiezio-melotti is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@abstractedfox@AA-Turner@sergey-miryanov@hugovk@webknjaz@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp