Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,43 +318,3 @@ jobs:
echo "promoted $version"
;;
esac

# Step 3 of a release (update-tools.yml describes all three): once a version
# tag's image is promoted -- so the tag a consumer will pull exists -- open a
# bump PR in every repo that pins python-sdlc. Each repo's own CI decides
# whether its bump lands.
bump-consumers:
name: Bump every repo that pins python-sdlc
needs: promote
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
# A FIXED group, like promote's, and for the same kind of reason. Each repo
# gets ONE bump branch which this force-pushes, so two releases running at
# once would fight over it and the loser's version would be the one left on
# the branch. Serialized, the later release simply supersedes the earlier --
# which is correct, since its image contains the earlier one's code.
# Not cancel-in-progress: a half-finished fleet bump is worse than a slow one.
concurrency:
group: bump-consumers-python-sdlc
cancel-in-progress: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Mint CI token
id: ci-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.CRUNCHTOOLS_CI_CLIENT_ID }}
private-key: ${{ secrets.CRUNCHTOOLS_CI_APP_KEY }}
owner: crunchtools

- name: Open the bump pull requests
env:
GH_TOKEN: ${{ steps.ci-token.outputs.token }}
run: |
gh auth setup-git
python3 scripts/bump_consumers.py "$GITHUB_REF_NAME"
8 changes: 4 additions & 4 deletions .github/workflows/update-tools.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# A Gourmand or Gatehouse release reaches every Python repo in three steps, and
# this is the first: move the pin and bump this image's patch version, as a pull
# A Gourmand or Gatehouse release reaches every repo in three steps, and this
# is the first: move the pin and bump this image's patch version, as a pull
# request that merges itself when CI is green.
#
# 1. this workflow new tool release -> PR moving the pin here
# 2. release.yml that PR merges -> python-sdlc vX.Y.Z is released
# 3. container.yml the release is promoted -> a bump PR in every repo
# that pins python-sdlc (scripts/bump_consumers.py)
# 3. container.yml the release is promoted to sdlc:latest, which every
# converted repo floats on: no pull request per repo
#
# Gourmand and Gatehouse send `parent-image-updated` when they release. The
# weekly run catches a dispatch that was lost.
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project are documented here, following

## [Unreleased]

## [0.9.0] - 2026-11-17

### Added

- **No `rev:` to pin.** The image now carries its own launcher
Expand Down Expand Up @@ -50,15 +52,41 @@ All notable changes to this project are documented here, following
check's record carries exit 4. Only the smoke run can skip: a 4 from a tool
in the image is still a finding.

- `scripts/convert_repo.py` writes the config a converted repo needs to run
on its first try: `skip-stacks` for node, bootc or docs, which this image
cannot check yet, and `[tool.sdlc.ci] skip` for `container-build`,
`container-smoke` and `container-scan` when the Containerfile needs build
secrets (`--mount=type=secret`, `subscription-manager`, RHSM). A Python repo
naming no stacks is untouched; an existing key that disagrees is refused.

### Changed

- **`container-smoke` is advisory by default.** It runs and prints what it
found as `FOUND SOMETHING, ADVISORY: not gating` (record exit 5), and the
command does not fail. `gate = true` in `[tool.sdlc.ci.container-smoke]`
makes a finding gate; a smoke run that could not run is still a 2.
- `containerfile-lint` also ignores SC1072, which hadolint raises on an
exec-form `RUN ["python3", "-c", …]`, and a Containerfile hadolint cannot
parse (a `RUN` heredoc) is printed as ADVISORY and SKIPPED, not failed.
- `examples/gatehouse.yml` is gatehouse at 4ae89d0 (gatehouse#150): the guard
also refuses a fork's change to `.sdlc/`. The converter brings an older guard
up to date.
- `containerfile-lint` without a `.hadolint.yaml` now fails at `error`, not
`warning`, and ignores DL3007 (floating base tags) and DL3041 (unpinned dnf
packages), which the fleet does on purpose. Warnings such as DL3002 are
printed and do not fail. A repo's `.hadolint.yaml` replaces these defaults.

### Removed

- `bump-consumers` (and `scripts/bump_consumers.py`): repos float on
`sdlc:latest`, so a release opens no bump pull requests. A repo still pinned
by `rev:` moves when it converts.

### Fixed

- `container-smoke` passes an exit 0 whatever podman says of OOMKilled: nested
rootless podman reports it true even for `true`. OOMKilled counts only
beside a non-zero exit.
- `container-smoke` removes the smoke container with `-v`, so an image that
declares a `VOLUME` no longer leaks an anonymous volume on every run. A fleet
measurement filled a seat's disk with 13 GB of them.
Expand Down
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LABEL description="Every CrunchTools SDLC check in one image: ruff, mypy, pytest
LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc"
LABEL org.opencontainers.image.description="Every CrunchTools SDLC check in one image, for Python and container repos."
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
LABEL version="0.8.0"
LABEL version="0.9.0"

# What the image carries, readable without starting anything. `sdlc versions`
# prints these and a consuming repo's CI pins them.
Expand Down
2 changes: 1 addition & 1 deletion IMAGE_TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.0
0.9.0
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ rev-pinned hooks below, or the standalone Gourmand and Gatehouse hooks -- and
prints the diff; `--apply` writes it. It replaces a workflow only when the CI
stub covers every job in it (`sdlc ci`, Gourmand), refreshes `gatehouse.yml`
from [`examples/gatehouse.yml`](examples/gatehouse.yml) when it differs only in
comments, keeps everything else (publish, release, container builds), and
refuses with exit 2 a shape it would have to guess at.
comments or in the guard's script (an older guard that does not cover
`.sdlc/`), keeps everything else (publish, release, container builds), and
refuses with exit 2 a shape it would have to guess at. So that a converted repo
never meets GATE CANNOT RUN on its first run, it also writes `skip-stacks` for
a stack this image cannot check yet (node, bootc, docs), and `[tool.sdlc.ci]
skip` for the three container checks when the Containerfile needs build
secrets (`--mount=type=secret`, `subscription-manager`, RHSM) that `sdlc ci`
is not given; the publish workflow keeps building those with its secrets. A
Python repo that names no stacks is left alone, and an existing key that does
not already say this is refused rather than rewritten.
`scripts/fleet_wave.py` runs it across the org: a plan by default, one
auto-merging pull request per repo with `--apply`, a TSV ledger either way.
It reads `GH_TOKEN` from the environment for the GitHub API (required with
Expand Down Expand Up @@ -166,9 +174,9 @@ refused.

| Check | Command | What it does |
|---|---|---|
| `containerfile-lint` | push, ci | hadolint over the Containerfile. Without a `.hadolint.yaml` the threshold is `error` and DL3007 (floating base tags) and DL3041 (unpinned dnf) are ignored, as fleet conventions; warnings such as DL3002 are printed and do not fail. A repo's `.hadolint.yaml` replaces all of that |
| `containerfile-lint` | push, ci | hadolint over the Containerfile. Without a `.hadolint.yaml` the threshold is `error` and DL3007 (floating base tags) DL3041 (unpinned dnf) and SC1072 (raised on an exec-form `RUN ["python3", "-c", …]`) are ignored, as fleet conventions; warnings such as DL3002 are printed and do not fail. A repo's `.hadolint.yaml` replaces all of that. A Containerfile hadolint cannot parse (a `RUN` heredoc) is printed as ADVISORY and SKIPPED, not failed; `container-build` still builds it |
| `container-build` | ci | `podman build`, at the tag the next two read |
| `container-smoke` | ci | starts the built image detached, with no network and no capabilities, and reads its state from podman: still running after `seconds`, or exited 0, passes; any other exit, the OOM killer, or an entrypoint that cannot start (126/127) fails. An image whose PID 1 is systemd (`/sbin/init`, `systemd`) is SKIPPED with its reason: systemd needs privileges the run withholds |
| `container-smoke` | ci | starts the built image detached, with no network and no capabilities, and reads its state from podman: still running after `seconds`, or exited 0, passes; any other exit, the OOM killer, or an entrypoint that cannot start (126/127) is a finding. **Advisory by default**: a finding is printed as `FOUND SOMETHING, ADVISORY` and does not fail the command; `gate = true` makes it gate. Exit 0 passes even when podman reports OOMKilled, which nested rootless podman does for any container; OOMKilled counts only beside a non-zero exit. Podman failing to create the container is still a 2. An image whose PID 1 is systemd (`/sbin/init`, `systemd`) is SKIPPED with its reason: systemd needs privileges the run withholds |
| `container-scan` | ci | grype over the built image's filesystem, mounted read-only by podman; fails on a fixable Critical by default, and the repo's `.grype.yaml` applies |

Build, smoke and scan are one lane, beside everything else.
Expand Down Expand Up @@ -255,8 +263,10 @@ $ jq -r '.checks[] | "\(.seconds)s \(.check) exit \(.exit)"' .git/sdlc/last-push
```

A check's `exit` is its status: 0 passed, 1 found something, 2 could not run,
3 deferred to CI, and 4 SKIPPED, which only `container-smoke` reports, for a
systemd PID 1 it cannot boot. A 4 never decides the command's own exit.
3 deferred to CI, 4 SKIPPED -- reported only by `container-smoke`, for a
systemd PID 1 it cannot boot, and `containerfile-lint`, for a Containerfile
hadolint cannot parse -- and 5 an ADVISORY finding from an ungated
`container-smoke`. A 4 or a 5 never decides the command's own exit.

The checks appear in the order they **finished**, which with lanes is not the
order they were listed in. A check that streamed to your terminal has no log
Expand Down Expand Up @@ -327,7 +337,7 @@ tests = ["tests/image/"]
| `ruff-check`, `ruff-format`, `lint`, `mypy`, `gourmand`, `gatehouse`, `pip-audit`, `hooks-installed` | none |
| `containerfile-lint` | `containerfiles` (default: the root Containerfile or Dockerfile), `threshold` |
| `container-build` | the `image-build` kind's settings; `containerfile` defaults to the root one |
| `container-smoke` | `seconds` (default 10), `args`, `env`, `network` (default `false`), `image` |
| `container-smoke` | `gate` (default `false`: findings are advisory), `seconds` (default 10), `args`, `env`, `network` (default `false`), `image` |
| `container-scan` | `fail_on` (default `critical`), `only_fixed` (default `true`), `image` |

### Kinds, for a repo's own checks
Expand Down Expand Up @@ -461,8 +471,9 @@ sees it. `sdlc codeql-baseline` writes it from the current findings. See
## How a new Gourmand or Gatehouse arrives

Their releases trigger a rebuild here, which is released as a new python-sdlc
version, which opens a version-bump pull request in each Python repo. The laptop
then runs the reviewer CI runs.
version and promoted to `sdlc:latest`. Every converted repo floats on that tag,
so the laptop then runs the reviewer CI runs, with no pull request per repo. A
repo still pinned by `rev:` moves only when it converts or bumps by hand.

## Host contract

Expand Down
36 changes: 27 additions & 9 deletions bin/sdlc
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,12 @@ run_up() { # seconds run-args -> the smoke verdict
"$_cname" 2>/dev/null) || _upstate=
podman logs "$_cname" 2>&1 || :
podman rm -f -v "$_cname" >/dev/null 2>&1 || :
# Exit 0 is a pass whatever OOMKilled says: nested rootless podman reports
# it true even for `true`. It counts only beside a non-zero exit.
case "$_upstate" in
'true '*) printf 'still running after %ss: the image starts and stays up\n' "$_upsecs"; return 0 ;;
*' true') printf '%s: the container was killed for memory\n' "$ME" >&2; return 1 ;;
'false 0 '*) return 0 ;;
*' true') printf '%s: the container was killed for memory\n' "$ME" >&2; return 1 ;;
'false '*) printf '%s: the container exited %s within %ss of starting\n' "$ME" \
"$(printf '%s' "$_upstate" | cut -d' ' -f2)" "$_upsecs" >&2; return 1 ;;
*) printf '%s: podman could not report the container state; nothing was judged\n' "$ME" >&2
Expand Down Expand Up @@ -716,12 +718,25 @@ run_step() { # mode payload -> the step's exit status
_run_step "$@" || _rs=$?
# Only a push may defer to CI. Anything else that reports 3 could not run.
if [ "$_rs" -eq 3 ] && [ "${SDLC_TIER:-}" != push ]; then return 2; fi
# Only run_up may skip, and only by its own decision. A tool inside a check
# exiting 4 found something, as it always has.
if [ "$_rs" -eq 4 ] && [ "$1" != host-up ]; then return 1; fi
# Two statuses mean "not gating", and each comes from one place only:
# 4 SKIPPED, not judged: run_up for a systemd PID 1, and
# containerfile-lint when hadolint cannot parse the Containerfile
# 5 found something, ADVISORY: an advisory smoke run's finding
# Anything else exiting 4 or 5 -- any tool in any other check -- found
# something, as it always has.
case "$_rs:$1:$2" in
4:host-up:*|4:host-up-advisory:*|4:image-ro:containerfile-lint) ;;
1:host-up-advisory:*) return 5 ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL (Constitution): An ungated smoke check that finds something is converted to status 5 and then treated as non-failing. The command therefore succeeds despite a finding, contrary to the constitution's exit-code contract: 0 means the check found nothing and 1 means it found something.

Suggestion: Keep advisory presentation separate from the check's verdict: a smoke finding must retain a finding result and make the command exit 1, unless the constitution is amended to define a different contract.

Evidence:

1:host-up-advisory:*) return 5 ;;
4:*|5:*) return 1 ;;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug: advisory smoke is the operator's decision for the conversion wave, and the finding is not reported as a pass.

The finding is never presented as clean. The run prints FOUND SOMETHING, ADVISORY: not gating together with how to make it gate, and the record carries exit 5, not 0. A smoke run that could not run is still a 2. The command's exit 0 means only that nothing gating failed. A repo opts into gating with gate = true in [tool.sdlc.ci.container-smoke], and the plan is to tighten repo by repo after the wave. This is flagged to the release owner for Exedore 2's re-review.

4:*|5:*) return 1 ;;
esac
return "$_rs"
}

advisory() { # check seconds -> the footer of an advisory finding
printf '\n== %s FOUND SOMETHING, ADVISORY: not gating, after %ss\n' "$1" "$2"
printf '%s: To make it gate: gate = true in [tool.sdlc.ci.%s]\n' "$ME" "$1"
}

deferred() { # check -> the warning a deferral prints, every time
printf '\n%s: %s COULD NOT RUN -- DEFERRED TO CI.\n' "$ME" "$1" >&2
printf '%s: This push is not blocked, and nothing was judged here.\n' "$ME" >&2
Expand All @@ -739,7 +754,7 @@ _run_step() {
*) die "the image asked for an unknown local check: $2" ;;
esac ;;
host) run_host "$2" ;;
host-up)
host-up|host-up-advisory)
_secs=${2%%"$US"*}
case "$_secs" in ''|*[!0-9]*) die "a host-up step must start with a number of seconds" ;; esac
run_host "${2#*"$US"}" "$_secs" ;;
Expand All @@ -753,6 +768,7 @@ _close_serial() { # the open check is finished: footer and record
# happened, rather than when the next check starts.
[ "$_scur_rc" -eq 0 ] && printf '\n== %s passed in %ss\n' "$_scur" "$_scur_took"
[ "$_scur_rc" -eq 4 ] && printf '\n== %s SKIPPED, not judged, after %ss\n' "$_scur" "$_scur_took"
[ "$_scur_rc" -eq 5 ] && advisory "$_scur" "$_scur_took"
record_check "$_scur" "$_scur_rc" "$_scur_took" ""
_scur=
}
Expand Down Expand Up @@ -795,8 +811,8 @@ run_serial() { # the plan -> its worst step status
_failed="$_failed $_check"
_scur_rc=3
deferred "$_check"
elif [ "$_rc" -eq 4 ]; then
_scur_rc=4
elif [ "$_rc" -eq 4 ] || [ "$_rc" -eq 5 ]; then
_scur_rc=$_rc
elif [ "$_rc" -ne 0 ]; then
_failed="$_failed $_check"
_scur_rc=$_rc
Expand Down Expand Up @@ -864,6 +880,8 @@ _close_check() { # the open check's block is complete
printf '\n== %s passed in %ss\n' "$_cur_name" "$_cur_took" >> "$OUT/out.$_cur"
elif [ "$_cur_rc" -eq 4 ]; then
printf '\n== %s SKIPPED, not judged, after %ss\n' "$_cur_name" "$_cur_took" >> "$OUT/out.$_cur"
elif [ "$_cur_rc" -eq 5 ]; then
advisory "$_cur_name" "$_cur_took" >> "$OUT/out.$_cur"
elif [ "$_cur_rc" -eq 3 ]; then
deferred "$_cur_name" 2>> "$OUT/out.$_cur"
else
Expand Down Expand Up @@ -924,8 +942,8 @@ run_lane() { # lane-index steps-file lane-cpus -> the lane's worst
if [ "$_rc" -eq 3 ]; then
_failed="$_failed $_check"
_cur_rc=3
elif [ "$_rc" -eq 4 ]; then
_cur_rc=4
elif [ "$_rc" -eq 4 ] || [ "$_rc" -eq 5 ]; then
_cur_rc=$_rc
elif [ "$_rc" -ne 0 ]; then
_failed="$_failed $_check"
_cur_rc=$_rc
Expand Down
9 changes: 5 additions & 4 deletions examples/gatehouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ permissions: {} # default-deny; each job grants only what it needs

jobs:
# ── 1) Protect the workflow files themselves ────────────────────────────────
# Rejects PRs from forks that touch .github/workflows/. Safe under
# Rejects PRs from forks that touch .github/workflows/ or .sdlc/ (the
# launcher the required `sdlc ci` check runs). Safe under
# pull_request_target because it only reads the changed-file LIST via the
# API — it never checks out or runs your code. And because pull_request_target
# runs the BASE version of this file, a PR can't edit this job to disable it.
Expand Down Expand Up @@ -71,11 +72,11 @@ jobs:
echo "Head branch is in $GITHUB_REPOSITORY; allowing."; exit 0
fi
# Both sides of a rename: `gh pr diff --name-only` lists only the new
# path, so a fork could move a workflow out of .github/workflows/ unseen.
# path, so a fork could move a file out of .github/workflows/ or .sdlc/ unseen.
changed="$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR/files" \
--jq '.[] | .filename, (.previous_filename // empty)')"
if echo "$changed" | grep -qE '^\.github/workflows/'; then
echo "::error::PR modifies .github/workflows/ — not accepted from external contributors."
if echo "$changed" | grep -qE '^(\.github/workflows|\.sdlc)/'; then
echo "::error::PR modifies .github/workflows/ or .sdlc/ — not accepted from external contributors."
# Explain once, on the PR event; replies re-run the check, not the comment.
if [ "$EVENT" = "pull_request_target" ]; then
gh pr comment "$PR" --repo "$GITHUB_REPOSITORY" --body \
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[project]
name = "python-sdlc"
version = "0.8.0"
version = "0.9.0"
description = "One container image and one script for every CrunchTools Python SDLC check"
requires-python = ">=3.14"
license = "AGPL-3.0-or-later"
Expand Down
Loading
Loading