feat(image-tag-cleanup): add pure ephemeral-tag selection logic - #76
Merged
Merged
Conversation
Foundation for deleting old commit-tagged images (trunk-ci-cd.yml publishes a new one on every merge to main, with nothing to bound how many accumulate). select-deletions.sh is pure decision logic with no registry calls: given a JSON list of tag/version records, it decides which are safe to delete. Safety guarantee, tested: an entry is only ever a candidate when EVERY tag it carries matches ephemeral_tag_prefix. A stable release, :latest, :edge, or a legacy alpha/beta/rc tag never matches, so it's never even considered, regardless of retention_days/keep_min. 9/9 tests cover this plus the keep_min floor and retention_days trigger. This lands as its own foundation slice (currently unused — wiring it into Docker Hub/GHCR cleanup follows in the next PR) to keep each review focused.
4 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
First of two PRs implementing image tag retention (see design.md D9, added in the next PR).
trunk-ci-cd.ymlpublishes a new, uniquely-tagged image on every merge tomain, with no branch-per-channel boundary to bound how many accumulate — this is the foundation for cleaning those up.select-deletions.shis pure decision logic, zero registry calls: given a JSON list of tag/version records on stdin, it decides which are safe to delete. It's unused by anything yet — the Docker Hub/GHCR wiring that calls it lands in the follow-up PR — but it's fully self-contained and independently testable.Safety guarantee: an entry is only ever a deletion candidate when every tag it carries matches
ephemeral_tag_prefix. A stable release,:latest,:edge, or a legacy:alpha/:beta/:X.Y.Z-alpha.Ntag never matches, so it's never even considered — this holds regardless ofretention_days/keep_min.Chain Context
mainChain Overview
Test plan
tests/image-tag-cleanup-select.test.sh— 9/9 passing (empty input, non-ephemeral tag protected, mixed-tag entry protected, untagged entry protected, keep_min floor respected, retention_days trigger, custom prefix, GHCR-shaped numeric id)shellcheckcleanactionlintclean ontest.yml