-
Notifications
You must be signed in to change notification settings - Fork 210
fix: support wildcard file paths in project includes #1914
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # templates/[bt]*.yml matches both templates/build.yml and templates/test.yml, | ||
| # so the glob expands to more than one file. | ||
| include: | ||
| - project: components/go | ||
| ref: main | ||
| file: templates/[bt]*.yml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import {WriteStreamsMock} from "../../../src/write-streams.js"; | ||
| import {handler} from "../../../src/handler.js"; | ||
| import {initSpawnSpy} from "../../mocks/utils.mock.js"; | ||
| import {WhenStatics} from "../../mocks/when-statics.js"; | ||
|
|
||
| beforeAll(() => { | ||
| initSpawnSpy([...WhenStatics.all, WhenStatics.mockGitRemoteHttp]); | ||
| }); | ||
|
|
||
| test.concurrent("include:project with a wildcard file path includes every match", async () => { | ||
| const writeStreams = new WriteStreamsMock(); | ||
|
|
||
| await handler({ | ||
| cwd: "tests/test-cases/include-project-file-wildcard", | ||
| noColor: true, | ||
| list: true, | ||
| stateDir: ".gitlab-ci-local-include-project-file-wildcard", | ||
| }, writeStreams); | ||
|
|
||
| const jobNames = writeStreams.stdoutLines | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This test (and its .gitlab-ci.yml fixture) depend on a live external GitLab project Prompt for AI agents |
||
| .filter(l => /^(build|test)\s/.test(l)) | ||
| .map(l => l.split(/\s+/)[0]) | ||
| .sort(); | ||
|
|
||
| expect(jobNames).toEqual(["build", "test"]); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Switching the match sort to
String#localeComparemakes the order of included project files depend on the host runtime's locale (via the Intl collator), whereas the previous default.sort()was locale-independent and deterministic. Because these matches are concatenated intoincludeDatasand pipeline config can be merged/overridden in that order, a developer machine with a different locale could resolve a slightly different pipeline than CI for the same inputs. If the goal was stable ordering, keep the locale-invariant default.sort()(or pass an explicit{numeric: true, sensitivity: 'base'}if case-insensitivity is intended); otherwise project includes should order consistently regardless of locale.Prompt for AI agents