A merge publishes the image its PR built, the same digest, instead of building it again (PIPT-56) #212
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
queue
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/pipeline-templates!212
Loading…
Reference in a new issue
No description provided.
Delete branch "image-reuse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work package: https://openproject.home.romaine.life/wp/PIPT-56
The web-image and cluster-image paths built the image on the PR for its check and again on the merge (crenellation: 46 s). PIPT-53's reuse convention now covers those images: a merge publishes exactly the image its PR built, the same digest, under the release tag.
What changes:
release-versionwithout publishing, as the release suite's scope does) and attestsCI_IMAGE_V1 {head, fingerprint}in its own log (cluster-service/prior-image.mjs attest). The fingerprint is the Dockerfile,.dockerignore, what the Dockerfile copies, the build context and image name, the stamped version, and the pipeline-templates filesimage.mjsruns (followed asprior-build.mjsfollows a release build's, without the files that only carry the image).check-imagebuilds with that tag asAPP_VERSION(crenellation bakes it into its bundle), runs the self-test, thendocker saves the image with its ID into.ci-image/, uploaded as the run'scheck-imageartifact for a week.image.mjs publish, afterrelease-versionreserved the tag, looks through the merged PR's runs of the same suite for one whose scope attested the same fingerprint, whosecheck-imagepassed and whose image is still kept; it downloads it,docker loads it, checks the loaded ID is the one the PR recorded, pushes it under the tag, and checks the pushed digest is that ID (the runners' containerd image store makes an image's ID its push digest). No match, or any failure finding or loading it, builds as before.prior-build.mjsexports its PR-run lookup, log attestation (with its marker as a parameter) and script follower (with files to skip), unchanged for releases.Left alone: a release suite's joined image (spotify-player, tuimail, auth), which keeps its own path. An image whose Dockerfile declares
ARG SOURCE_SHA(landing-page) is still built on the merge, since only the merge knows its commit.Proof (comments below): a real merged PR on crenellation (web-image) and on nelsong6/avatars (cluster-image) through
CI_SUITES_REF, where the merge's published digest equals the PR build's and nothing builds on the merge.cluster-image proof, nelsong6/avatars through
CI_SUITES_REF=image-reuse(PR, merged):CI_IMAGE_V1for the tag its merge would take (v0.1.7);check-imagebuiltsha256:2e8432d69f39e1fcd5cd0a65d36f52b0dd0d75f588c99c54dd68266dd55221fd, ran its self-test and kept it (artifactcheck-image, 8.5 MB).forgejo.romaine.life/nelsong6/avatars:v0.1.7@sha256:2e8432d69f39e1fcd5cd0a65d36f52b0dd0d75f588c99c54dd68266dd55221fd, the PR build's digest; nodocker buildran. The pin PR it opened merged, so main pins that digest. The merge's run took 23 s, against 15 s for the last release that built (a small Go image whose build hits the runner's cache).web-image proof, romaine-life/crenellation through
CI_SUITES_REF=image-reuse(PR, merged):CI_IMAGE_V1for v0.1.10;check-imagebuilt withAPP_VERSION=v0.1.10(baked into the bundle) assha256:18c9c76f712a1f51630100a63bc868927cf721fc1c1eb8713154809069299762and kept it (80 MB).romainecr.azurecr.io/crenellation:v0.1.10@sha256:18c9c76f712a1f51630100a63bc868927cf721fc1c1eb8713154809069299762, the PR build's digest; nodocker buildran. The whole merge run took 39 s, against 60 s for v0.1.9's, which built.(The PR's 25-minute check-test ran every package because this branch predates the per-package scoping in #211.)
merge-queue stopped this at
31059d7: conflicts with main. Push a fix, or once it is fixed outside this pull request, remove and re-add thequeuelabel.