From 1fb1e7a984ab75e2dcd4b7823c7a879bfbbbf2ad Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sat, 28 Nov 2026 16:17:12 +1100 Subject: [PATCH] Add GitHub Actions build and publish workflows --- .github/CODEOWNERS | 1 + .github/actionlint.yaml | 2 + .github/workflows/ci.yml | 28 +++++++++++ .github/workflows/publish.yml | 87 +++++++++++++++++++++++++++++++++++ .github/zizmor.yml | 7 +++ .pre-commit-config.yaml | 2 +- 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/actionlint.yaml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/zizmor.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..711107c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @IUCLabs/maintainers diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..dfe4e20 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,2 @@ +self-hosted-runner: + labels: [iuclabs-k8s, iuclabs-build] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6e7e6b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: ci + +on: + pull_request: + push: + branches: [main] + +permissions: {} + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + ci: + uses: IUCLabs/workflows/.github/workflows/pre-commit.yml@v0.1.1 + permissions: + contents: read + with: + runs_on: iuclabs-k8s + python_version: "3.11" + + actions: + uses: IUCLabs/workflows/.github/workflows/actions.yml@v0.1.1 + permissions: + contents: read + with: + runs_on: ubuntu-latest diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c96b76c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,87 @@ +# Build every rpms/* package missing from its artifactapi rpm-vendor-* repo, per distro; push to main uploads them. +name: publish + +on: + pull_request: + push: + branches: [main] + +permissions: {} + +concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + VAULT_ADDR: https://vault.service.consul:8200 + ARTIFACTAPI: https://artifactapi.k8s.syd1.au.unkin.net + IMAGE: artifactapi.k8s.syd1.au.unkin.net/docker-internal/rpmbuilder:0.1.0-alma9 + +jobs: + build: + if: ${{ github.event_name != 'push' }} + runs-on: iuclabs-build + permissions: + contents: read + strategy: + fail-fast: false + matrix: &distros + include: + - { distro: almalinux/el9, repo: rpm-vendor-el9 } + - { distro: fedora/42, repo: rpm-vendor-f42 } + - { distro: fedora/43, repo: rpm-vendor-f43 } + - { distro: fedora/44, repo: rpm-vendor-f44 } + steps: + - &checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - &build + name: build rpms + env: + DISTRO: ${{ matrix.distro }} + run: | + docker run --rm --privileged -v "${GITHUB_WORKSPACE}:/src" -w /src "${IMAGE}" \ + ./tools/build build-all --distro "${DISTRO}" --buildah + find . -type f -name '*.rpm' + + publish: + if: ${{ github.event_name == 'push' }} + runs-on: iuclabs-build + permissions: + contents: read + id-token: write + strategy: + fail-fast: false + matrix: *distros + steps: + - *checkout + - *build + # login after the build: vault tokens live 15m + - uses: hashicorp/vault-action@892a26828f195e65540a40b4768ae4571f51ebfc # v4.0.0 + with: + url: ${{ env.VAULT_ADDR }} + method: jwt + path: jwt/github/iuclabs + role: rpmbuilder_publish + jwtGithubAudience: ${{ env.VAULT_ADDR }} + secrets: | + identity/oidc/token/artifactapi-writer token | ARTIFACTAPI_TOKEN + - name: upload rpms + env: + REPO: ${{ matrix.repo }} + run: | + set -euo pipefail + auth="${RUNNER_TEMP}/auth" + printf 'Authorization: Bearer %s\n' "${ARTIFACTAPI_TOKEN}" > "${auth}" + find . -type f -name '*.rpm' -print0 | while IFS= read -r -d '' rpm; do + file=$(basename "${rpm}") + # artifactapi has no HEAD route (405); probe the served Packages path. + code=$(curl -s --cacert /etc/vault-ca/ca.crt -o /dev/null -w '%{http_code}' "${ARTIFACTAPI}/api/v2/remotes/${REPO}/files/Packages/${file}" || true) + if [ "${code}" = 200 ]; then + echo "${file} already exists in ${REPO}; skipping" + continue + fi + curl -fsS --cacert /etc/vault-ca/ca.crt -X PUT "${ARTIFACTAPI}/api/v2/remotes/${REPO}/files/${file}" \ + -H "Content-Type: application/x-rpm" -H @"${auth}" --data-binary @"${rpm}" + done diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 0000000..21475c9 --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,7 @@ +rules: + unpinned-uses: + config: + policies: + # shared workflows are pinned to their release tags + "IUCLabs/*": ref-pin + "*": hash-pin diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2b46e2..caaec9a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: hooks: - id: pytest name: Run unit tests - entry: make test + entry: uv run --group dev pytest tests/ -q language: system types: [python] pass_filenames: false -- 2.47.3