diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1be5c0b3e..a7aaf6780 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,8 @@ name: Docker on: + push: + branches: [main] workflow_call: inputs: version: @@ -166,6 +168,31 @@ jobs: mkdir -p "${RUNNER_TEMP}/digests" touch "${RUNNER_TEMP}/digests/${digest#sha256:}" + # Smoke-test the built image before recording its digest. If the + # Python ABI is wrong (e.g. builder Python 3.11 vs distroless + # Python 3.13) pydantic_core._pydantic_core fails to dlopen and + # the import raises ModuleNotFoundError. Catching it here prevents + # a broken digest from reaching the manifest merge job and being + # tagged and published. Both python-slim and distroless variants + # expose python3 in PATH and honour the image's PYTHONPATH env. + - name: Smoke-test image (pydantic_core + headroom._core) + env: + IMAGE: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }} + DIGEST: ${{ steps.digest.outputs.digest }} + PLATFORM: ${{ matrix.arch.platform }} + run: | + docker run --rm \ + --platform "$PLATFORM" \ + --entrypoint python3 \ + "${IMAGE}@${DIGEST}" \ + -c " + import pydantic_core + from headroom._core import DiffCompressor, SmartCrusher + print('smoke-test OK: pydantic_core', pydantic_core.__version__, + '| DiffCompressor', DiffCompressor.__name__, + '| SmartCrusher', SmartCrusher.__name__) + " + - name: Upload digest marker uses: actions/upload-artifact@v7 with: @@ -255,6 +282,7 @@ jobs: tags: | type=ref,event=branch,enable=${{ inputs.enable_ref_tags != 'false' && github.event_name != 'release' }},suffix=${{ matrix.variant.name != '' && format('-{0}', matrix.variant.name) || '' }} type=ref,event=pr,enable=${{ inputs.enable_ref_tags != 'false' && github.event_name != 'release' }},suffix=${{ matrix.variant.name != '' && format('-{0}', matrix.variant.name) || '' }} + type=raw,value=dev,enable=${{ inputs.enable_ref_tags != 'false' && github.event_name == 'push' }},suffix=${{ matrix.variant.name != '' && format('-{0}', matrix.variant.name) || '' }} type=raw,value=${{ steps.version.outputs.version }},enable=${{ steps.version.outputs.version != '' }},suffix=${{ matrix.variant.name != '' && format('-{0}', matrix.variant.name) || '' }} type=raw,value=${{ steps.version.outputs.version }}-${{ steps.short-sha.outputs.sha }},enable=${{ steps.version.outputs.version != '' && matrix.variant.name == '' }} type=raw,value=${{ steps.version.outputs.version }}-${{ matrix.variant.name }}-${{ steps.short-sha.outputs.sha }},enable=${{ steps.version.outputs.version != '' && matrix.variant.name != '' }}