Skip to content

Commit d3ddcb8

Browse files
nammnclaude
andcommitted
Use venv for pre-commit in CI instead of pip install
The CI creates a venv via python_venv setup step that has pre-commit installed from requirements.txt. Activate this venv instead of trying to install pre-commit via pip which creates PATH issues. This matches how the master branch script activates the venv before running pre-commit hooks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b3f3800 commit d3ddcb8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

scripts/evergreen/check_precommit.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ initial_index_state=$(git diff --name-only --cached --diff-filter=AM)
66

77
export EVERGREEN_MODE=true
88

9-
# Install pre-commit if not available
10-
if ! command -v pre-commit >/dev/null 2>&1; then
11-
echo "Installing pre-commit..."
12-
pip install pre-commit
13-
# Add ~/.local/bin to PATH if it exists (pip installs scripts there)
14-
if [[ -d "${HOME}/.local/bin" ]]; then
15-
export PATH="${HOME}/.local/bin:${PATH}"
16-
fi
9+
# Activate the venv if it exists (CI creates this via python_venv setup step)
10+
# The venv contains pre-commit installed from requirements.txt
11+
if [[ -f "venv/bin/activate" ]]; then
12+
echo "Activating venv..."
13+
# shellcheck disable=SC1091
14+
source venv/bin/activate
1715
fi
1816

17+
# pre-commit should now be available from the venv
1918
echo "Running pre-commit hooks..."
2019
echo "pre-commit version: $(pre-commit --version)"
2120

0 commit comments

Comments
 (0)