-
Notifications
You must be signed in to change notification settings - Fork 29
Description
We are seeing differences in the generated CODEOWNERS Team-specific owned globs order when running codeownership validate locally (macOS) vs the CI (Github Action - Ubuntu).
I created this small repo to try to show what we are experiencing. It only has one team with 8 globs, all with the same prefix before the **.
When I run codeownership validate locally with macOS 15.6, it generates this CODEOWNERS file (order 8-2-3-4-1-6-7-5), but when this runs on the CI, the order is 1-2-3-4-5-6-7-8 (this github action prints the file content after running validate)
This seems to be related to the sorting added here, because the block might give different results depending on the inputs order. For example, the block returns -1 when comparing '/**/a' <=> '/**/b', but it also returns -1 when making the opposite comparison '/**/b' <=> '/**/a', so both '/**/a' < '/**/b' and '/**/b' < '/**/a'.
But also seems to be happening because Ruby is not following the same algorithm steps to compare the entries on macOS vs Ubuntu (maybe some optimization that depends on the OS?). For example, the first comparison on macOS is entry 1 <=> entry 5, whereas on Ubuntu is entry 1 <=> entry 2 (looks like this only happens if the array has at least 8 elements). This can be seen with the output from test.rb which shows each step of the algorithm:
macOS:
/app/**/1.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/5.rb @my-org/operations-team <=> /app/**/8.rb @my-org/operations-team: -1
/app/**/2.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/3.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/4.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/1.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/6.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/7.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/8.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/8.rb @my-org/operations-team <=> /app/**/2.rb @my-org/operations-team: -1
/app/**/2.rb @my-org/operations-team <=> /app/**/3.rb @my-org/operations-team: -1
/app/**/3.rb @my-org/operations-team <=> /app/**/4.rb @my-org/operations-team: -1
/app/**/4.rb @my-org/operations-team <=> /app/**/1.rb @my-org/operations-team: -1
/app/**/1.rb @my-org/operations-team <=> /app/**/6.rb @my-org/operations-team: -1
/app/**/6.rb @my-org/operations-team <=> /app/**/7.rb @my-org/operations-team: -1
/app/**/7.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
Ubuntu (Github Action output here):
/app/**/1.rb @my-org/operations-team <=> /app/**/2.rb @my-org/operations-team: -1
/app/**/3.rb @my-org/operations-team <=> /app/**/4.rb @my-org/operations-team: -1
/app/**/1.rb @my-org/operations-team <=> /app/**/3.rb @my-org/operations-team: -1
/app/**/2.rb @my-org/operations-team <=> /app/**/3.rb @my-org/operations-team: -1
/app/**/5.rb @my-org/operations-team <=> /app/**/6.rb @my-org/operations-team: -1
/app/**/7.rb @my-org/operations-team <=> /app/**/8.rb @my-org/operations-team: -1
/app/**/5.rb @my-org/operations-team <=> /app/**/7.rb @my-org/operations-team: -1
/app/**/6.rb @my-org/operations-team <=> /app/**/7.rb @my-org/operations-team: -1
/app/**/1.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/2.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/3.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
/app/**/4.rb @my-org/operations-team <=> /app/**/5.rb @my-org/operations-team: -1
Not sure if this is a bug or expected behavior, but I can help put together a fix if you think this is not expected.
I also noticed there's a pre-release that will start using the Rust library, so maybe this will not be a problem anymore?
Using these versions:
Ruby: 3.4.5
code_ownershi: 1.39.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Status