Skip to content

Commit 0c4d54b

Browse files
committed
Add GitHub action to test Python venv
1 parent 5d8436e commit 0c4d54b

File tree

2 files changed

+42
-124
lines changed

2 files changed

+42
-124
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Check Python venv virtual environment
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
# Only watch changes related to Python virtual environment venv
8+
paths:
9+
- 'requirements.txt'
10+
- 'scripts/activatePythonEnvironment.sh'
11+
- '.github/workflows/internal-check-python-venv-support.yml' # or when this file changed
12+
13+
jobs:
14+
check-python-venv-environment:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-22.04
20+
python: 3.12
21+
22+
steps:
23+
- name: Checkout GIT Repository
24+
uses: actions/checkout@v4
25+
26+
- name: (Python Setup) Use version ${{ matrix.python }} with venv environment management module
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python }}
30+
cache: 'pip'
31+
32+
- name: Create, activate, install and check virtual environment
33+
env:
34+
USE_VIRTUAL_PYTHON_ENVIRONMENT_VENV: "true"
35+
# 1. Run the script under test to create, activate and install the virtual environment
36+
# 2a. Run pip in dry-run mode without installing or resolving dependencies
37+
# 2b. Suppress all pip output (stderr)
38+
# 2c. Check if pip *would install* anything using grep
39+
# 2d. If there are missing dependencies and the environment is incomplete, return 1 (indicates all requirements already satisfied)
40+
run: |
41+
./scripts/activatePythonEnvironment.sh
42+
pip install --dry-run --no-deps --requirement "./requirements.txt" 2>/dev/null | grep -q "Would install" || return 1

.github/workflows/internal-java-code-analysis-venv-draft.yml

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)