Skip to content

Commit 37f5a85

Browse files
authored
fix: drop support for named pipes on Windows (actions#962)
Seems that folk are having issues with uploading 0-byte files from Windows agents. This effectively removes the support for Windows for uploading from named files that, due to `isFIFO` returning `false` on Windows for named pipes created using MSYS2's `mkfifo` command, resorted to checking if the file size is 0 - a common trait of named pipes. See actions/upload-artifact#281
1 parent d1a6612 commit 37f5a85

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

.github/workflows/artifact-tests.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,43 @@ jobs:
4444
npm ci
4545
npm run tsc
4646
working-directory: packages/artifact
47-
47+
4848
- name: Set artifact file contents
4949
shell: bash
5050
run: |
5151
echo "non-gzip-artifact-content=hello" >> $GITHUB_ENV
5252
echo "gzip-artifact-content=Some large amount of text that has a compression ratio that is greater than 100%. If greater than 100%, gzip is used to upload the file" >> $GITHUB_ENV
53+
echo "empty-artifact-content=_EMPTY_" >> $GITHUB_ENV
5354
5455
- name: Create files that will be uploaded
5556
run: |
56-
mkdir artifact-path
57+
mkdir artifact-path
5758
echo ${{ env.non-gzip-artifact-content }} > artifact-path/world.txt
5859
echo ${{ env.gzip-artifact-content }} > artifact-path/gzip.txt
60+
touch artifact-path/empty.txt
5961
6062
# We're using node -e to call the functions directly available in the @actions/artifact package
6163
- name: Upload artifacts using uploadArtifact()
6264
run: |
6365
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-1',['artifact-path/world.txt'], '${{ github.workspace }}'))"
6466
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-2',['artifact-path/gzip.txt'], '${{ github.workspace }}'))"
67+
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-3',['artifact-path/empty.txt'], '${{ github.workspace }}'))"
6568
6669
- name: Download artifacts using downloadArtifact()
6770
run: |
6871
mkdir artifact-1-directory
6972
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadArtifact('my-artifact-1','artifact-1-directory'))"
7073
mkdir artifact-2-directory
7174
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadArtifact('my-artifact-2','artifact-2-directory'))"
72-
75+
mkdir artifact-3-directory
76+
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadArtifact('my-artifact-3','artifact-3-directory'))"
77+
7378
- name: Verify downloadArtifact()
7479
shell: bash
7580
run: |
7681
packages/artifact/__tests__/test-artifact-file.sh "artifact-1-directory/artifact-path/world.txt" "${{ env.non-gzip-artifact-content }}"
7782
packages/artifact/__tests__/test-artifact-file.sh "artifact-2-directory/artifact-path/gzip.txt" "${{ env.gzip-artifact-content }}"
83+
packages/artifact/__tests__/test-artifact-file.sh "artifact-3-directory/artifact-path/empty.txt" "${{ env.empty-artifact-content }}"
7884
7985
- name: Download artifacts using downloadAllArtifacts()
8086
run: |
@@ -85,4 +91,5 @@ jobs:
8591
shell: bash
8692
run: |
8793
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-1/artifact-path/world.txt" "${{ env.non-gzip-artifact-content }}"
88-
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-2/artifact-path/gzip.txt" "${{ env.gzip-artifact-content }}"
94+
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-2/artifact-path/gzip.txt" "${{ env.gzip-artifact-content }}"
95+
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-3/artifact-path/empty.txt" "${{ env.empty-artifact-content }}"

packages/artifact/__tests__/test-artifact-file.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ if [ ! -f "$path" ]; then
1818
exit 1
1919
fi
2020

21-
actualContent=$(cat $path)
22-
if [ "$actualContent" != "$expectedContent" ];then
21+
actualContent=$(cat "$path")
22+
if [ "$expectedContent" == "_EMPTY_" ] && [ ! -s "$path" ]; then
23+
exit 0
24+
elif [ "$actualContent" != "$expectedContent" ]; then
2325
echo "File contents are not correct, expected $expectedContent, received $actualContent"
2426
exit 1
2527
fi

packages/artifact/__tests__/upload.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ describe('Upload Tests', () => {
181181
function hasMkfifo(): boolean {
182182
try {
183183
// make sure we drain the stdout
184-
return execSync('which mkfifo').toString().length > 0
184+
return (
185+
process.platform !== 'win32' &&
186+
execSync('which mkfifo').toString().length > 0
187+
)
185188
} catch (e) {
186189
return false
187190
}

packages/artifact/src/internal/upload-http-client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ export class UploadHttpClient {
221221
): Promise<UploadFileResult> {
222222
const fileStat: fs.Stats = await stat(parameters.file)
223223
const totalFileSize = fileStat.size
224-
// on Windows with mkfifo from MSYS2 stats.isFIFO returns false, so we check if running on Windows node and
225-
// if the file has size of 0 to compensate
226-
const isFIFO =
227-
fileStat.isFIFO() || (process.platform === 'win32' && totalFileSize === 0)
224+
const isFIFO = fileStat.isFIFO()
228225
let offset = 0
229226
let isUploadSuccessful = true
230227
let failedChunkSizes = 0

0 commit comments

Comments
 (0)