Files
Kamino/.gitea/workflows/build.yml
T

113 lines
4.2 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 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