-
Notifications
You must be signed in to change notification settings - Fork 66
Modernize the environment and add the new minPctChange option. #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Changes: - switch docker image from Ubuntu 20 to lightweight Alpine - switch from Node 12 to Node 22 - use the latest sharp release (0.34.2) with built-in vips library - use 'npm ci' instead of 'npm install' - replace the deprecated set-output console log - fix octokit deprecation and import - add new minPctChange option to control the minimum saving to commit optimized images The very old sharp/vips versions together with the fixed 1% size change were causing webp images to be continuosly optimized until the actual quality became very low.
Hey @alexdupre! Great PR, thanks so much for your efforts so far. Mozjpeg hasn't needed to be compiled for a while now, so it's long been on my mind to circle back and update image-actions. Thanks again for taking on this work. I can see atm the docker build is failing, once you've had the chance to fix I'll be happy to do a full review and get this released 🛳️ Given that the |
The Docker image works, the old tests are now broken. I cannot have a look before a couple of weeks, perhaps you can fix them in the meanwhile? I tried to create a JS only action, but I wasn't successful, given that it requires the native component for vips and 'ncc' wasn't able to package it. |
In checking I can see that the test that failed is caused by an unexpected write to
How did you test your changes?
As far as I am aware, vips will automatically get installed for the correct architecture, as provided by NPM. I don't think this will be a blocker for marking as a JS only option. In checking the JS action docs, it looks we will need to update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added queries around minimum percent change threshold
minPctChange: | ||
description: "Minimun percentage reduction to be committed" | ||
required: false | ||
default: "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as you've reported that 1% causes issues with webp, it might be worth considering changing to a higher default value. Should the value be numeric or a string?
default: "1" | |
default: "2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently using 5% and still many webp images are optimized more than once.
The underlying value is a float, but in this file all values are strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently using 5% and still many webp images are optimized more than once.
Damn… that does not sound ideal. Early on when I built image-actions I recall that 1% was about right… but that was before it supported webp. A higher single digit default might be required. Maybe 5% is a good starting place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess something between 5% and 10% is a good value, with a tradeoff between compression (5%) and single run (10%).
An idea that I had was to iterate the optimization step within a single action run, until the saving was below the threshold, to reach the best/final size in a single commit, but I wasn't sure if it was a good idea.
minPctChange: '2.5' | ||
``` | ||
|
||
`minPctChange` accepts a numerical value and defaults to '1'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`minPctChange` accepts a numerical value and defaults to '1'. | |
`minPctChange` accepts a numerical value represented as a string. `Default = '2'`. | |
@@ -115,6 +115,20 @@ with: | |||
|
|||
`compressOnly` accepts a Boolean value (true or false) and defaults to false. | |||
|
|||
### Minimum percentage change | |||
|
|||
By default, Image Actions commits optimised images if the new size is at least 1% smaller than the original one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, Image Actions commits optimised images if the new size is at least 1% smaller than the original one. | |
By default, Image Actions commits optimised images if the new size is at least 2% smaller than the original one. | |
@@ -21,6 +22,7 @@ const IGNORE_PATHS = process.env['INPUT_IGNOREPATHS'] | |||
: ['node_modules/**'] | |||
const COMPRESS_ONLY = process.env['INPUT_COMPRESSONLY'] === 'true' | |||
const JPEG_PROGRESSIVE = process.env['INPUT_JPEGPROGRESSIVE'] === 'true' | |||
const MIN_PCT_CHANGE = parseFloat(process.env['INPUT_MINPCTCHANGE']) || 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const MIN_PCT_CHANGE = parseFloat(process.env['INPUT_MINPCTCHANGE']) || 1 | |
const MIN_PCT_CHANGE = parseFloat(process.env['INPUT_MINPCTCHANGE']) || 2 |
To test it, I switched to build the docker image: I'm using the action in some of my projects successfully. A JS action cannot install npm dependencies, either you have to commit the |
Thanks for the clarification, it's been a long time since I looked at action packaging. |
Changes:
The very old sharp/vips versions together with the fixed 1% size change were causing webp images to be continuosly optimized until the actual quality became very low.