Skip to content

Commit 4cbcd80

Browse files
committed
Fix venv check by inverting exit code and adding more info
1 parent b5c959f commit 4cbcd80

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

.github/workflows/internal-check-python-venv-support.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@ jobs:
3232
env:
3333
USE_VIRTUAL_PYTHON_ENVIRONMENT_VENV: "true"
3434
# 1. Run the script under test to create, activate and install the virtual environment
35-
# 2a. Run pip in dry-run mode without installing or resolving dependencies
36-
# 2b. Suppress all pip output (stderr)
37-
# 2c. Check if pip *would install* anything using grep
38-
# 2d. If there are missing dependencies and the environment is incomplete, return 1 (indicates all requirements already satisfied)
35+
# 2. Start with an overall check with pip
36+
# 3. Run pip in dry-mode with full output first to get all infos and fail on missing packages.
37+
# 4a. The leading exclamation mark tells the shell to invert the returned exit code.
38+
# Failing because "Would install" is missing leads to a successful execution.
39+
# 5b. Run pip in dry-run mode without installing or resolving dependencies
40+
# 5c. Suppress all pip output (stderr)
41+
# 5d. Check if pip *would install* anything using grep
42+
# 5e. If there are missing dependencies and the environment is incomplete, fail with code 1 (indicates all requirements already satisfied)
43+
#
44+
# Output installed dependencies for troubleshooting purposes:.venv/bin/pip freeze
45+
# TODO remove:
46+
# pip install --dry-run --ignore-installed --requirement "./requirements.txt"
47+
# ! pip install --dry-run --no-deps --no-cache-dir --no-index --requirement "./requirements.txt" 2>/dev/null | grep -q "Would install"
3948
run: |
40-
./scripts/activatePythonEnvironment.sh
41-
pip install --dry-run --no-deps --requirement "./requirements.txt" 2>/dev/null | grep -q "Would install" || return 1
49+
source ./scripts/activatePythonEnvironment.sh
50+
! .venv/bin/pip install --dry-run --no-deps --requirement requirements.txt 2>/dev/null

0 commit comments

Comments
 (0)