Two Molecule runs could not overlap on one Docker daemon because every scenario's container name was fixed; only the runner's single slot kept them apart. Each platform is now named and labelled by KAMINO_RUN_ID (run id and attempt, "local" outside CI), the run script expands those names with molecule's own interpolator before removing them, and the workflow removes its own containers by label and only sweeps labelled leftovers older than the job timeout, so a run still going is never hit. Non-pull-request runs get a concurrency group of their own. Push to main no longer triggers Molecule, Lint or Build: a merged pull request was already tested, and the nightly and manual Molecule runs cover every scenario. Build keeps its v* tag trigger. Assisted-by: Claude Code:claude-opus-5-5
163 lines
7.7 KiB
YAML
163 lines
7.7 KiB
YAML
name: Build
|
|
|
|
# Builds the Collection tarball and checks it. On a v* tag it also checks the release
|
|
# invariants (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 org secret is used; the job token (secrets.GITHUB_TOKEN) clones the repository.
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# A newer push to the same pull request cancels the running run. A tag's ref differs from every
|
|
# branch's, so a tag run has a group of its own and is never cancelled.
|
|
concurrency:
|
|
group: build-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: kamino-docker
|
|
timeout-minutes: 30
|
|
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
|
container:
|
|
image: git.rkdr.net/mortis/ci:0.2.40@sha256:fcb063b570cc8e379fa0e3cc0409ceee4e5b7f848f97cd1663c0b9f7a7da221c
|
|
env:
|
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
steps:
|
|
- 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 }}
|
|
# Passed as environment, never interpolated into the script: a tag name may
|
|
# contain shell metacharacters.
|
|
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
|
REF_TYPE: ${{ github.ref_type }}
|
|
REF_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
git clone "$REPO_URL" .
|
|
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 [ "$REF_TYPE" = "tag" ]; then
|
|
git fetch origin "+refs/tags/${REF_NAME}:refs/tags/${REF_NAME}"
|
|
fi
|
|
echo "Checked out $(git rev-parse HEAD)"
|
|
|
|
# The baked tools match the pin files unless this change touches them; then the
|
|
# pinned tools are installed for this run, as before the ci image existed. This job
|
|
# uses the Python tools only; the collections of requirements.yml are Lint's.
|
|
- name: Check the baked tooling against the pins
|
|
run: |
|
|
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
|
echo "The pin files match the ci image; using the baked tools."
|
|
else
|
|
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
|
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
|
"installing the pinned tools for this run."
|
|
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
|
fi
|
|
|
|
# The release 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"
|
|
|
|
# ansible-galaxy dereferences symlinks when it builds, so a symlink in the source tree
|
|
# reaches the archive as a regular file with the target's content, where
|
|
# scripts/check_tarball.py cannot see it. Refuse them in the tree instead: this step
|
|
# is the only guard against a file symlink. The two -prune paths below (./.venv,
|
|
# ./.git) are skipped only because the build skips them too (galaxy.yml build_ignore,
|
|
# and ansible-galaxy's own .git exclusion): the two lists must stay in step, and
|
|
# tests/scripts/test_check_tarball.py fails when a pruned directory is not ignored.
|
|
- name: Refuse symlinks in the source tree
|
|
run: |
|
|
links="$(find . -path ./.git -prune -o -path ./.venv -prune -o -type l -print)"
|
|
if [ -n "$links" ]; then
|
|
echo "::error::symlinks in the source tree would be dereferenced into the Collection archive:"
|
|
echo "$links"
|
|
exit 1
|
|
fi
|
|
|
|
- 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
|
|
|
|
# The archive is what consumers get: only the allow list of scripts/check_tarball.py.
|
|
- name: Check the archive contents
|
|
run: |
|
|
export PATH="/opt/venv/bin:$PATH"
|
|
set -- /tmp/dist/mortis-kamino-*.tar.gz
|
|
if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then
|
|
echo "::error::expected exactly one tarball in /tmp/dist, found $# match(es): $*"
|
|
exit 1
|
|
fi
|
|
python3 scripts/check_tarball.py "$1"
|
|
|
|
# galaxy-importer without ansible-test and without Docker. 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
|
|
set -- /tmp/dist/mortis-kamino-*.tar.gz
|
|
if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then
|
|
echo "::error::expected exactly one tarball in /tmp/dist, found $# match(es): $*"
|
|
exit 1
|
|
fi
|
|
GALAXY_IMPORTER_CONFIG=/tmp/galaxy-importer.cfg \
|
|
python3 -m galaxy_importer.main "$1"
|
|
|
|
# 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 reads tests/sanity/ignore-<core MAJOR.MINOR>.txt and has no wildcard.
|
|
# The committed ignore-common.txt applies to every core version: it is copied to the
|
|
# file name of the installed core here, in this throwaway worktree only (plus the
|
|
# lines of a committed ignore-<MAJOR.MINOR>.txt, for a finding of one version only).
|
|
core="$(python3 -c 'import ansible.release as r; print(".".join(r.__version__.split(".")[:2]))')"
|
|
case "$core" in [0-9]*.[0-9]*) ;; *) echo "::error::Cannot read the ansible-core version ($core)"; exit 1 ;; esac
|
|
ignore="tests/sanity/ignore-${core}.txt"
|
|
{ cat tests/sanity/ignore-common.txt; if [ -f "$ignore" ]; then cat "$ignore"; fi; } > /tmp/ignore.new
|
|
mv /tmp/ignore.new "$ignore"
|
|
echo "Sanity ignore list for ansible-core ${core}: $(wc -l < "$ignore") lines"
|
|
ansible-test sanity --requirements --color no
|