ci: add lint and build workflows on the kamino-docker runner

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-24 21:10:20 +00:00
1 parent 904d833a6f
commit a4c1931b4f
2 files changed
+209

No files matched your search

+112
View File
@@ -0,0 +1,112 @@
name: Build
# Builds the Collection tarball and checks it. On a v* tag it also checks the release
# invariants of ADR 0004 (annotated tag, tag equals v + galaxy.yml version). Nothing is
# uploaded: the tarball is built in a temporary directory and discarded. Releases are
# consumed by git tag, so there is no publish step. No secrets are used.
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: kamino-docker
timeout-minutes: 30
container:
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
env:
DEBIAN_FRONTEND: noninteractive
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
- name: Install OS packages
run: |
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates git python3 python3-venv python3-pip
- name: Checkout the commit under test
env:
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraheader
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
REF: ${{ github.ref }}
run: |
git clone "${{ github.server_url }}/${{ github.repository }}" .
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
# Make sure the tag object itself is present (not only the commit it points at).
if [ "${{ github.ref_type }}" = "tag" ]; then
git fetch origin "+refs/tags/${{ github.ref_name }}:refs/tags/${{ github.ref_name }}"
fi
echo "Checked out $(git rev-parse HEAD)"
- name: Install pinned tooling
run: |
python3 -m venv /opt/venv
/opt/venv/bin/pip install --quiet -r requirements-dev.txt
# ADR 0004, Release process: the tag is annotated and equals v + the galaxy.yml version.
- name: Check the release tag
if: github.ref_type == 'tag'
env:
TAG: ${{ github.ref_name }}
run: |
export PATH="/opt/venv/bin:$PATH"
type="$(git cat-file -t "refs/tags/$TAG")"
if [ "$type" != "tag" ]; then
echo "::error::$TAG is a lightweight tag; releases must be annotated (git tag -a)"
exit 1
fi
version="$(python3 -c 'import sys, yaml; print(yaml.safe_load(open("galaxy.yml"))["version"])')"
if [ "$TAG" != "v$version" ]; then
echo "::error::tag $TAG does not match galaxy.yml version $version (expected v$version)"
exit 1
fi
echo "Tag $TAG is annotated and matches galaxy.yml version $version"
- name: Build the Collection
run: |
export PATH="/opt/venv/bin:$PATH"
mkdir -p /tmp/dist
ansible-galaxy collection build --force --output-path /tmp/dist .
ls -l /tmp/dist
sha256sum /tmp/dist/*.tar.gz
# galaxy-importer without ansible-test and without Docker (ADR 0004, Collection
# repo gates). The importer reads its configuration from this file.
- name: Run galaxy-importer
run: |
export PATH="/opt/venv/bin:$PATH"
cat > /tmp/galaxy-importer.cfg <<'CFG'
[galaxy-importer]
RUN_ANSIBLE_TEST = False
RUN_ANSIBLE_LINT = False
LOCAL_IMAGE_DOCKER = False
CFG
GALAXY_IMPORTER_CONFIG=/tmp/galaxy-importer.cfg \
python3 -m galaxy_importer.main /tmp/dist/mortis-kamino-*.tar.gz
# Sanity tests need the collection at ansible_collections/<namespace>/<name>.
- name: Run ansible-test sanity
run: |
export PATH="/opt/venv/bin:$PATH"
# No --venv: its delegation virtualenv is created inside the content tree and fails
# the shebang and symlinks tests.
mkdir -p /tmp/ac/ansible_collections/mortis
git worktree add --detach /tmp/ac/ansible_collections/mortis/kamino HEAD
cd /tmp/ac/ansible_collections/mortis/kamino
ansible-test sanity --requirements --color no
+97
View File
@@ -0,0 +1,97 @@
name: Lint
# Runs on the Collection's own runner (label kamino-docker, scoped to the mortis org),
# never on the production runner. No secrets are used: the only credential is the
# job token, which is read-only for a fork pull request. No pull_request_target.
# The tools are installed in the job from pinned PyPI versions (requirements-dev.txt)
# and pinned hook revisions (.pre-commit-config.yaml), so this does not depend on any
# prebuilt CI image.
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch: {}
permissions:
contents: read
# A newer push to the same ref makes the running lint obsolete.
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: kamino-docker
# Ceiling only: the instance may cap job timeouts at app.ini's default.
timeout-minutes: 30
# Pinned by digest (ubuntu:24.04, 2026-10-24). The runner's default image is
# ubuntu:24.04 too, but a mutable tag; naming it here keeps the job reproducible.
container:
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
env:
DEBIAN_FRONTEND: noninteractive
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
# The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token, as the environment repo does.
- name: Install OS packages
run: |
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates git python3 python3-venv python3-pip shellcheck
- name: Checkout the commit under test
env:
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraheader
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
REF: ${{ github.ref }}
run: |
git clone "${{ github.server_url }}/${{ github.repository }}" .
# A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch.
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
echo "Checked out $(git rev-parse HEAD)"
- name: Install pinned tooling
run: |
python3 -m venv /opt/venv
/opt/venv/bin/pip install --quiet -r requirements-dev.txt
- name: Run pre-commit on all files
run: |
export PATH="/opt/venv/bin:$PATH"
pre-commit run --all-files --show-diff-on-failure
# The gitleaks hook scans --staged only, which is empty in a clean checkout,
# so scan the PR's commits explicitly with the binary pre-commit built.
- name: Scan PR commits for secrets
if: github.event_name == 'pull_request'
env:
SHA: ${{ github.event.pull_request.head.sha }}
run: |
GITLEAKS="$(find ~/.cache/pre-commit -type f -name gitleaks | sort | tail -n1)"
if [ ! -x "$GITLEAKS" ]; then
echo "gitleaks binary not found in the pre-commit cache" >&2
exit 1
fi
"$GITLEAKS" git --verbose --redact --log-opts="origin/main..$SHA"
# commit-msg stage hooks do not run under --all-files.
- name: Check Conventional Commits
if: github.event_name == 'pull_request'
env:
SHA: ${{ github.event.pull_request.head.sha }}
run: |
export PATH="/opt/venv/bin:$PATH"
MSG_FILE="$(mktemp)"
for sha in $(git rev-list --no-merges "origin/main..$SHA"); do
git log -1 --format=%B "$sha" > "$MSG_FILE"
echo "Checking $sha"
pre-commit run conventional-pre-commit --hook-stage commit-msg \
--commit-msg-filename "$MSG_FILE"
done