Files
Kamino/.gitea/workflows/lint.yml
T
Defame1297andClaude Sonnet 5.5 0bc8d19775 fix(ci): harden the build and image workflows after review
Pass ref and repository values to run steps as environment instead of
interpolating them into the script (a tag name may contain shell
metacharacters). In the image workflow: refuse tags that are not
vMAJOR.MINOR.PATCH[-prerelease] before anything runs, purge exactly the
packages the prepare step added instead of autoremove and fail on any
package or /etc file difference from the base image, send the registry
write probe with an empty body, and remove the registry credential after
the push also when the build fails.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-24 21:10:20 +00:00

99 lines
3.8 KiB
YAML

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.
# The tools are installed in the job from pinned PyPI versions (requirements-dev.txt)
# and pinned hook revisions (.pre-commit-config.yaml), so this does not depend on any
# prebuilt CI image.
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch: {}
permissions:
contents: read
# A newer push to the same ref makes the running lint obsolete.
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: kamino-docker
# Ceiling only: the instance may cap job timeouts at app.ini's default.
timeout-minutes: 30
# Pinned by digest (ubuntu:24.04, 2026-10-24). The runner's default image is
# ubuntu:24.04 too, but a mutable tag; naming it here keeps the job reproducible.
container:
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
env:
DEBIAN_FRONTEND: noninteractive
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
# The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token, as the environment repo does.
- name: Install OS packages
run: |
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates git python3 python3-venv python3-pip shellcheck
- 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 }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
git clone "$REPO_URL" .
# A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch.
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
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
- name: Run pre-commit on all files
run: |
export PATH="/opt/venv/bin:$PATH"
pre-commit run --all-files --show-diff-on-failure
# The gitleaks hook scans --staged only, which is empty in a clean checkout,
# so scan the PR's commits explicitly with the binary pre-commit built.
- name: Scan PR commits for secrets
if: github.event_name == 'pull_request'
env:
SHA: ${{ github.event.pull_request.head.sha }}
run: |
GITLEAKS="$(find ~/.cache/pre-commit -type f -name gitleaks | sort | tail -n1)"
if [ ! -x "$GITLEAKS" ]; then
echo "gitleaks binary not found in the pre-commit cache" >&2
exit 1
fi
"$GITLEAKS" git --verbose --redact --log-opts="origin/main..$SHA"
# commit-msg stage hooks do not run under --all-files.
- name: Check Conventional Commits
if: github.event_name == 'pull_request'
env:
SHA: ${{ github.event.pull_request.head.sha }}
run: |
export PATH="/opt/venv/bin:$PATH"
MSG_FILE="$(mktemp)"
for sha in $(git rev-list --no-merges "origin/main..$SHA"); do
git log -1 --format=%B "$sha" > "$MSG_FILE"
echo "Checking $sha"
pre-commit run conventional-pre-commit --hook-stage commit-msg \
--commit-msg-filename "$MSG_FILE"
done