You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a new CI workflow to enforce media optimization. On pull requests to main, it compresses changed png/gif/mp4 files, uploads optimized outputs as the compressed-media-assets artifact, and fails the check when compression updates are detected so they can be included in the PR. It also provides a workflow_dispatch trigger to run the same compression check across all tracked media files for one-time repository backfill.
This PR adds stronger media compression checks in CI: non-snapshot PNGs are compressed with pngquant (with optipng fallback), *-snapshots/*.png remain lossless to reduce visual-test drift, GIFs are compressed with gifsicle --lossy=120 --colors 128, and MP4s are compressed with ffmpeg (crf=32, fps=20, scaled to fit within 1280x720 while preserving aspect ratio). The workflow uploads optimized artifacts and fails when compressible changes are detected so the optimized outputs can be applied in the PR. It also introduces .github/media-compression.lock (path + SHA-256) to make behavior deterministic: files already matching the lock are skipped, and when CI compresses a file it updates the lock entry and includes the updated lockfile in the artifact, so applying the artifact and pushing prevents repeat fail loops on the same files. On the same ~16.42 MB media set, research runs showed conservative lossless compression to ~15.08 MB (save ~1.34 MB, 8.16%), moderate lossy to ~11.95 MB (save ~4.47 MB, 27.25%), and aggressive lossy to ~9.7–9.8 MB (save ~6.6–6.7 MB, ~40%). This workflow uses the aggressive lossy profile in CI.
I think that media-compression.lock adds too much overhead to maintaining this repository (adding new examples/modifying existing ones). Could we only run exclusively lossless compression instead? At least with optipng this should stabilise at a stable binary form.
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
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.
closes #289
This PR adds a new CI workflow to enforce media optimization. On pull requests to main, it compresses changed
png/gif/mp4files, uploads optimized outputs as thecompressed-media-assetsartifact, and fails the check when compression updates are detected so they can be included in the PR. It also provides aworkflow_dispatchtrigger to run the same compression check across all tracked media files for one-time repository backfill.