-
Notifications
You must be signed in to change notification settings - Fork 210
fix: pass artifact paths to rsync via --files-from
#1825
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
firecow
merged 2 commits into
firecow:master
from
Paul-Goulpie:fix/rsync-artifacts-files-from-arg-max
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /artifact_* | ||
| /output_dir/ | ||
| /.gitlab-ci-local-many-paths/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| # Creates 9000 files whose names are 255 characters long. | ||
| # With the old approach (paths passed as rsync arguments), the total argument | ||
| # size (~2.3 MB) exceeded ARG_MAX (~2 MB) and rsync failed silently. | ||
| # With the new approach (--files-from + bash for loop), there is no limit on | ||
| # the number of files. | ||
| produce-artifacts: | ||
| stage: build | ||
| script: | ||
| - | | ||
| python3 -c " | ||
| import os | ||
| padding = 'x' * 240 | ||
| for i in range(9000): | ||
| name = f'artifact_{i:05d}_{padding}' | ||
| fd = os.open(name, os.O_CREAT | os.O_WRONLY, 0o644) | ||
| os.close(fd) | ||
| " | ||
| - mkdir -p output_dir && echo "hello" > output_dir/result.txt | ||
| artifacts: | ||
| paths: | ||
| - artifact_* | ||
| - output_dir/ | ||
|
|
||
| consume-artifacts: | ||
| stage: test | ||
| script: | ||
| - count=$(find . -maxdepth 1 -name 'artifact_*' | wc -l) | ||
| - if [ "$count" -ne 9000 ]; then echo "FAIL expected 9000 artifacts, got $count"; exit 1; fi | ||
| - if [ ! -f output_dir/result.txt ]; then echo "FAIL output_dir/result.txt not found"; exit 1; fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| 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); | ||
| }); | ||
|
|
||
| // Validates that --files-from works correctly when the number of artifact files | ||
| // would exceed ARG_MAX if their paths were passed directly as rsync arguments | ||
| // (9000 files × ~257 bytes ≈ 2.3 MB > ARG_MAX ~2 MB). | ||
| test.concurrent("artifacts-many-paths --shell-isolation 9000 artifacts via --files-from", async () => { | ||
| const writeStreams = new WriteStreamsMock(); | ||
| await handler({ | ||
| cwd: "tests/test-cases/artifacts-many-paths", | ||
| shellIsolation: true, | ||
| stateDir: ".gitlab-ci-local-many-paths", | ||
| }, writeStreams); | ||
|
|
||
| // Ensures artifacts were actually exported (not silently swallowed by || true). | ||
| expect(writeStreams.stdoutLines.join("\n")).toMatch(/produce-artifacts.*exported artifacts/); | ||
| // Ensures consume-artifacts found all 9000 expected files. | ||
| expect(writeStreams.stderrLines.join("\n")).not.toMatch(/FAIL/); | ||
| }, 120_000); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.