Skip to content

Commit e6d03f6

Browse files
authored
Add a regression test for artifact name + content-type mismatches (#472)
* Add a regression test for artifact name + content-type mismatches * Specify that we want v4 in a comment * Fix the expected type
1 parent 70fc10c commit e6d03f6

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,36 @@ jobs:
154154
}
155155
Write-Host "Successfully downloaded artifact without decompressing: $rawFile (size: $($fileInfo.Length) bytes)"
156156
shell: pwsh
157+
158+
# Regression test for artifact filename vs content-type mismatch
159+
# When an archived artifact has a name with a file extension that doesn't
160+
# match the blob type (e.g. "report.txt" but blob is zip), the server
161+
# should append .zip to the content-disposition filename.
162+
- name: Create and upload archived artifact with misleading extension
163+
shell: bash
164+
run: |
165+
mkdir -p path/to/extension-test
166+
echo '{"key": "value"}' > path/to/extension-test/data.json
167+
- uses: actions/upload-artifact@v4 # V4 is important here to ensure we're supporting older versions correctly
168+
with:
169+
name: report.txt-${{ matrix.runs-on }}.json
170+
path: path/to/extension-test/data.json
171+
172+
- name: Download misleading-extension artifact without decompressing
173+
uses: ./
174+
with:
175+
name: report.txt-${{ matrix.runs-on }}.json
176+
path: ext-test/raw
177+
skip-decompress: true
178+
179+
- name: Verify downloaded file has .zip extension appended
180+
shell: bash
181+
run: |
182+
expected="ext-test/raw/report.txt-${{ matrix.runs-on }}.json.zip"
183+
if [ -f "$expected" ]; then
184+
echo "PASS: Downloaded file has .zip appended: $expected"
185+
else
186+
echo "FAIL: Expected $expected but got:"
187+
ls -al ext-test/raw/
188+
exit 1
189+
fi

0 commit comments

Comments
 (0)