diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index 84a5906..39852db 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -1,7 +1,8 @@ name: Molecule image -# Builds images/molecule-ubuntu2404 with kaniko (osscontainertools fork, v1.28.6) and -# pushes it to git.rkdr.net/mortis/molecule-ubuntu2404 (ADR 0004, Image distribution). +# Builds the images under images/ with kaniko (osscontainertools fork, v1.28.6) and +# pushes them to git.rkdr.net/mortis/ (ADR 0004, Image distribution): the molecule +# test target (molecule-ubuntu2404) and the lint/build tooling (ci). # # Never on pull_request: a workflow file comes from the PR head, so a fork PR could # otherwise push to the registry. This workflow has no pull_request trigger, and the job @@ -30,7 +31,10 @@ on: # yamllint disable-line rule:truthy branches: - main paths: - - 'images/molecule-ubuntu2404/**' + - 'images/**' + # The ci image bakes these two files' contents in (images/ci/Dockerfile). + - 'requirements-dev.txt' + - '.pre-commit-config.yaml' - '.gitea/workflows/image.yml' tags: - 'v*' @@ -53,13 +57,26 @@ jobs: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) runs-on: kamino-docker timeout-minutes: 45 + # One job at a time on the single-capacity runner. An empty subpath means the + # repository root is the build context. + strategy: + fail-fast: false + max-parallel: 1 + matrix: + include: + - name: molecule-ubuntu2404 + subpath: images/molecule-ubuntu2404 + dockerfile: Dockerfile + - name: ci + subpath: "" + dockerfile: images/ci/Dockerfile container: image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac # Keeps a runaway build from taking the whole 3 GB runner LXC down with it. options: --memory=2g --memory-swap=2g env: DEBIAN_FRONTEND: noninteractive - IMAGE_PATH: mortis/molecule-ubuntu2404 + IMAGE_PATH: mortis/${{ matrix.name }} steps: # A tag becomes the image tag. OCI tags cannot contain '+' (semver build metadata), # and the trigger glob `v*` also matches names like `vfoo`: refuse both before @@ -218,6 +235,8 @@ jobs: REF: ${{ github.ref }} REF_NAME: ${{ github.ref_name }} SHA: ${{ github.sha }} + SUBPATH: ${{ matrix.subpath }} + DOCKERFILE: ${{ matrix.dockerfile }} run: | set +x set -eu @@ -235,7 +254,10 @@ jobs: esac # Context: this commit of this repository, cloned by kaniko (##: - # clone , check out ). The Dockerfile has no COPY, so only it is read. + # clone , check out ). With a sub-path only that directory is the + # context (molecule image: its Dockerfile has no COPY). + ctx=(--dockerfile "$DOCKERFILE") + if [ -n "$SUBPATH" ]; then ctx+=(--context-sub-path "$SUBPATH"); fi # # When it finishes the executor has replaced the job container's filesystem with # the built image and removed /kaniko, so nothing written there (a --digest-file, @@ -250,8 +272,7 @@ jobs: esac done < <(/kaniko/executor \ --context "git://${registry}/${REPO}.git#${REF}#${SHA}" \ - --context-sub-path images/molecule-ubuntu2404 \ - --dockerfile Dockerfile \ + "${ctx[@]}" \ "${dests[@]}" \ --snapshot-mode=redo \ --cache=false \ @@ -267,7 +288,7 @@ jobs: echo "Pinned reference: ${image}@${digest}" if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then { - echo "### molecule-ubuntu2404 pushed" + echo "### ${IMAGE_PATH} pushed" echo echo "Pin it by digest: \`${image}@${digest}\`" } >> "$GITHUB_STEP_SUMMARY" || true