How to Compress Test Artifacts in CI
Test runs produce verbose reports, traces, and screenshots. Compressing them before upload cuts transfer time and storage with no information loss.
Test artifacts like coverage XML, JUnit reports, and Playwright traces are highly compressible text and image data. Archiving them before upload shrinks the bytes that cross the network.
1. Archive before uploading
Bundle a directory of reports into a single compressed tarball so the upload is one small file, not thousands.
- run: tar -czf reports.tar.gz coverage/ junit/ traces/
- uses: actions/upload-artifact@v4
with:
name: reports
path: reports.tar.gz2. Pick the format for the data
Use zstd for speed on large text reports; gzip is fine for small ones. Match the tool to the size.
- run: tar --zstd -cf traces.tar.zst playwright-report/3. Do not double-compress
PNG screenshots and already-zipped traces compress poorly; re-archiving them wastes CPU for almost no size gain. Compress text reports; store already-compressed binaries as-is.
4. Compression trades CPU for network
Compression spends runner CPU to save upload time. On a right-sized Latchkey runner the CPU is there to do it cheaply, so the net is faster jobs and smaller storage.
Key takeaways
- Archive report directories into one compressed file before upload.
- Use zstd for large text reports, gzip for small ones.
- Do not re-compress PNGs or already-zipped traces.