Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 7, 2025

The Release Stage 1 workflow was failing with the error "GraphQL: Base branch was modified. Review and try the merge again" due to a race condition when multiple dependency update bots tried to merge PRs simultaneously.

Problem

The workflow used a matrix strategy that ran alpha, beta, and stable dependency update jobs in parallel:

strategy:
  matrix: ${{ fromJson(needs.determine-release-types.outputs.matrix) }}

This caused race conditions where:

  1. All three jobs (alpha, beta, stable) would run simultaneously
  2. Each would create PRs and attempt to auto-merge them at the same time
  3. When one job merged its PR (modifying the base branch), other jobs would fail with "Base branch was modified"
  4. This resulted in workflow failures like run #17525831245

Solution

Added a simple max-parallel: 1 constraint to the existing matrix strategy:

strategy:
  max-parallel: 1
  matrix: ${{ fromJson(needs.determine-release-types.outputs.matrix) }}

Key improvements:

  • Minimal change - Only one line added to the existing workflow
  • Preserves matrix structure - Maintains clean DRY approach without code duplication
  • Prevents race conditions - Ensures sequential execution by allowing only one matrix job to run at a time
  • Easy to understand - Clear intent and simple implementation
  • Maintains existing logic - All matrix variables and conditional execution preserved

Benefits over Sequential Jobs Approach

This solution is superior to creating separate sequential jobs because it:

  • Keeps the clean matrix structure intact
  • Avoids duplicating job definitions
  • Maintains all existing matrix variables (${{ matrix.release_type }}, ${{ matrix.config_file }})
  • Requires minimal changes to the existing workflow
  • Is easier to understand and maintain

Testing

Added comprehensive test suite (test/test-race-condition-fix.sh) that validates:

  • YAML syntax correctness
  • Matrix strategy with max-parallel constraint
  • Single job structure (not separate sequential jobs)
  • Matrix variable usage preservation
  • Proper race condition prevention

All existing tests continue to pass, ensuring no regressions were introduced.

Fixes #227.


💡 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.

…cution

- Replace parallel matrix strategy with sequential jobs
- Add proper job dependencies (alpha -> beta -> stable)
- Use always() conditions for error resilience
- Maintain conditional execution based on release types
- Add comprehensive test suite for validation

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Release Stage 1 fails Fix Release Stage 1 race condition by implementing sequential job execution Sep 7, 2025
@Copilot Copilot AI requested a review from NorthernMan54 September 7, 2025 13:57
Copilot finished work on behalf of NorthernMan54 September 7, 2025 13:57
@NorthernMan54
Copy link
Contributor

@copilot Can we try a different approach, and keep the matrix. Just have the matrix run with a max parallel of 1

Replace sequential jobs approach with cleaner matrix strategy constraint:
- Revert to original matrix structure
- Add max-parallel: 1 to prevent race conditions
- Update tests and documentation for new approach
- Much simpler solution maintaining DRY principles

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 7, 2025

@copilot Can we try a different approach, and keep the matrix. Just have the matrix run with a max parallel of 1

You're absolutely right! That's a much cleaner approach. I've implemented the max-parallel: 1 solution instead:

strategy:
  max-parallel: 1
  matrix: ${{ fromJson(needs.determine-release-types.outputs.matrix) }}

This approach is much better because:

  • ✅ Only adds one line to the existing workflow
  • ✅ Maintains the clean matrix structure (no code duplication)
  • ✅ Still prevents race conditions by ensuring sequential execution
  • ✅ Preserves all existing matrix variables and logic
  • ✅ Much simpler and easier to understand

The max-parallel constraint ensures that even though the matrix defines multiple jobs (alpha, beta, stable), only one will run at a time, preventing the race condition while keeping the DRY principle intact.

Implemented in commit af346e9.

@Copilot Copilot AI changed the title Fix Release Stage 1 race condition by implementing sequential job execution Fix Release Stage 1 race condition using max-parallel constraint Sep 7, 2025
Copilot finished work on behalf of NorthernMan54 September 7, 2025 14:11
@NorthernMan54 NorthernMan54 marked this pull request as ready for review September 7, 2025 14:14
@NorthernMan54 NorthernMan54 merged commit db55a19 into latest Sep 7, 2025
1 check passed
@NorthernMan54 NorthernMan54 deleted the copilot/fix-227 branch September 7, 2025 14:15
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.

Release Stage 1 fails
2 participants