Skip to content

feat: add bidirectionalLabelMatch option and deprecate exactMatch#5031

Merged
Brend-Smits merged 2 commits into
mainfrom
fix/exact-match-was-not-really-exact-but-partial-exact
Jul 3, 2026
Merged

feat: add bidirectionalLabelMatch option and deprecate exactMatch#5031
Brend-Smits merged 2 commits into
mainfrom
fix/exact-match-was-not-really-exact-but-partial-exact

Conversation

@Brend-Smits

@Brend-Smits Brend-Smits commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Description

Introduce a new bidirectionalLabelMatch option that performs strict two-way label matching (runner labels must equal workflow labels as a set). This preserves the existing exactMatch behavior (unidirectional subset check) to avoid breaking changes.

The bidirectionalLabelMatch option requires labels to be identical in both directions. Previously, a runner with labels [A, B, C, D] would match a job requesting [A, B, C] when exactMatch was true. With bidirectionalLabelMatch=true, the runner will only match if the job requests exactly [A, B, C, D].

Before: Job [A,B,C] + Runner [A,B,C,D] + exactMatch=true            → Match
After:  Job [A,B,C] + Runner [A,B,C,D] + bidirectionalLabelMatch=true → No Match

exactMatch was supposed to have this behavior, but to avoid breaking changes, the variable will be deprecated to give users time to migrate.

Changes:

  • Add bidirectionalLabelMatch to MatcherConfig interface (optional, defaults to false)
  • Update canRunJob to support bidirectional matching when enabled — now accepts both bidirectionalLabelMatch and enableDynamicLabels parameters; bidirectional matching correctly respects dynamic label sanitization
  • Deprecate exactMatch in Terraform variables with migration guidance
  • Add bidirectionalLabelMatch to multi-runner and webhook variable types
  • Add new root variable enable_runner_bidirectional_label_match
  • Add comprehensive test coverage for bidirectional matching

Migration: To migrate, use bidirectionalLabelMatch instead of exactMatch in your runner configs. Then either:

  1. Remove extra labels from runner configurations, or
  2. Add the extra labels to your workflow job runs-on

Co-authored-by: Stuart Pearson

Test Plan

  • Added/updated unit tests in dispatch.test.ts covering bidirectional label matching, interaction with exactMatch, case-insensitivity, empty labels, and combined use with enableDynamicLabels — 36 tests passing

Related Issues

@Brend-Smits Brend-Smits requested a review from a team as a code owner February 13, 2026 14:41
@github-actions

github-actions Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 34b7069 to f597650 Compare February 13, 2026 14:44
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from f86dfa0 to 7a14043 Compare March 9, 2026 09:33
@Brend-Smits Brend-Smits requested a review from a team as a code owner March 9, 2026 09:33
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 187cc9d to 8018959 Compare March 9, 2026 09:39
@Brend-Smits Brend-Smits changed the title fix!: make exactMatch truly bidirectional for label matching feat: add bidirectionalLabelMatch option and deprecate exactMatch Mar 9, 2026
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 8018959 to e61882b Compare March 9, 2026 09:43
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from f793d18 to e61882b Compare April 1, 2026 13:20
Brend-Smits added a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Apr 14, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 10, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
@Brend-Smits

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 6c68ca4.

Two files had conflicts:

  • dispatch.ts: Combined our bidirectionalLabelMatch parameter with main's enableDynamicLabels parameter into a unified 5-parameter canRunJob signature. Both features now work together — bidirectional matching uses the sanitized labels (respecting dynamic label stripping) when enableDynamicLabels is enabled.
  • modules/multi-runner/README.md: Took main's updated documentation (macOS runners, dynamic labels, relaxed cpu_options schema) and added our bidirectionalLabelMatch field to the matcherConfig section.

Also updated the test file to correctly pass both parameters (36 tests passing).

Brend-Smits added a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 11, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
Brend-Smits added a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 11, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 11, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 12, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 14, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 17, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
philips-forks-framework-releaser Bot pushed a commit to philips-forks/terraform-aws-github-runner that referenced this pull request Jun 19, 2026
Upstream-PR: github-aws-runners#5031
Signed-off-by: Brend Smits <brend.smits@philips.com>
@Brend-Smits

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit fd11a6a.

8 files had conflicts:

  • dispatch.ts: Combined our bidirectionalLabelMatch sort/filter with main's new per-runner dynamic labels policy architecture (enableDynamicLabels/ec2DynamicLabelsPolicy per matcher). The canRunJob function now takes 4 params (removed the top-level enableDynamicLabels param since main moved that logic into handleWorkflowJob).
  • dispatch.test.ts: Kept our bidirectional label match tests alongside main's new per-matcher dynamic label dispatch tests. Removed tests that relied on the now-removed 5th enableDynamicLabels param in canRunJob.
  • sqs/index.ts: MatcherConfig now includes all fields: exactMatch, bidirectionalLabelMatch, enableDynamicLabels, and ec2DynamicLabelsPolicy.
  • main.tf: Matcher config includes both bidirectionalLabelMatch and enableDynamicLabels/ec2DynamicLabelsPolicy.
  • modules/multi-runner/variables.tf, modules/webhook/variables.tf: matcherConfig object includes all fields.
  • modules/multi-runner/README.md, modules/webhook/README.md: Combined descriptions and type definitions from both branches.

All 92 tests pass.

@edersonbrilhante

Copy link
Copy Markdown
Contributor

@Brend-Smits Some commits are not signed. I am ready to merge, just need you to fix the commits first

@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 66ec55e to 9ad4e17 Compare July 3, 2026 14:42
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 09229f7 to ffc2cc0 Compare July 3, 2026 14:45
@Brend-Smits

Copy link
Copy Markdown
Contributor Author

@Brend-Smits Some commits are not signed. I am ready to merge, just need you to fix the commits first

Thanks for having a look! Apologies for that. I think something went wrong in the merge.... Can you have another look?

Introduce a new bidirectionalLabelMatch option that performs strict
two-way label matching (runner labels must equal workflow labels as a
set). This preserves the existing exactMatch behavior (unidirectional
subset check) to avoid breaking changes.

The bidirectionalLabelMatch option for runner label matching
requires labels to be identical in both directions. Previously, a runner
with labels [A, B, C, D] would match a job requesting [A, B, C] when
exactMatch was true. Now, bidirectionalLabelMatch=true requires the labels to be
exactly identical - the runner will only match if the job requests
exactly [A, B, C, D].

Signed-off-by: Brend Smits <brend.smits@philips.com>
@Brend-Smits Brend-Smits force-pushed the fix/exact-match-was-not-really-exact-but-partial-exact branch from 3068376 to 30e66d8 Compare July 3, 2026 14:48
@Brend-Smits Brend-Smits enabled auto-merge (squash) July 3, 2026 14:51
@Brend-Smits Brend-Smits merged commit 4ccbde6 into main Jul 3, 2026
43 checks passed
@Brend-Smits Brend-Smits deleted the fix/exact-match-was-not-really-exact-but-partial-exact branch July 3, 2026 15:16
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.

3 participants