Skip to content

Compress uploaded code with gzip - #26

Merged
benrfairless merged 1 commit into
mainfrom
feature/1-compress-uploaded-code
Aug 24, 2026
Merged

benrfairless merged 1 commit into
mainfrom
feature/1-compress-uploaded-code

Conversation

@benrfairless

@benrfairless benrfairless commented Aug 24, 2026

Copy link
Copy Markdown
Member

Description

The morph command now gzip-compresses the tar of scraper code before uploading it. MorphCLI.create_tar wraps the tempfile in a Zlib::GzipWriter around the existing Minitar output, producing a .tar.gz instead of a plain .tar. The gzip stream is finished (not closed) so the returned tempfile handle stays open and rewound for the upload, preserving the method's existing contract, and the multipart content type is now application/gzip.

Motivation and Context

Scraper code was uploaded as an uncompressed tar, wasting bandwidth and upload time. Text-heavy scraper directories compress very well, so this is a cheap win, especially on slow connections.

Resolves #1

Heads up: this needs a matching server-side change (openaustralia/morph#1519) before release. morph.io's ApiController#run_remote currently unpacks the upload with Archive::Tar::Minitar.unpack on a plain tar, so the server needs to decompress (or detect gzip) first. A CLI release before that lands would break morph against production.

How Has This Been Tested?

  • Checked affected area manually on my own / staging system
  • Ran automated tests on my own system
  • Confirmed it passed the GitHub actions tests

Test-first: added specs asserting the archive is gzip-compressed (magic bytes, size reduction on compressible input, and readable via Zlib::GzipReader + Minitar::Input), confirmed they failed against the old implementation, then implemented the change and confirmed the full suite passes (bundle exec rspec, 30 examples, 0 failures, 97.6% line coverage). bundle exec rubocop is clean. Not yet run end-to-end against a server, since morph.io doesn't accept gzipped uploads yet (see above).

Screenshots (if appropriate):

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

AI assistance

Written with AI assistance (Assisted-by: OpenCode:anthropic.claude-fable-5), reviewed by a human before submission.

Wrap the tar upload in a Zlib::GzipWriter so scraper code is
gzip-compressed before being posted to the server, cutting upload time
and bandwidth. The gzip stream is finished (not closed) so the tempfile
handle stays open and rewound for the upload, matching the existing tar
trailer handling. The multipart content type becomes application/gzip.

Note: morph.io's ApiController#run_remote currently unpacks the upload
with Archive::Tar::Minitar.unpack on a plain tar, so it needs a
matching change to decompress before this can be released.

Resolves #1

Assisted-by: OpenCode:anthropic.claude-fable-5
Signed-off-by: Ben Fairless <ben@oaf.org.au>

@ianheggie-oaf ianheggie-oaf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved - LGTM

@benrfairless
benrfairless merged commit 9b6ba2b into main Aug 24, 2026
9 checks passed
@benrfairless
benrfairless deleted the feature/1-compress-uploaded-code branch August 24, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compress uploaded code

2 participants