-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinternal-check-python-venv-support.yml
More file actions
48 lines (43 loc) · 2.04 KB
/
internal-check-python-venv-support.yml
File metadata and controls
48 lines (43 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Check Python venv virtual environment
on:
pull_request:
branches:
- main
# Only watch changes related to Python virtual environment venv
paths:
- 'requirements.txt'
- 'scripts/activatePythonEnvironment.sh'
- '.github/workflows/internal-check-python-venv-support.yml' # or when this file changed
jobs:
check-python-venv-environment:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- python: 3.12
steps:
- name: Checkout GIT Repository
uses: actions/checkout@v6
- name: (Python Setup) Use version ${{ matrix.python }} with venv environment management module
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Activate virtual environment using venv and check if the required packages were installed
env:
USE_VIRTUAL_PYTHON_ENVIRONMENT_VENV: "true"
# 1. Run the script under test to create, activate and install the virtual environment
# 2. Run pip install for the current environment in dry-mode with full output first to get all infos and fail on missing packages.
# 3a. The leading exclamation mark tells the shell to invert the returned exit code.
# Failing because "Would install" is missing leads to a successful execution.
# 3b. Run pip install for the current environment in dry-run mode without installing or resolving dependencies
# 3c. Suppress all pip output (stderr)
# 3d. Check if pip would install anything using grep
# 3e. If there are missing dependencies and the environment is incomplete,
# fail with code 1 (indicates all requirements already satisfied)
#
# Output installed dependencies for troubleshooting purposes:.venv/bin/pip freeze
run: |
source ./scripts/activatePythonEnvironment.sh
.venv/bin/pip install --dry-run --quiet --requirement requirements.txt
! .venv/bin/pip install --dry-run --requirement requirements.txt 2>/dev/null | grep -q "Would install"