G1: shared CI tools image (prepared, not yet built in CI)
Add images/ci-tools: one image with ansible 14.6.0 (core 2.21.6), ansible-lint, yamllint, helm 3.22.1, kubeconform, actionlint, hadolint, gitleaks and node 24 for JavaScript actions. Python tools are pinned in requirements.txt; binaries are pinned by version and the SHA-256 from each release's checksum file. VERSION starts at 1.0.0. Add a manual-only ci-tools-image workflow that builds and smoke-tests the image, and publishes an immutable version tag only when Eric enables CI_TOOLS_PUBLISH and adds a registry token (after S8 and P1). A sample job then uses the published image as its container. Tested on the workstation: image builds, every tool reports its pinned version, hadolint/actionlint pass on the new files, and syntax-check passes for gitea.yaml, ci-runner.yaml and prometheus.yaml inside it. Refs DevOps/software-infrastructure#49 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
# Build, smoke-test and (once allowed) publish the shared CI tools image.
|
||||
# DevOps/software-infrastructure#49 (G1). Source: images/ci-tools/.
|
||||
#
|
||||
# Manual-only for now: the shared runner is still being stabilised (S3-S8,
|
||||
# #36-#41), so this must not start on every push. After S8 passes, add:
|
||||
#
|
||||
# push:
|
||||
# branches: [main]
|
||||
# paths: ["images/ci-tools/**", ".gitea/workflows/ci-tools-image.yaml"]
|
||||
#
|
||||
# Publishing also needs P1 (#61) and two settings Eric creates on this repo:
|
||||
# variable CI_TOOLS_PUBLISH = "true"
|
||||
# secret REGISTRY_TOKEN = a token with write:package for the publishing user
|
||||
# variable REGISTRY_USER = that user's name
|
||||
# Without them the publish and sample jobs are skipped and nothing is pushed.
|
||||
|
||||
name: ci-tools-image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ci-tools-image-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
IMAGE: gitea.eom.dev/devops/ci-tools
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- name: Read version
|
||||
id: version
|
||||
run: |
|
||||
version="$(tr -d '[:space:]' < images/ci-tools/VERSION)"
|
||||
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||
echo "::error::images/ci-tools/VERSION must be MAJOR.MINOR.PATCH, got '$version'"
|
||||
exit 1
|
||||
fi
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# The build context is sent over the Docker API, so this works even
|
||||
# though the runner's Docker daemon can't see the job's files.
|
||||
- name: Build
|
||||
run: docker build -t "ci-tools:ci-${{ github.run_id }}" images/ci-tools
|
||||
|
||||
- name: Smoke test (every tool present at its pinned version)
|
||||
run: docker run --rm "ci-tools:ci-${{ github.run_id }}" ci-tools-versions
|
||||
|
||||
- name: Lint the image's own Dockerfile with the image
|
||||
run: docker run --rm -i "ci-tools:ci-${{ github.run_id }}" hadolint - < images/ci-tools/Dockerfile
|
||||
|
||||
- name: Clean up
|
||||
if: always()
|
||||
run: docker image rm "ci-tools:ci-${{ github.run_id }}" >/dev/null 2>&1 || true
|
||||
|
||||
publish:
|
||||
needs: build
|
||||
if: vars.CI_TOOLS_PUBLISH == 'true' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
image: ${{ steps.push.outputs.image }}
|
||||
env:
|
||||
VERSION: ${{ needs.build.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
|
||||
- name: Log in to the Gitea registry
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
REGISTRY_USER: ${{ vars.REGISTRY_USER }}
|
||||
run: printf '%s' "$REGISTRY_TOKEN" | docker login gitea.eom.dev -u "$REGISTRY_USER" --password-stdin
|
||||
|
||||
# Version tags are immutable: bump images/ci-tools/VERSION to publish.
|
||||
- name: Refuse to overwrite an existing version
|
||||
run: |
|
||||
if docker manifest inspect "$IMAGE:$VERSION" >/dev/null 2>&1; then
|
||||
echo "::error::$IMAGE:$VERSION already exists. Bump images/ci-tools/VERSION."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build and push
|
||||
id: push
|
||||
run: |
|
||||
docker build \
|
||||
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
|
||||
--label "org.opencontainers.image.revision=${{ github.sha }}" \
|
||||
--label "org.opencontainers.image.version=$VERSION" \
|
||||
-t "$IMAGE:$VERSION" images/ci-tools
|
||||
docker run --rm "$IMAGE:$VERSION" ci-tools-versions
|
||||
docker push "$IMAGE:$VERSION"
|
||||
echo "image=$IMAGE:$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Log out and clean up
|
||||
if: always()
|
||||
run: |
|
||||
docker logout gitea.eom.dev || true
|
||||
docker image rm "$IMAGE:$VERSION" >/dev/null 2>&1 || true
|
||||
|
||||
# Acceptance check for G1: a job that uses the published image as its
|
||||
# container starts and runs the tools without installing anything.
|
||||
sample:
|
||||
needs: publish
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
container:
|
||||
image: ${{ needs.publish.outputs.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- run: ci-tools-versions
|
||||
- run: actionlint -color .gitea/workflows/ci-tools-image.yaml
|
||||
- run: yamllint -d relaxed .gitea/workflows/ci-tools-image.yaml
|
||||
@@ -0,0 +1,69 @@
|
||||
# CI tools image
|
||||
|
||||
One image with every lint and validation tool eom.dev's CI jobs need, at
|
||||
pinned versions, so jobs start without running `apt` or `pip`.
|
||||
Tracked in DevOps/software-infrastructure#49 (G1).
|
||||
|
||||
- Source: `images/ci-tools/` (`Dockerfile`, `requirements.txt`, `VERSION`,
|
||||
`versions.sh`).
|
||||
- Workflow: `.gitea/workflows/ci-tools-image.yaml`.
|
||||
- Published name (once publishing is enabled): `gitea.eom.dev/devops/ci-tools:<VERSION>`.
|
||||
|
||||
## What's inside (1.0.0)
|
||||
|
||||
| Tool | Version | How it's pinned |
|
||||
| --- | --- | --- |
|
||||
| ansible (collection bundle) | 14.6.0 | `requirements.txt` |
|
||||
| ansible-core | 2.21.6 | `requirements.txt` (ansible 14 needs 2.21.x) |
|
||||
| ansible-lint | 26.11.0 | `requirements.txt` |
|
||||
| yamllint | 1.38.0 | `requirements.txt` |
|
||||
| helm | 3.22.1 | `ARG` + SHA-256 from the release |
|
||||
| kubeconform | 0.8.0 | `ARG` + SHA-256 from the release |
|
||||
| actionlint | 1.7.12 | `ARG` + SHA-256 from the release |
|
||||
| hadolint | 2.15.1 | `ARG` + SHA-256 from the release |
|
||||
| gitleaks | 8.30.1 | `ARG` + SHA-256 from the release |
|
||||
| node (for JavaScript actions such as `actions/checkout`) | 24.22.3 | base image tag |
|
||||
| python | 3.13.18 on Debian 13 | base image tag |
|
||||
|
||||
Also: `git`, `openssh-client`, `curl`, `jq`, `rsync`. Size is about 1 GB,
|
||||
most of it the Ansible collection bundle.
|
||||
|
||||
Helm stays on 3.x for now because the roles drive it through
|
||||
`kubernetes.core.helm`. Moving to Helm 4 is a separate change.
|
||||
|
||||
## Using it in a job
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: gitea.eom.dev/devops/ci-tools:1.0.0
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
- run: yamllint .
|
||||
- run: ansible-lint
|
||||
```
|
||||
|
||||
Pin a version tag. There is deliberately no `latest`.
|
||||
|
||||
## Changing it
|
||||
|
||||
1. Edit the version in `requirements.txt` or the `ARG`s in the `Dockerfile`.
|
||||
For a binary, take the SHA-256 from the release's published checksum file,
|
||||
not from a file you downloaded yourself.
|
||||
2. Bump `VERSION` (patch for tool bumps, minor for new tools, major for
|
||||
removals or anything that changes how jobs call the tools).
|
||||
3. Run the workflow. Publishing refuses to overwrite an existing version tag.
|
||||
4. Run `ci-tools-versions` in the image to see what it contains.
|
||||
|
||||
## Status
|
||||
|
||||
- Built and smoke-tested on the workstation, 2026-11-14: every tool reports
|
||||
its pinned version, `hadolint` passes on the image's own Dockerfile,
|
||||
`actionlint` passes on the workflow, and `ansible-playbook --syntax-check`
|
||||
passes on `gitea.yaml`, `ci-runner.yaml` and `prometheus.yaml` inside it.
|
||||
- **Not yet built in CI or published.** The workflow is manual-only until
|
||||
the runner fixes are proven (S8, #41). Publishing needs P1 (#61) and the
|
||||
repo settings listed at the top of the workflow.
|
||||
@@ -0,0 +1,57 @@
|
||||
# eom.dev CI tools image (DevOps/software-infrastructure#49, G1).
|
||||
# Everything a lint/validate job needs, at pinned versions, so jobs start
|
||||
# without installing anything. Bump VERSION when anything here changes.
|
||||
|
||||
# Node is only here so JavaScript actions (actions/checkout etc.) can run
|
||||
# inside a job that uses this image as its container.
|
||||
FROM node:24.22.3-trixie-slim AS node
|
||||
|
||||
FROM python:3.13.18-slim-trixie
|
||||
|
||||
ARG HELM_VERSION=3.22.1
|
||||
ARG HELM_SHA256=896cf63684a42a723d61c980369d6e588330927deb13676ca0d85006dd6da0ea
|
||||
ARG KUBECONFORM_VERSION=0.8.0
|
||||
ARG KUBECONFORM_SHA256=9bc2bffbf71f261128533edaf912153948b7ff238f9a531ae6d34466ec287883
|
||||
ARG ACTIONLINT_VERSION=1.7.12
|
||||
ARG ACTIONLINT_SHA256=8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
|
||||
ARG HADOLINT_VERSION=2.15.1
|
||||
ARG HADOLINT_SHA256=c7187db94eeeeca956519a6af171adc31453941a1e777961f6e680f697c8c507
|
||||
ARG GITLEAKS_VERSION=8.30.1
|
||||
ARG GITLEAKS_SHA256=551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl git openssh-client jq rsync \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
||||
|
||||
WORKDIR /tmp/tools
|
||||
RUN fetch() { curl -fsSL --retry 3 -o "$2" "$1" && echo "$3 $2" | sha256sum -c -; } \
|
||||
&& fetch "https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz" helm.tgz "${HELM_SHA256}" \
|
||||
&& tar -xzf helm.tgz --strip-components=1 linux-amd64/helm \
|
||||
&& fetch "https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" kubeconform.tgz "${KUBECONFORM_SHA256}" \
|
||||
&& tar -xzf kubeconform.tgz kubeconform \
|
||||
&& fetch "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" actionlint.tgz "${ACTIONLINT_SHA256}" \
|
||||
&& tar -xzf actionlint.tgz actionlint \
|
||||
&& fetch "https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VERSION}/hadolint-linux-x86_64" hadolint "${HADOLINT_SHA256}" \
|
||||
&& fetch "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" gitleaks.tgz "${GITLEAKS_SHA256}" \
|
||||
&& tar -xzf gitleaks.tgz gitleaks \
|
||||
&& install -m 0755 helm kubeconform actionlint hadolint gitleaks /usr/local/bin/ \
|
||||
&& rm -rf /tmp/tools
|
||||
|
||||
COPY requirements.txt /tmp/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||
&& rm /tmp/requirements.txt
|
||||
|
||||
COPY VERSION /etc/eom-ci-tools-version
|
||||
COPY versions.sh /usr/local/bin/ci-tools-versions
|
||||
|
||||
# Jobs run as root in act_runner job containers; keep the default user so
|
||||
# actions/checkout can write the workspace.
|
||||
WORKDIR /workspace
|
||||
ENV ANSIBLE_FORCE_COLOR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
CMD ["ci-tools-versions"]
|
||||
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
@@ -0,0 +1,6 @@
|
||||
# Python tools in the CI tools image. Pin exact versions; bump them in one
|
||||
# commit together with VERSION.
|
||||
ansible==14.6.0
|
||||
ansible-core==2.21.6
|
||||
ansible-lint==26.11.0
|
||||
yamllint==1.38.0
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Print the version of every tool in the eom.dev CI tools image.
|
||||
# Fails if any tool is missing, so it doubles as the image smoke test.
|
||||
set -eu
|
||||
echo "eom-ci-tools $(cat /etc/eom-ci-tools-version)"
|
||||
ansible --version | head -n1
|
||||
ansible-lint --version | head -n1
|
||||
yamllint --version
|
||||
helm version --short
|
||||
kubeconform -v
|
||||
actionlint -version | head -n1
|
||||
hadolint --version
|
||||
gitleaks version
|
||||
node --version
|
||||
git --version
|
||||
Reference in New Issue
Block a user