Files
Kamino/.gitea/workflows/build.yml
T
Defame1297andClaude Sonnet 5.5 24500e9eed
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 6s
docs: correct the credential statements in CLAUDE.md, CONTRIBUTING.md and the workflows
State that a same-repo pull request gets org secrets and that Gitea 28 refuses the
job token for org packages. Rename image.yml's workflow to "Images" (cosmetic, no
step changed) and update stale comments.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-25 18:19:06 +00:00

118 lines
4.8 KiB
YAML

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 org secret is used; the job token (secrets.GITHUB_TOKEN) clones the repository.
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
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
container:
image: git.rkdr.net/mortis/ci:0.2.0@sha256:0eedfabb16fc95322b05b33917d2e551dccc6121c1537cef6a52cd5372a855eb
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.
- 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 or .pre-commit-config.yaml differ from the ci image; installing the pinned tools for this run."
/opt/venv/bin/pip install --quiet -r requirements-dev.txt
fi
# 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