From 24500e9eed53c2b4f092a4398ef9ccf0bcfbce8a Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 25 Oct 2026 18:19:06 +0000 Subject: [PATCH 1/4] 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 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/build.yml | 2 +- .gitea/workflows/image.yml | 16 +++++++++------- .gitea/workflows/lint.yml | 4 ++-- CLAUDE.md | 7 ++++--- CONTRIBUTING.md | 7 ++++--- .../credential-and-workflow-comments.yml | 2 ++ 6 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 changelogs/fragments/credential-and-workflow-comments.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 762faff..fcc39e4 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -3,7 +3,7 @@ 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. +# 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: diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index 7d1a992..4ceee46 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -1,4 +1,4 @@ -name: Molecule image +name: Images # Builds the images under images/ with kaniko (osscontainertools fork, v1.28.6) and # pushes them to git.rkdr.net/mortis/ (ADR 0004, Image distribution): the molecule @@ -18,10 +18,11 @@ name: Molecule image # to that entrypoint, not substituted. The pinned kaniko executor is therefore # downloaded by layer digest and verified with sha256sum. # - Credentials: the job token is tried first (permissions: packages: write). Gitea 28 -# probably refuses it for an organisation-owned package (the Actions user is not an -# org member: services/context/package.go, TODO ActionUser permission check). Only if -# a write probe is refused are the org secrets PACKAGE_PUSH_USER / PACKAGE_PUSH_TOKEN -# used. The log names the method that worked, never a value. +# refuses it for an organisation-owned package (HTTP 401 on a write probe, run 2237: +# the Actions user is not an org member, services/context/package.go, TODO ActionUser +# permission check). Only if a write probe is refused are the org secrets +# PACKAGE_PUSH_USER / PACKAGE_PUSH_TOKEN used. The log names the method that worked, +# never a value. # - Layers: every layer stays far below Cloudflare's 100 MB request-body limit (see the # Dockerfile). No kaniko cache: a tiny, rarely rebuilt image gains little, and cache # layers would be pushed through the same Cloudflare-limited path. @@ -107,8 +108,9 @@ jobs: # file difference under /usr, /lib, /bin, /sbin, /opt or /etc fails the job. # Names only, no sizes or modes, and /var/log, /run and dpkg's *-old files are # not compared: logs and dpkg state the install touched may end up in the first - # layer as modified files. That is cosmetic; after the first push, list the - # layers (crane export | tar t) and look for run/act, root/ and var/log/apt. + # layer as modified files. That is cosmetic. Not yet checked: listing the layers + # (crane export | tar t, looking for run/act, root/ and var/log/apt) needs a + # read:package token, which the Claude token lacks. # # The pinned kaniko v1.28.6 image has index digest # sha256:2fa20b0a4b40c7db72b479d57e55c2cf79f2178533b2d3bcbd129d6bd3c087ed and diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index c2f3e27..b3f1d9b 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -1,8 +1,8 @@ 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. +# never on the production runner. No org secret is used: the only credential is the +# job token (secrets.GITHUB_TOKEN), which is read-only for a fork pull request. No pull_request_target. # The tools come from the ci image (images/ci, built by image.yml): the pinned Python # tools of requirements-dev.txt and the hook environments of .pre-commit-config.yaml # are baked in. When a PR changes one of those files the checksum check below fails diff --git a/CLAUDE.md b/CLAUDE.md index ff5fb52..c964a80 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,7 @@ protection, or create tags: those are the operator's. ## Workflows (`.gitea/workflows/`) -- Never `pull_request_target`. No secrets on `pull_request`. Pass ref, repo and name values to +- Never `pull_request_target`. A fork `pull_request` run gets no secrets and a read-only job token; a same-repo pull request does get the org Actions secrets, so nothing but `image.yml` may reference them. Pass ref, repo and name values to scripts through `env:`, never interpolate `${{ github.* }}` into a `run:` block. - Runner labels are `kamino-docker` and `kamino-molecule` only (`.gitea/actionlint.yaml`). Use the `github.*` contexts, which Gitea aliases; actionlint does not know `gitea.*`. @@ -55,5 +55,6 @@ protection, or create tags: those are the operator's. digest. - Each pushed layer must stay below 100 MB: Cloudflare rejects larger request bodies with HTTP 413. That is why the `ci` image deletes the Go toolchains from the hook cache. -- The push credential is the org Actions secrets `PACKAGE_PUSH_USER` and `PACKAGE_PUSH_TOKEN`. - Never print or use them anywhere else. +- `image.yml` tries the job token first with a write probe; Gitea 28 refuses it for the org's packages + (HTTP 401, run 2237), so the push uses the org Actions secrets `PACKAGE_PUSH_USER` and + `PACKAGE_PUSH_TOKEN`. Never print or use them anywhere else. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1bcbbf0..0a090e9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,9 +28,10 @@ outside contributions: - Protect the `v*` tags so only maintainers can create them. A tag run uses the workflow files of the tagged commit and may receive organisation secrets. -- Protect `main`: pull request required, with the `Lint` and `Build` checks. -- The image workflow (`.gitea/workflows/image.yml`) pushes with the Actions job token - when Gitea allows it, otherwise with the organisation secrets +- Protect `main`: pull request required, with the `Lint` and `Build` checks. Molecule is not a required + check: its path filter would leave the check pending forever on a pull request that touches no role. +- The image workflow (`.gitea/workflows/image.yml`) tries the Actions job token first; + Gitea 28 refuses it for an organisation's packages, so it pushes with the organisation secrets `PACKAGE_PUSH_USER` and `PACKAGE_PUSH_TOKEN` (a bot user with write access to the organisation's packages and a token with only the `write:package` scope). Keep those the only credentials stored at organisation level. diff --git a/changelogs/fragments/credential-and-workflow-comments.yml b/changelogs/fragments/credential-and-workflow-comments.yml new file mode 100644 index 0000000..b858e5a --- /dev/null +++ b/changelogs/fragments/credential-and-workflow-comments.yml @@ -0,0 +1,2 @@ +trivial: + - Document the credential model in CLAUDE.md, CONTRIBUTING.md and the workflow headers, and rename the image workflow to Images. From 705b370e230375b91327f5d8f937548e79f59c2a Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 25 Oct 2026 18:22:57 +0000 Subject: [PATCH 2/4] fix(ci): let a push to main finish its Lint and Build runs The concurrency group was the ref, so a second merge to main cancelled the run of the first. Key the group on the sha outside pull requests and cancel only on pull_request. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/build.yml | 6 ++++-- .gitea/workflows/lint.yml | 7 ++++--- changelogs/fragments/ci-concurrency-main-runs.yml | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/ci-concurrency-main-runs.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 762faff..c9d1ce7 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -18,9 +18,11 @@ on: # yamllint disable-line rule:truthy permissions: contents: read +# A newer push to the same pull request cancels the running run; a push to main or a tag +# never cancels another run. concurrency: - group: build-${{ github.ref }} - cancel-in-progress: true + group: build-${{ github.event_name == 'pull_request' && github.ref || github.sha }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: build: diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index c2f3e27..d5e3c3b 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -19,10 +19,11 @@ on: # yamllint disable-line rule:truthy permissions: contents: read -# A newer push to the same ref makes the running lint obsolete. +# A newer push to the same pull request makes the running run obsolete. A push to main or a +# tag is never cancelled: each merge commit keeps its own result. concurrency: - group: lint-${{ github.ref }} - cancel-in-progress: true + group: lint-${{ github.event_name == 'pull_request' && github.ref || github.sha }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: lint: diff --git a/changelogs/fragments/ci-concurrency-main-runs.yml b/changelogs/fragments/ci-concurrency-main-runs.yml new file mode 100644 index 0000000..9c037e5 --- /dev/null +++ b/changelogs/fragments/ci-concurrency-main-runs.yml @@ -0,0 +1,2 @@ +trivial: + - A later push to main no longer cancels the Lint and Build runs of an earlier one; pull request runs still cancel their predecessors. From 3b19cfd65e1edc98e3ea55b74aabaa1696000f0b Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 25 Oct 2026 18:52:57 +0000 Subject: [PATCH 3/4] fix(ci): give tag runs their own concurrency group A tag run and the main run of the same commit shared the group keyed by the commit SHA, so one could wait on the other. Tag runs are now keyed by their ref. Cancellation stays limited to pull requests. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/build.yml | 5 +++-- .gitea/workflows/lint.yml | 5 +++-- changelogs/fragments/ci-concurrency-main-runs.yml | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index c9d1ce7..b9ebd24 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -19,9 +19,10 @@ permissions: contents: read # A newer push to the same pull request cancels the running run; a push to main or a tag -# never cancels another run. +# never cancels another run. A tag run has its own group, so it never shares one with the +# main run of the same commit. concurrency: - group: build-${{ github.event_name == 'pull_request' && github.ref || github.sha }} + group: build-${{ github.event_name == 'pull_request' && github.ref || (github.ref_type == 'tag' && github.ref || github.sha) }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index d5e3c3b..3546e2f 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -20,9 +20,10 @@ permissions: contents: read # A newer push to the same pull request makes the running run obsolete. A push to main or a -# tag is never cancelled: each merge commit keeps its own result. +# tag is never cancelled: each merge commit keeps its own result, and a tag run has its own +# group, so it never shares one with the main run of the same commit. concurrency: - group: lint-${{ github.event_name == 'pull_request' && github.ref || github.sha }} + group: lint-${{ github.event_name == 'pull_request' && github.ref || (github.ref_type == 'tag' && github.ref || github.sha) }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: diff --git a/changelogs/fragments/ci-concurrency-main-runs.yml b/changelogs/fragments/ci-concurrency-main-runs.yml index 9c037e5..6fe8632 100644 --- a/changelogs/fragments/ci-concurrency-main-runs.yml +++ b/changelogs/fragments/ci-concurrency-main-runs.yml @@ -1,2 +1,4 @@ trivial: - - A later push to main no longer cancels the Lint and Build runs of an earlier one; pull request runs still cancel their predecessors. + - >- + A later push to main no longer cancels the Lint and Build runs of an earlier one; pull request + runs still cancel their predecessors, and a tag run has its own group. From 39fd0c385ac9b173ef7fa1628295ce73cdd1e9ea Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 25 Oct 2026 19:18:28 +0000 Subject: [PATCH 4/4] fix(ci): drop the dead tag branch from the Lint concurrency group lint.yml has no tag trigger, so the ref_type == 'tag' branch of its concurrency group could never run. Keep it in build.yml, which has one, and correct the comment and changelog fragment accordingly. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/lint.yml | 8 ++++---- changelogs/fragments/ci-concurrency-main-runs.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index 3546e2f..944ee2e 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -19,11 +19,11 @@ on: # yamllint disable-line rule:truthy permissions: contents: read -# A newer push to the same pull request makes the running run obsolete. A push to main or a -# tag is never cancelled: each merge commit keeps its own result, and a tag run has its own -# group, so it never shares one with the main run of the same commit. +# A newer push to the same pull request makes the running run obsolete. A push to main is +# never cancelled: each merge commit keeps its own result, so its group is the commit SHA. +# (This workflow has no tag trigger, so no tag branch in the group.) concurrency: - group: lint-${{ github.event_name == 'pull_request' && github.ref || (github.ref_type == 'tag' && github.ref || github.sha) }} + group: lint-${{ github.event_name == 'pull_request' && github.ref || github.sha }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: diff --git a/changelogs/fragments/ci-concurrency-main-runs.yml b/changelogs/fragments/ci-concurrency-main-runs.yml index 6fe8632..9ac883d 100644 --- a/changelogs/fragments/ci-concurrency-main-runs.yml +++ b/changelogs/fragments/ci-concurrency-main-runs.yml @@ -1,4 +1,4 @@ trivial: - >- A later push to main no longer cancels the Lint and Build runs of an earlier one; pull request - runs still cancel their predecessors, and a tag run has its own group. + runs still cancel their predecessors, and in the Build workflow a tag run has its own group.