Skip to content

Add github.ref to concurrency configuration for push workflows - #818

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-bd5b284d-5bfc-42fe-b8fd-f5bdce87de8f
Sep 14, 2025
Merged

Add github.ref to concurrency configuration for push workflows#818
pelikhan merged 3 commits into
mainfrom
copilot/fix-bd5b284d-5bfc-42fe-b8fd-f5bdce87de8f

Conversation

Copilot AI commented Sep 14, 2025

Copy link
Copy Markdown
Contributor

This PR fixes the concurrency configuration for workflows with push triggers to include github.ref, ensuring proper isolation between different branches and refs.

Problem

Previously, workflows with push triggers only used the workflow name in their concurrency group:

concurrency:
  group: "gh-aw-${{ github.workflow }}"

This meant that pushes to different branches (e.g., main, develop, feature/xyz) would all share the same concurrency group, potentially causing unintended workflow cancellations or queueing across branches.

Solution

The concurrency configuration now includes github.ref for push workflows:

concurrency:
  group: "gh-aw-${{ github.workflow }}-${{ github.ref }}"

This ensures that:

  • Pushes to main get concurrency group: "gh-aw-MyWorkflow-refs/heads/main"
  • Pushes to develop get concurrency group: "gh-aw-MyWorkflow-refs/heads/develop"
  • Each branch operates independently without interference

Implementation Details

  • Added isPushWorkflow() function to detect workflows with push triggers
  • Modified buildConcurrencyGroupKeys() to append github.ref for push workflows
  • Maintained existing priority logic where pull request workflows take precedence over push workflows in mixed scenarios
  • Pull request workflows continue to use ${{ github.event.pull_request.number || github.ref }} as before

Examples

Pure push workflow:

on:
  push:
    branches: [main, develop]

Generates:

concurrency:
  group: "gh-aw-${{ github.workflow }}-${{ github.ref }}"

Mixed push + pull request workflow:

on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize]

Generates (PR logic takes priority):

concurrency:
  group: "gh-aw-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
  cancel-in-progress: true

Testing

  • All existing tests pass with no regressions
  • Added comprehensive test coverage for push workflows
  • Added tests for mixed push/PR workflow scenarios
  • Manual verification with compiled workflow examples
  • Full validation suite (build, test, lint, format) passes

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build3644294473/b278/cli.test -test.testlogfile=/tmp/go-build3644294473/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build4271198390/b278/cli.test -test.testlogfile=/tmp/go-build4271198390/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add isPushWorkflow() function to detect push triggers
- Modify buildConcurrencyGroupKeys() to include github.ref for push workflows
- Update tests to verify push workflows include github.ref
- Add comprehensive test cases for push and mixed workflows
- All tests passing, code formatted and linted

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] The default concurrency level should have github.ref if the triggers contain push or pull-request Add github.ref to concurrency configuration for push workflows Sep 14, 2025
Copilot AI requested a review from pelikhan September 14, 2025 16:09
@pelikhan
pelikhan marked this pull request as ready for review September 14, 2025 16:16
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge origin/main

Copilot AI commented Sep 14, 2025

Copy link
Copy Markdown
Contributor Author

@copilot merge origin/main

I cannot perform git merge operations directly as I don't have access to commit/push changes using git commands. There is one commit in main (0b6ea2f - renamed to dev workflow) that would need to be merged. You'll need to perform the merge manually or through the GitHub UI.

@pelikhan
pelikhan merged commit b8c849d into main Sep 14, 2025
12 checks passed
@pelikhan
pelikhan deleted the copilot/fix-bd5b284d-5bfc-42fe-b8fd-f5bdce87de8f branch September 14, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants