From c2a3d6fb2df1efa668d4e2347b5c41efccb45ddc Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Wed, 11 Nov 2026 01:31:12 +0100 Subject: [PATCH 1/3] perf(docker): reuse build digests and skip redundant setup --- ...-action-docker-create-images-manifests.yml | 93 +++++++++++++++++++ .../workflows/__test-action-docker-setup.yml | 51 ++++++++++ ...rkflow-docker-build-images-attestation.yml | 8 +- .github/workflows/docker-build-images.yml | 4 +- .../docker/create-images-manifests/README.md | 4 +- .../docker/create-images-manifests/action.yml | 76 +++++++++++---- actions/docker/setup/README.md | 10 ++ actions/docker/setup/action.yml | 8 ++ docs/README.md | 1 + ...ild-digests-and-limit-publication-setup.md | 61 ++++++++++++ 10 files changed, 292 insertions(+), 24 deletions(-) create mode 100644 docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md diff --git a/.github/workflows/__test-action-docker-create-images-manifests.yml b/.github/workflows/__test-action-docker-create-images-manifests.yml index 634b0d2b..ca71038d 100644 --- a/.github/workflows/__test-action-docker-create-images-manifests.yml +++ b/.github/workflows/__test-action-docker-create-images-manifests.yml @@ -118,6 +118,99 @@ jobs: assert.deepEqual(denied.outputs, {}); } + - name: Test publication digests and mixed batches + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const assert = require('node:assert/strict'); + const { stdout } = await exec.getExecOutput('ruby', [ + '-rjson', '-ryaml', '-e', + 'puts JSON.generate(YAML.safe_load(File.read(ARGV[0])))', + 'actions/docker/create-images-manifests/action.yml', + ]); + const action = JSON.parse(stdout); + const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; + const sourceDigest = `sha256:${'a'.repeat(64)}`; + const indexDigest = `sha256:${'b'.repeat(64)}`; + const repository = 'registry.example.com/test/application'; + const single = { + name: 'application', registry: 'registry.example.com', repository: 'test/application', + images: [`${repository}@${sourceDigest}`], digest: sourceDigest, + tags: ['test', 'latest'], annotations: { description: 'Application' }, + platforms: ['linux/amd64'], 'multi-platform': false, + }; + + async function publish(input) { + const calls = []; + let images = JSON.stringify(input); + let requiresBuildx; + for (const stepId of ['prepare-images', 'create-images-manifests', 'get-built-images-digest']) { + const script = action.runs.steps.find(step => step.id === stepId).with.script; + await new AsyncFunction('process', 'core', 'exec', script)( + { env: { INPUT_BUILT_IMAGES: images, BUILT_IMAGES_OUTPUT: images } }, + { + debug() {}, info() {}, + setOutput(name, value) { + if (name === 'built-images') images = value; + if (name === 'requires-buildx') requiresBuildx = value; + }, + }, + { getExecOutput: async (command, args) => { + calls.push([command, ...args]); + return { exitCode: 0, stdout: `Digest: ${indexDigest}`, stderr: '' }; + } }, + ); + } + return { images: JSON.parse(images), calls, requiresBuildx }; + } + + const reused = await publish({ application: single }); + assert.equal(reused.requiresBuildx, 'false'); + assert.deepEqual(reused.calls, []); + assert.deepEqual(reused.images.application, { + ...single, images: single.tags.map(tag => `${repository}:${tag}@${sourceDigest}`), + }); + + const withoutDigest = { ...single }; + delete withoutDigest.digest; + assert.deepEqual((await publish({ application: withoutDigest })).images, reused.images); + const taggedSource = { ...single, images: [`${repository}:test@${sourceDigest}`] }; + assert.deepEqual((await publish({ application: taggedSource })).images, reused.images); + + const multi = { + ...single, name: 'multi', 'multi-platform': true, + platforms: ['linux/amd64', 'linux/arm64'], + images: [`${repository}@${sourceDigest}`, `${repository}@${indexDigest}`], + }; + const mixed = await publish({ application: single, multi }); + assert.equal(mixed.requiresBuildx, 'true'); + assert.deepEqual(Object.keys(mixed.images), ['application', 'multi']); + assert.deepEqual(mixed.images.application, reused.images.application); + assert.deepEqual(mixed.images.multi, { + ...multi, digest: indexDigest, + images: single.tags.map(tag => `${repository}:${tag}@${indexDigest}`), + }); + assert.deepEqual(mixed.calls.map(call => call.slice(0, 4)), [ + ['docker', 'buildx', 'imagetools', 'create'], + ['docker', 'buildx', 'imagetools', 'inspect'], + ]); + + const tagOnly = await publish({ application: { ...single, images: [`${repository}:test`] } }); + assert.equal(tagOnly.requiresBuildx, 'true'); + assert.equal(tagOnly.images.application.digest, indexDigest); + assert.deepEqual(tagOnly.calls, [['docker', 'buildx', 'imagetools', 'inspect', `${repository}:test`]]); + const clone = await publish({ application: { ...single, 'multi-platform': true } }); + assert.equal(clone.images.application.digest, indexDigest); + assert.equal(clone.calls.length, 2); + + for (const invalid of [null, [], { application: null }, { application: { ...single, images: [] } }]) { + await assert.rejects(publish(invalid)); + } + await assert.rejects(publish({ application: { ...single, digest: indexDigest } }), /Conflicting digest/); + for (const source of [`other.example.com/test/application@${sourceDigest}`, `${repository}@sha256:invalid`]) { + await assert.rejects(publish({ application: { ...single, images: [source] } }), /Invalid immutable source/); + } + build-original-tag: name: Arrange - Build original tag uses: $/.github/workflows/docker-build-images.yml diff --git a/.github/workflows/__test-action-docker-setup.yml b/.github/workflows/__test-action-docker-setup.yml index 96e03374..c9636aaf 100644 --- a/.github/workflows/__test-action-docker-setup.yml +++ b/.github/workflows/__test-action-docker-setup.yml @@ -8,6 +8,57 @@ on: # yamllint disable-line rule:truthy permissions: {} jobs: + tests-registry-only: + name: Test registry authentication without a Docker daemon + runs-on: ubuntu-latest + permissions: + contents: read + env: + DOCKER_HOST: unix:///tmp/ci-github-container-no-daemon.sock + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Act - Authenticate without initializing Docker or Buildx + id: registry-only + uses: $/actions/docker/setup + with: + oci-registry: ghcr.io + oci-registry-username: ${{ github.repository_owner }} + oci-registry-password: ${{ github.token }} + setup-docker: false + setup-buildx: false + docker-version: "0.0.0" + + - name: Assert - Registry-only outputs + env: + PUSH_REGISTRY: ${{ steps.registry-only.outputs.push-registry }} + BUILDX_NAME: ${{ steps.registry-only.outputs.buildx-name }} + run: | + test "$PUSH_REGISTRY" = "ghcr.io" + test -z "$BUILDX_NAME" + if docker info >/dev/null 2>&1; then + echo "::error::Test requires an unreachable Docker daemon" + exit 1 + fi + + - name: Act - Reject invalid registry credentials + id: denied + continue-on-error: true + uses: $/actions/docker/setup + with: + oci-registry: ghcr.io + oci-registry-username: ${{ github.repository_owner }} + oci-registry-password: invalid-test-credential + setup-docker: false + setup-buildx: false + + - name: Assert - Authentication failure propagates + env: + LOGIN_OUTCOME: ${{ steps.denied.outcome }} + run: test "$LOGIN_OUTCOME" = "failure" + tests: name: Test for "docker/setup" action runs-on: ubuntu-latest diff --git a/.github/workflows/__test-workflow-docker-build-images-attestation.yml b/.github/workflows/__test-workflow-docker-build-images-attestation.yml index 41888a3d..3b05e640 100644 --- a/.github/workflows/__test-workflow-docker-build-images-attestation.yml +++ b/.github/workflows/__test-workflow-docker-build-images-attestation.yml @@ -60,11 +60,12 @@ jobs: }; } - function createScenario({ name, imageNames, platforms, attest }) { + function createScenario({ name, imageNames, platforms, attest, mixed = false }) { return { name, attest, - images: JSON.stringify(imageNames.map(imageName => createImageDefinition(imageName, platforms))), + images: JSON.stringify(imageNames.map((imageName, index) => + createImageDefinition(imageName, mixed && index === 1 ? ['linux/amd64', 'linux/arm64'] : platforms))), verify_images: JSON.stringify(imageNames.map(imageName => `${imageName}:${tag}`)), package_names: JSON.stringify(imageNames), }; @@ -85,7 +86,8 @@ jobs: attest: true, }), createScenario({ - name: 'multiple images - attested', + name: 'mixed platforms - attested', + mixed: true, imageNames: [ `${imageNamePrefix}-multi-image-attested-a`, `${imageNamePrefix}-multi-image-attested-b`, diff --git a/.github/workflows/docker-build-images.yml b/.github/workflows/docker-build-images.yml index e2b2058d..0e386ef9 100644 --- a/.github/workflows/docker-build-images.yml +++ b/.github/workflows/docker-build-images.yml @@ -487,8 +487,7 @@ jobs: permissions: contents: read packages: write - id-token: write # Needed for signing and attesting images - attestations: write # Needed for attesting images + id-token: write # Needed for signing images needs: [prepare-variables, build-images] runs-on: ${{ fromJson(inputs.runs-on) }} outputs: @@ -617,6 +616,7 @@ jobs: oci-registry-username: ${{ inputs.oci-registry-username }} oci-registry-password: ${{ secrets.oci-registry-password }} # zizmor: ignore[secrets-outside-env] built-images: ${{ needs.publish-manifests.outputs.built-images }} + setup-docker: false setup-buildx: false - uses: $/actions/docker/attest-image diff --git a/actions/docker/create-images-manifests/README.md b/actions/docker/create-images-manifests/README.md index 4c7f2113..034a7ac6 100644 --- a/actions/docker/create-images-manifests/README.md +++ b/actions/docker/create-images-manifests/README.md @@ -25,8 +25,8 @@ ## Overview Action to create built images manifests. -It uses the Docker Buildx plugin to create manifests for the built images. -It requires the Docker Buildx plugin to be installed and configured. +It reuses immutable single-platform build digests without inspecting tags. +It configures Docker Buildx when manifest creation or tag inspection is required. It supports creating manifests for multiple images and platforms at once. diff --git a/actions/docker/create-images-manifests/action.yml b/actions/docker/create-images-manifests/action.yml index 0c0b8bf3..66b88abb 100644 --- a/actions/docker/create-images-manifests/action.yml +++ b/actions/docker/create-images-manifests/action.yml @@ -2,8 +2,8 @@ name: "Docker - Create images manifests" description: | Action to create built images manifests. - It uses the Docker Buildx plugin to create manifests for the built images. - It requires the Docker Buildx plugin to be installed and configured. + It reuses immutable single-platform build digests without inspecting tags. + It configures Docker Buildx when manifest creation or tag inspection is required. It supports creating manifests for multiple images and platforms at once. author: hoverkraft branding: @@ -96,6 +96,59 @@ outputs: runs: using: "composite" steps: + - id: prepare-images + name: Validate images and resolve publication tooling + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + INPUT_BUILT_IMAGES: ${{ inputs.built-images }} + with: + script: | + const builtImages = JSON.parse(process.env.INPUT_BUILT_IMAGES || ''); + if (!builtImages || Array.isArray(builtImages) || typeof builtImages !== 'object') { + throw new Error('"built-images" must be a JSON object'); + } + + let requiresBuildx = false; + for (const [name, image] of Object.entries(builtImages)) { + if (!image || typeof image !== 'object' || Array.isArray(image)) { + throw new Error(`Invalid built image "${name}"`); + } + for (const field of ['registry', 'repository']) { + if (typeof image[field] !== 'string' || !image[field].trim()) { + throw new Error(`Missing "${field}" for "${name}"`); + } + } + for (const field of ['images', 'tags']) { + if (!Array.isArray(image[field]) || !image[field].length || + image[field].some(value => typeof value !== 'string' || !value.trim())) { + throw new Error(`Expected non-empty "${field}" for "${name}"`); + } + } + + const previousDigest = image.digest; + delete image.digest; + if (!image['multi-platform'] && Array.isArray(image.platforms) && + image.platforms.length === 1 && image.images.length === 1) { + const source = image.images[0]; + const [reference, digest] = source.split('@'); + const repository = `${image.registry}/${image.repository}`; + if (source.includes('@')) { + if (source.split('@').length !== 2 || !/^sha256:[a-f0-9]{64}$/.test(digest) || + (reference !== repository && !reference.startsWith(`${repository}:`))) { + throw new Error(`Invalid immutable source for "${name}": ${source}`); + } + if (previousDigest !== undefined && previousDigest !== digest) { + throw new Error(`Conflicting digest for "${name}"`); + } + image.digest = digest; + } + } + requiresBuildx ||= !image.digest; + } + + core.setOutput('built-images', JSON.stringify(builtImages)); + core.setOutput('requires-buildx', String(requiresBuildx)); + - id: docker-setup uses: $/actions/docker/setup with: @@ -103,12 +156,14 @@ runs: oci-registry-username: ${{ inputs.oci-registry-username }} oci-registry-password: ${{ inputs.oci-registry-password }} built-images: ${{ inputs.built-images }} + setup-docker: ${{ steps.prepare-images.outputs.requires-buildx }} + setup-buildx: ${{ steps.prepare-images.outputs.requires-buildx }} - id: create-images-manifests name: Create images manifests and push uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: - INPUT_BUILT_IMAGES: ${{ inputs.built-images }} + INPUT_BUILT_IMAGES: ${{ steps.prepare-images.outputs.built-images }} with: script: | const builtImagesInput = process.env.INPUT_BUILT_IMAGES || ""; @@ -119,13 +174,6 @@ runs: throw new Error(`"built-images" input is not a valid JSON: ${error}`); } - // Helper function to validate image data - function validateImage(builtImage) { - if (!builtImage.images || builtImage.images.length === 0) { - throw new Error(`No images found for "${builtImage.name}"`); - } - } - // Helper function to create multiarch manifest async function createMultiarchManifest(builtImage, imagesWithTags) { const platformArgs = builtImage.platforms.flatMap(platform => ["--platform", platform]); @@ -230,12 +278,6 @@ runs: new Promise((resolve) => setTimeout(resolve, delayMs)); const getImageDigest = async function(image) { - // Check if the image already has a digest - if (image.match(/@/)) { - core.debug(`Image "${image}" already has a digest, skipping inspection.`); - return image; - } - const inspectImageArgs = ["buildx", "imagetools", "inspect", image]; const inspectImageCommand = `docker ${inspectImageArgs.join(" ")}`; core.debug(`Inspecting image "${image}" with command: "${inspectImageCommand}"`); @@ -305,7 +347,7 @@ runs: await Promise.all(Object.keys(builtImages).map(async (imageName) => { const builtImage = builtImages[imageName]; - const digest = await getImageDigest(builtImage.images[0]); + const digest = builtImage.digest || await getImageDigest(builtImage.images[0]); // Update built image with the digest builtImage.digest = digest; diff --git a/actions/docker/setup/README.md b/actions/docker/setup/README.md index e72b7a3e..0fda1e78 100644 --- a/actions/docker/setup/README.md +++ b/actions/docker/setup/README.md @@ -63,6 +63,13 @@ Shared action to configure Docker tooling and OCI registry authentication. # When provided, registry authentication targets are inferred from the built image data. built-images: "" + # Whether to detect and install the configured Docker client and daemon. + # Set this and `setup-buildx` to `false` for registry authentication only. + # Registry authentication requires an existing Docker CLI, but no running daemon. + # + # Default: `true` + setup-docker: true + # Whether to install and configure Docker Buildx. # # Default: `true` @@ -105,6 +112,9 @@ Shared action to configure Docker tooling and OCI registry authentication. | |
[registry."my-registry.local:5000"]
 http = true
 insecure = true
| | | | **`built-images`** | Optional built images payload used to resolve manifest publication registries. | **false** | - | | | When provided, registry authentication targets are inferred from the built image data. | | | +| **`setup-docker`** | Whether to detect and install the configured Docker client and daemon. | **false** | `true` | +| | Set this and `setup-buildx` to `false` for registry authentication only. | | | +| | Registry authentication requires an existing Docker CLI, but no running daemon. | | | | **`setup-buildx`** | Whether to install and configure Docker Buildx. | **false** | `true` | | **`docker-version`** | Required Docker version. The action installs it when the active Docker client or daemon reports a different version. | **false** | `29.7.2` | | | When `DOCKER_HOST` is set, the Docker daemon is managed outside of the runner (e.g. a Docker-in-Docker sidecar) and is kept as is. | | | diff --git a/actions/docker/setup/action.yml b/actions/docker/setup/action.yml index 1fef01a3..634d666e 100644 --- a/actions/docker/setup/action.yml +++ b/actions/docker/setup/action.yml @@ -40,6 +40,13 @@ inputs: Optional built images payload used to resolve manifest publication registries. When provided, registry authentication targets are inferred from the built image data. required: false + setup-docker: + description: | + Whether to detect and install the configured Docker client and daemon. + Set this and `setup-buildx` to `false` for registry authentication only. + Registry authentication requires an existing Docker CLI, but no running daemon. + default: true + required: false setup-buildx: description: | Whether to install and configure Docker Buildx. @@ -398,6 +405,7 @@ runs: }); - id: detect-docker + if: inputs.setup-docker != 'false' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: EXPECTED_DOCKER_VERSION: ${{ inputs.docker-version }} diff --git a/docs/README.md b/docs/README.md index 7164dccd..d49aeae0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,3 +5,4 @@ - [Publishing releases](development/releases.md) - [Keyless OCI Helm signatures](adr/0001-sign-oci-helm-charts-with-keyless-cosign.md) - [Chart release distribution decision](adr/0002-bundle-chart-release-dependencies.md) +- [Publication setup and build digest reuse](adr/0003-reuse-build-digests-and-limit-publication-setup.md) diff --git a/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md new file mode 100644 index 00000000..e095efc6 --- /dev/null +++ b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md @@ -0,0 +1,61 @@ +# Reuse build digests and limit publication setup + +Date: 2026-11-11 + +Status: Proposed + +## Context + +Single-platform builds already push their tags and return an immutable digest. +Manifest publication currently replaces those references with tags, initializes +Docker and Buildx, and inspects the tags again. Signing uses cosign and attestation +uses actions/attest; both need registry credentials, but neither needs a Docker +daemon. Attestation jobs still initialize one. + +## Decision + +Validate publication inputs before setup. Reuse the digest of an unambiguous +single-platform source from the expected registry/repository. Reject conflicting +digest metadata. Preserve image keys, metadata and tag ordering in the output. +Keep registry inspection for tag-only inputs, and manifest creation and inspection +for multi-platform inputs, including explicit tag cloning. Never reuse a platform +digest as the digest of an assembled index. + +Add an opt-out for Docker installation to the existing setup action. Defaults +retain the build toolchain contract. Registry-only callers disable both Docker +and Buildx setup and use the runner's Docker CLI for login. Authentication and +logout continue through docker/login-action with the existing credential routing. +Multi-platform or tag-inspection batches retain the configured Docker/Buildx setup. + +Keep signing and attestation in their existing jobs. Build jobs gain no OIDC or +attestation permissions. Publication needs OIDC for signing; only the attestation +job needs permission to write attestations. + +## Alternatives and consequences + +Extracting another authentication action would move the same resolver without +improving this change. Removing setup everywhere would depend on the runner's +Buildx version and weaken the multi-platform toolchain contract. Re-inspecting +single-platform tags adds registry requests and can observe a concurrent tag move; +using the build digest preserves the artifact that was actually built. + +Registry-only callers require an existing Docker CLI and credential helpers. +They do not require a reachable daemon. Public single-platform inputs without an +immutable source retain their registry-inspection path. Cache behavior and build +ordering are unchanged. Reverting the action pin restores previous behavior. + +## Validation requirements + +Cover single-platform digest reuse, conflicting metadata, tag-only inputs, mixed +batches, multi-platform index digests, metadata ordering, registry visibility +retries and authentication failures. Exercise registry-only setup with an +unreachable daemon. Run the existing platform, signature and attestation +integration workflows and compare publication/setup timings. Record actual +measurements here after CI, without committing raw logs. + +## References + +- [Pleey CI optimization plan, P2.3](https://github.com/cloud-native-aixmarseille/pleey/blob/ci/475-p1-local-reductions/docs/technical/plans/0023-optimize-ci-execution-and-caching.md#p23-remove-redundant-publicationsecurity-setup) +- [Docker registry credentials](https://docs.docker.com/reference/cli/docker/login/) +- [Cosign container signing](https://docs.sigstore.dev/cosign/signing/signing_with_containers/) +- [GitHub artifact attestations](https://github.com/actions/attest) From 72c146d5357dfa17e44b420229e0998fa33b27c3 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Wed, 11 Nov 2026 01:42:00 +0100 Subject: [PATCH 2/3] fix(docker): validate tags before reusing build digests --- ...-action-docker-create-images-manifests.yml | 8 ++- .../docker/create-images-manifests/action.yml | 7 ++- ...ild-digests-and-limit-publication-setup.md | 50 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/.github/workflows/__test-action-docker-create-images-manifests.yml b/.github/workflows/__test-action-docker-create-images-manifests.yml index ca71038d..f714632d 100644 --- a/.github/workflows/__test-action-docker-create-images-manifests.yml +++ b/.github/workflows/__test-action-docker-create-images-manifests.yml @@ -207,7 +207,13 @@ jobs: await assert.rejects(publish(invalid)); } await assert.rejects(publish({ application: { ...single, digest: indexDigest } }), /Conflicting digest/); - for (const source of [`other.example.com/test/application@${sourceDigest}`, `${repository}@sha256:invalid`]) { + for (const tag of ['bad tag', 'bad@tag', '-invalid', 'a'.repeat(129)]) { + await assert.rejects(publish({ application: { ...single, tags: [tag] } }), /Invalid tag/); + } + for (const source of [ + `other.example.com/test/application@${sourceDigest}`, `${repository}@sha256:invalid`, + `${repository}:@${sourceDigest}`, `${repository}:bad tag@${sourceDigest}`, + ]) { await assert.rejects(publish({ application: { ...single, images: [source] } }), /Invalid immutable source/); } diff --git a/actions/docker/create-images-manifests/action.yml b/actions/docker/create-images-manifests/action.yml index 66b88abb..cb26c848 100644 --- a/actions/docker/create-images-manifests/action.yml +++ b/actions/docker/create-images-manifests/action.yml @@ -108,6 +108,7 @@ runs: throw new Error('"built-images" must be a JSON object'); } + const tagPattern = /^[\w][\w.-]{0,127}$/; let requiresBuildx = false; for (const [name, image] of Object.entries(builtImages)) { if (!image || typeof image !== 'object' || Array.isArray(image)) { @@ -124,6 +125,9 @@ runs: throw new Error(`Expected non-empty "${field}" for "${name}"`); } } + if (image.tags.some(tag => !tagPattern.test(tag))) { + throw new Error(`Invalid tag for "${name}"`); + } const previousDigest = image.digest; delete image.digest; @@ -132,9 +136,10 @@ runs: const source = image.images[0]; const [reference, digest] = source.split('@'); const repository = `${image.registry}/${image.repository}`; + const sourceTag = reference.startsWith(`${repository}:`) ? reference.slice(repository.length + 1) : ''; if (source.includes('@')) { if (source.split('@').length !== 2 || !/^sha256:[a-f0-9]{64}$/.test(digest) || - (reference !== repository && !reference.startsWith(`${repository}:`))) { + (reference !== repository && !tagPattern.test(sourceTag))) { throw new Error(`Invalid immutable source for "${name}": ${source}`); } if (previousDigest !== undefined && previousDigest !== digest) { diff --git a/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md index e095efc6..25a1c3a8 100644 --- a/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md +++ b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md @@ -53,6 +53,56 @@ unreachable daemon. Run the existing platform, signature and attestation integration workflows and compare publication/setup timings. Record actual measurements here after CI, without committing raw logs. +## Validation and timing observations, 2026-11-11 + +The local publication checks cover digest reuse with and without a separate +digest field, tagged immutable sources, mixed batches, tag-only inspection, +explicit cloning, conflicting digests and malformed inputs. Registry retry +checks retain their bounded backoff and immediate authentication-error failures. +Super-Linter passed, and the action readmes were regenerated with CI Dokumentor. +Existing inputs/outputs, job dependencies and build/attestation permissions were +compared with main; only the documented setup input and publication permission +reduction change those contracts. + +The first candidate is +[`c2a3d6f`](https://github.com/hoverkraft-tech/ci-github-container/commit/c2a3d6fb2df1efa668d4e2347b5c41efccb45ddc), +[CI run 42932049090](https://github.com/hoverkraft-tech/ci-github-container/actions/runs/42932049090). +All 167 executed jobs passed; 10 jobs were intentionally skipped. The run verified +single/multi-platform manifests, signed images, mixed-platform attestations and +registry authentication with an unreachable daemon, including invalid credentials. +Compare its platform/signing matrix with the previous passing main run at +[`ec1cd96`](https://github.com/hoverkraft-tech/ci-github-container/commit/ec1cd960fb1a1908ac21680756eb49a4c8f018d5), +[CI run 42894339060](https://github.com/hoverkraft-tech/ci-github-container/actions/runs/42894339060). +The following values are medians with minimum–maximum ranges, in seconds. + +| Operation | Previous action | Candidate action | Previous job | Candidate job | +| --------------------------- | --------------: | ---------------: | -----------: | ------------: | +| Single-platform publication | 19.5 (17–29) | 1 (1–1) | 34.5 (31–54) | 12.5 (8–16) | +| Multi-platform publication | 23 (23–23) | 23.5 (19–25) | 44 (39–49) | 40 (38–48) | +| Attestation registry setup | 12.5 (12–13) | 1 (1–2) | 27.5 (27–32) | 13.5 (12–16) | + +Each publication row contains the four sign/attest combinations from one run. +The attestation row contains the four enabled attestation jobs. These are +different scenarios within a run, not repeated controlled workflow samples. +Action duration excludes its post step; whole-job duration includes setup, +signing/attestation and cleanup, but excludes runner queue time. Median publication +cleanup fell from 6 to 0 seconds for single-platform jobs and stayed at 6 seconds +for multi-platform jobs. Attestation setup cleanup fell from 5 to 0 seconds. +API timestamps have one-second resolution; zero does not mean no work. + +The inspected single-platform logs used runner 2.338.2 and Ubuntu 26.04 image +20261101.186.1 in different Azure regions. The baseline is a main event and the +candidate is a PR event, with different tags and build identities. The mixed +attestation scenario also adds a platform build, so whole-run totals are not +comparable. These observations support removing setup overhead; they do not +establish a controlled end-to-end improvement for Pleey. Action downloads still +occur even when runtime setup is skipped. + +The final revision adds rejection of malformed tags to the measured candidate. +Its local contract and lint checks passed separately. No build, cache or +publication operation was added for valid inputs. Downstream adoption and its +full-workflow comparison follow upstream review and release. + ## References - [Pleey CI optimization plan, P2.3](https://github.com/cloud-native-aixmarseille/pleey/blob/ci/475-p1-local-reductions/docs/technical/plans/0023-optimize-ci-execution-and-caching.md#p23-remove-redundant-publicationsecurity-setup) From e748db94e416488d796e45801151b1c853440662 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Wed, 11 Nov 2026 01:45:24 +0100 Subject: [PATCH 3/3] fix(docker): retain setup when registry runners lack the CLI --- .../workflows/__test-action-docker-setup.yml | 24 +++++++++++++++++++ actions/docker/setup/README.md | 10 ++++---- actions/docker/setup/action.yml | 14 +++++++---- ...ild-digests-and-limit-publication-setup.md | 22 ++++++++++------- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/.github/workflows/__test-action-docker-setup.yml b/.github/workflows/__test-action-docker-setup.yml index c9636aaf..24afdac6 100644 --- a/.github/workflows/__test-action-docker-setup.yml +++ b/.github/workflows/__test-action-docker-setup.yml @@ -31,6 +31,30 @@ jobs: setup-buildx: false docker-version: "0.0.0" + - name: Assert - Registry-only CLI reuse and installation fallback + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const assert = require('node:assert/strict'); + const { stdout } = await exec.getExecOutput('ruby', [ + '-rjson', '-ryaml', '-e', + 'puts JSON.generate(YAML.safe_load(File.read(ARGV[0])))', + 'actions/docker/setup/action.yml', + ]); + const action = JSON.parse(stdout); + const script = action.runs.steps.find(step => step.id === 'detect-docker').with.script; + const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; + for (const dockerPath of ['/usr/bin/docker', '']) { + const outputs = {}; + await new AsyncFunction('process', 'io', 'core', 'exec', script)( + { env: { SETUP_DOCKER: 'false', EXPECTED_DOCKER_VERSION: 'test-version' } }, + { which: async () => dockerPath }, + { info() {}, setOutput: (name, value) => { outputs[name] = value; } }, + { getExecOutput: async () => { assert.fail('Registry-only setup must not contact the daemon'); } }, + ); + assert.deepEqual(outputs, dockerPath ? {} : { 'docker-install-version': 'test-version' }); + } + - name: Assert - Registry-only outputs env: PUSH_REGISTRY: ${{ steps.registry-only.outputs.push-registry }} diff --git a/actions/docker/setup/README.md b/actions/docker/setup/README.md index 0fda1e78..83390525 100644 --- a/actions/docker/setup/README.md +++ b/actions/docker/setup/README.md @@ -63,9 +63,10 @@ Shared action to configure Docker tooling and OCI registry authentication. # When provided, registry authentication targets are inferred from the built image data. built-images: "" - # Whether to detect and install the configured Docker client and daemon. + # Whether to enforce the configured Docker client and daemon versions. # Set this and `setup-buildx` to `false` for registry authentication only. - # Registry authentication requires an existing Docker CLI, but no running daemon. + # When disabled, reuse an existing Docker CLI without contacting its daemon. + # If the CLI is missing, install the configured Docker version so authentication remains available. # # Default: `true` setup-docker: true @@ -112,9 +113,10 @@ Shared action to configure Docker tooling and OCI registry authentication. | |
[registry."my-registry.local:5000"]
 http = true
 insecure = true
| | | | **`built-images`** | Optional built images payload used to resolve manifest publication registries. | **false** | - | | | When provided, registry authentication targets are inferred from the built image data. | | | -| **`setup-docker`** | Whether to detect and install the configured Docker client and daemon. | **false** | `true` | +| **`setup-docker`** | Whether to enforce the configured Docker client and daemon versions. | **false** | `true` | | | Set this and `setup-buildx` to `false` for registry authentication only. | | | -| | Registry authentication requires an existing Docker CLI, but no running daemon. | | | +| | When disabled, reuse an existing Docker CLI without contacting its daemon. | | | +| | If the CLI is missing, install the configured Docker version so authentication remains available. | | | | **`setup-buildx`** | Whether to install and configure Docker Buildx. | **false** | `true` | | **`docker-version`** | Required Docker version. The action installs it when the active Docker client or daemon reports a different version. | **false** | `29.7.2` | | | When `DOCKER_HOST` is set, the Docker daemon is managed outside of the runner (e.g. a Docker-in-Docker sidecar) and is kept as is. | | | diff --git a/actions/docker/setup/action.yml b/actions/docker/setup/action.yml index 634d666e..05b50379 100644 --- a/actions/docker/setup/action.yml +++ b/actions/docker/setup/action.yml @@ -42,9 +42,10 @@ inputs: required: false setup-docker: description: | - Whether to detect and install the configured Docker client and daemon. + Whether to enforce the configured Docker client and daemon versions. Set this and `setup-buildx` to `false` for registry authentication only. - Registry authentication requires an existing Docker CLI, but no running daemon. + When disabled, reuse an existing Docker CLI without contacting its daemon. + If the CLI is missing, install the configured Docker version so authentication remains available. default: true required: false setup-buildx: @@ -405,19 +406,24 @@ runs: }); - id: detect-docker - if: inputs.setup-docker != 'false' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: EXPECTED_DOCKER_VERSION: ${{ inputs.docker-version }} + SETUP_DOCKER: ${{ inputs.setup-docker }} with: script: | + const dockerPath = await io.which('docker', false); + if (process.env.SETUP_DOCKER === 'false' && dockerPath) { + core.info('Reusing the Docker CLI for registry authentication without checking its daemon'); + return; + } + const requestedDockerVersion = `${process.env.EXPECTED_DOCKER_VERSION || ''}`.trim(); if (!requestedDockerVersion.length) { throw new Error('"docker-version" input must not be empty'); } const expectedDockerVersion = requestedDockerVersion.replace(/^v(?=\d)/, ''); - const dockerPath = await io.which('docker', false); if (dockerPath) { try { const { stdout } = await exec.getExecOutput( diff --git a/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md index 25a1c3a8..e0e2d219 100644 --- a/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md +++ b/docs/adr/0003-reuse-build-digests-and-limit-publication-setup.md @@ -21,9 +21,11 @@ Keep registry inspection for tag-only inputs, and manifest creation and inspecti for multi-platform inputs, including explicit tag cloning. Never reuse a platform digest as the digest of an assembled index. -Add an opt-out for Docker installation to the existing setup action. Defaults -retain the build toolchain contract. Registry-only callers disable both Docker -and Buildx setup and use the runner's Docker CLI for login. Authentication and +Add an opt-out for Docker version enforcement to the existing setup action. +Defaults retain the build toolchain contract. Registry-only callers disable both +Docker and Buildx setup and reuse the runner's Docker CLI without contacting its +daemon. If no CLI is available, retain the installation fallback so existing +custom runners remain supported. Authentication and logout continue through docker/login-action with the existing credential routing. Multi-platform or tag-inspection batches retain the configured Docker/Buildx setup. @@ -39,8 +41,9 @@ Buildx version and weaken the multi-platform toolchain contract. Re-inspecting single-platform tags adds registry requests and can observe a concurrent tag move; using the build digest preserves the artifact that was actually built. -Registry-only callers require an existing Docker CLI and credential helpers. -They do not require a reachable daemon. Public single-platform inputs without an +Registry-only callers with an existing Docker CLI and credential helpers do not +require a reachable daemon. Runners without the CLI retain the installer's +existing requirements. Public single-platform inputs without an immutable source retain their registry-inspection path. Cache behavior and build ordering are unchanged. Reverting the action pin restores previous behavior. @@ -98,10 +101,11 @@ comparable. These observations support removing setup overhead; they do not establish a controlled end-to-end improvement for Pleey. Action downloads still occur even when runtime setup is skipped. -The final revision adds rejection of malformed tags to the measured candidate. -Its local contract and lint checks passed separately. No build, cache or -publication operation was added for valid inputs. Downstream adoption and its -full-workflow comparison follow upstream review and release. +The final revision rejects malformed tags and preserves Docker installation when +a custom runner has no CLI. Registry-only setup checks for the executable before +returning, without contacting an existing daemon. Contract tests cover both paths. +Downstream adoption and its full-workflow comparison follow upstream review and +release. ## References