Skip to content

Commit 05eb9ef

Browse files
shenxianpengclaude
andcommitted
fix(install): keep the venv and wheels out of the caller's workspace
The composite step ran in $GITHUB_WORKSPACE and left `venv/` (63 MB) and fourteen wheels next to the caller's sources, where any later `git status`, linter or `upload-artifact: .` step saw them. It also downloaded the dependency closure twice: `pip download` fetched all fourteen wheels, then `pip install commit_check-*.whl pygithub-*.whl` resolved the twelve transitive ones against PyPI again, so the installed wheels were not provably the downloaded ones. And when `gh` was missing, as on a self-hosted runner, the failure read "Artifact verification failed", blaming the wheel for an absent tool. Work under $RUNNER_TEMP/commit-check-action instead: one `pip download -d` into it, an explicit `command -v gh` check with its own `::error::`, `gh attestation verify` on the single downloaded commit-check wheel, and an offline `pip install --no-index --find-links` of requirements.txt so the verified wheel is the installed one and nothing is fetched twice. The Windows/Linux activation logic and DEB_PYTHON_INSTALL_LAYOUT are unchanged. Simulated in a scratch workspace seeded with README.md: before, `ls -A` showed README.md, 14 wheels and venv; after, README.md alone, with venv and wheels/ under $RUNNER_TEMP and zero "Downloading" lines on a forced reinstall from the wheel directory. Point the README SLSA badge at the current verify block; it linked to line numbers in an April 2025 revision of action.yml that no longer match. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
1 parent ccfa72b commit 05eb9ef

2 files changed

Lines changed: 27 additions & 14 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Used by](https://img.shields.io/static/v1?label=Used%20by&message=165&color=informational&logo=slickpic)](https://github.com/commit-check/commit-check-action/network/dependents)<!-- used by badge -->
55
[![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action)
66
[![commit-check](https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white&color=%232c9ccd)](https://github.com/commit-check/commit-check)
7-
[![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg?color=blue)](https://github.com/commit-check/commit-check-action/blob/a2873ca0482dd505c93fb51861c953e82fd0a186/action.yml#L59-L69)
7+
[![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg?color=blue)](https://github.com/commit-check/commit-check-action/blob/main/action.yml#L84-L94)
88
[![codecov](https://codecov.io/gh/commit-check/commit-check-action/graph/badge.svg?token=QHUDSMJGS7)](https://codecov.io/gh/commit-check/commit-check-action)
99

1010
A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more.

‎action.yml‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,44 @@ runs:
5858
# Platform-specific settings
5959
if [[ "$RUNNER_OS" == "Windows" ]]; then
6060
PYTHON_CMD="python"
61-
VENV_ACTIVATE="venv/Scripts/activate"
6261
else
6362
if [[ "$RUNNER_OS" == "Linux" ]]; then
6463
# https://github.com/pypa/setuptools/issues/3269
6564
export DEB_PYTHON_INSTALL_LAYOUT=deb
6665
fi
6766
PYTHON_CMD="python3"
68-
VENV_ACTIVATE="venv/bin/activate"
6967
fi
7068
71-
# Set up virtual environment
72-
$PYTHON_CMD -m venv venv
73-
source "$VENV_ACTIVATE"
69+
# Everything the action installs lives under $RUNNER_TEMP, never in the
70+
# caller's checkout: a later `git status`, linter or upload-artifact step
71+
# must not see our venv or wheels.
72+
WORK="$RUNNER_TEMP/commit-check-action"
73+
mkdir -p "$WORK/wheels"
74+
$PYTHON_CMD -m venv "$WORK/venv"
75+
if [[ "$RUNNER_OS" == "Windows" ]]; then
76+
source "$WORK/venv/Scripts/activate"
77+
else
78+
source "$WORK/venv/bin/activate"
79+
fi
7480
75-
# Download artifact
76-
$PYTHON_CMD -m pip download -r "$GITHUB_ACTION_PATH/requirements.txt"
81+
# One download of the pinned closure, into the scratch dir.
82+
$PYTHON_CMD -m pip download -q -d "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
7783
78-
# Verify artifact attestations
79-
if ! gh attestation verify commit_check-*.whl -R commit-check/commit-check; then
80-
echo "Artifact verification failed. Aborting installation."
81-
exit 1
84+
# Verify the commit-check wheel's build provenance (PyGithub and the
85+
# transitive wheels are pinned but not attested; see README "Runner requirements").
86+
if ! command -v gh >/dev/null 2>&1; then
87+
echo "::error::gh CLI not found; it is required to verify the commit-check wheel attestation. Install it on this runner (preinstalled on GitHub-hosted runners)."
88+
exit 1
89+
fi
90+
WHEEL=$(ls "$WORK"/wheels/commit_check-*.whl) # exactly one: pip download of a == pin
91+
if ! gh attestation verify "$WHEEL" -R commit-check/commit-check; then
92+
echo "::error::Attestation verification failed for $(basename "$WHEEL"). Aborting installation."
93+
exit 1
8294
fi
8395
84-
# Install artifact
85-
$PYTHON_CMD -m pip install commit_check-*.whl pygithub-*.whl
96+
# Install offline from the wheels we already downloaded and verified:
97+
# no second trip to PyPI, and the installed set is exactly the downloaded set.
98+
$PYTHON_CMD -m pip install -q --no-cache-dir --no-index --find-links "$WORK/wheels" -r "$GITHUB_ACTION_PATH/requirements.txt"
8699
87100
$PYTHON_CMD "$GITHUB_ACTION_PATH/main.py"
88101
env:

0 commit comments

Comments
 (0)