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
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All notable changes to this project are documented here, following

## [Unreleased]

## [0.2.1] - 2026-11-04

### Fixed

- **A passing Gatehouse review failed the push whenever there was a diff to
review.** `run_in_image` never reset its exit-status variable, and shell
function variables are global, so `git diff --quiet` -- which exits 1
whenever there IS a diff -- left a 1 that the container's success never
overwrote. Every push with a branch to review printed "No issues found" and
then failed. Present since v0.1.0; found on trentina's first push through
v0.2.0. `tests/test_host_contract.sh` now holds it.

## [0.2.0] - 2026-11-04

### Changed
Expand Down Expand Up @@ -153,6 +165,7 @@ cached tag was never refreshed — that gate had been running a two-week-old
reviewer while CI pulled fresh. Local and CI were different reviewers on the
same diff.

[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.2.1...HEAD
[0.2.1]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.1
[0.2.0]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.0
[0.1.0]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.1.0
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LABEL description="Every CrunchTools Python SDLC check in one image: ruff, mypy,
LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc"
LABEL org.opencontainers.image.description="Every CrunchTools Python SDLC check in one image."
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
LABEL version="0.2.0"
LABEL version="0.2.1"

# 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.2.0
0.2.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default_install_hook_types: [pre-commit, pre-push]

repos:
- repo: https://github.com/crunchtools/python-sdlc
rev: v0.2.0
rev: v0.2.1
hooks:
- id: sdlc-commit
- id: sdlc-push
Expand Down
6 changes: 5 additions & 1 deletion bin/sdlc
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ run_in_image() {
${SDLC_GATEHOUSE_SAMPLES:+-e SDLC_GATEHOUSE_SAMPLES} \
"$@"

# Reset HERE, not inherited. A shell function's variables are global, so a
# caller's earlier `|| _rc=$?` -- t_gatehouse's `git diff --quiet`, which is 1
# whenever there IS a diff -- survived into this function, and a container
# that succeeded reported the caller's 1 as its own failure.
_rc=0
if [ "$_stdin" = stdin ]; then
podman "$@" || _rc=$?
else
podman "$@" </dev/null || _rc=$?
fi
_rc=${_rc:-0}
# 125 podman itself failed, 126 not executable, 127 not found. The container
# never ran, so this is not a finding.
case "$_rc" in
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.2.0"
version = "0.2.1"
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
35 changes: 35 additions & 0 deletions tests/test_host_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ cat > "$SHIM/podman" <<EOF
#!/bin/sh
printf '%s\n' "\$*" >> "$LOG"
case " \$* " in
*" plan gatehouse-direct "*)
printf 'gatehouse${TAB}local${TAB}gatehouse\n' ;;
*" plan evil "*)
printf 'evil${TAB}host${TAB}sh${US}-c${US}touch $SHIM/pwned\n' ;;
*" plan subst "*)
Expand Down Expand Up @@ -111,6 +113,39 @@ else
bad "a host step's word was evaluated as shell"
fi

# A container that succeeds must report success, whatever the caller's last
# exit status was. Gatehouse runs right after `git diff --quiet`, which exits 1
# whenever there IS a diff to review; that 1 leaked through a shared variable
# and failed every push with a branch to review, after printing "No issues
# found". Checked here with a git shim that has a diff and a podman that passes.
GITSHIM=$(mktemp -d)
for prog in pre-commit gh; do
[ -e "$SHIM/$prog" ] && ln -s "$SHIM/$prog" "$GITSHIM/$prog"
done
for prog in sh awk sed tr grep basename dirname nproc cat mktemp rm ln head id podman; do
[ -e "$SHIM/$prog" ] && ln -s "$(readlink -f "$SHIM/$prog")" "$GITSHIM/$prog"
done
cat > "$GITSHIM/git" <<EOF
#!/bin/sh
case "\$*" in
*--show-toplevel*) pwd ;;
*symbolic-ref*) echo refs/remotes/origin/main ;;
*"diff --quiet"*) exit 1 ;;
*diff*) echo "+a change" ;;
*) exit 0 ;;
esac
EOF
chmod +x "$GITSHIM/git"
ENVFILE="$GITSHIM/gatehouse.env"
: > "$ENVFILE"
PATH="$GITSHIM" GATEHOUSE_ENV="$ENVFILE" sh bin/sdlc gatehouse-direct >/dev/null 2>&1 && rc=0 || rc=$?
rm -rf "$GITSHIM"
if [ "$rc" -eq 0 ]; then
ok "a passing review after a non-empty diff reports success"
else
bad "a passing review after a non-empty diff exited $rc"
fi

# The targets that run a container must actually have tried to. Without this the
# loop above would also pass if every target silently did nothing.
if [ -s "$LOG" ]; then
Expand Down
Loading