Auto-update melange image if older than 30 days#30
Auto-update melange image if older than 30 days#30AmberArcadia wants to merge 2 commits intomainfrom
Conversation
Automatically checks the age of the local melange Docker image and pulls an updated version if it's older than 30 days. Gives users a 15-second window to abort with Ctrl+C before pulling.
|
Hmmm it won't show the prompt by default it seems, oh well. |
stevebeattie
left a comment
There was a problem hiding this comment.
Beyond one minor nit that doesn't necessarily need to block landing this looks good to me.
| def main(argv: Sequence[str] | None = None) -> int: | ||
| # Check and update melange image if needed | ||
| check_and_update_melange_image(MelangeImage) | ||
|
|
There was a problem hiding this comment.
By performing this before the argument parser checking, the melange image check happens even if one does shellcheck_run_steps.py --help which might be unexpected or take a bit to show the help information.
| now = datetime.now(timezone.utc) | ||
| age_days = (now - created_date).days | ||
|
|
||
| if age_days > 30: |
There was a problem hiding this comment.
personally, I'd prefer once a day since we typically don't worry too much about backwards compat in melange changes. It might be cool to make this a config option.
| subprocess.run( | ||
| ["docker", "pull", image], | ||
| check=True, | ||
| capture_output=True, |
There was a problem hiding this comment.
Another option would be to make this melange_image_outdated() check that returns True if the image is missing or out of date. We can use that to decide if we should add --pull always to the docker run command below. I think that would avoid having the 2 different docker pull code paths here.
Or, if we made it docker_image_outdated(img, age), we could re-use it for the shellcheck image as well!
Automatically checks the age of the local melange Docker image and silently pulls an updated version if it's older than 30 days.
This helps ensure users have recent melange versions with the latest features and bug fixes, such as support for the
test-resourcesfield that was added in recent versions.Changes:
check_and_update_melange_image()function that checks image creation dateThe check runs at the start of the shellcheck hook, so users get updated images without manual intervention or delays.