Skip to content

fix flakey tests #35

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2025
Merged

fix flakey tests #35

merged 4 commits into from
May 9, 2025

Conversation

GrantBirki
Copy link
Member

The TestBranchMatchesCriteria function uses global variables (combineBranchName, branchPrefix, branchSuffix, branchRegex) that are modified during each test case. This can lead to race conditions and flakiness when tests are run in parallel. The fix is to refactor the branchMatchesCriteria function to accept these variables as parameters instead of relying on global state.


resolves: #34

@Copilot Copilot AI review requested due to automatic review settings May 9, 2025 06:11
@GrantBirki GrantBirki added the bug Something isn't working label May 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors branchMatchesCriteria to take its filter parameters explicitly rather than relying on mutable globals, updating all call sites and tests accordingly to avoid race conditions in parallel tests.

  • Changed the signature of branchMatchesCriteria to accept combineBranchName, branchPrefix, branchSuffix, and branchRegex as parameters.
  • Updated PrMatchesCriteria to pass through the global values to the new signature.
  • Revised TestBranchMatchesCriteria to remove global state manipulation and call the refactored function with per-test inputs.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/cmd/match_criteria_test.go Removed global setup/teardown, added parameters to test calls
internal/cmd/match_criteria.go Updated function signature and its call in PrMatchesCriteria

GrantBirki added 2 commits May 8, 2025 23:13

Verified

This commit was signed with the committer’s verified signature.
GrantBirki Grant Birkinbine

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
nobe4
nobe4 previously approved these changes May 9, 2025

Verified

This commit was signed with the committer’s verified signature.
GrantBirki Grant Birkinbine
@GrantBirki GrantBirki merged commit 395c1d2 into main May 9, 2025
7 checks passed
@GrantBirki GrantBirki deleted the flakey-test-fixes branch May 9, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flakey Tests: TestBranchMatchesCriteria
2 participants