11# Name of the GitHub Actions workflow
2- name : Python Virtual Environment Setup CI
2+ name : Python Virtual Environment Creator Tests
33
4- # Define when this workflow should run
4+ # Define when this workflow should be triggered
55on :
6+ # Trigger on push events to main and develop branches
67 push :
7- branches : [ main ] # Trigger on pushes to main branch
8+ branches : [ main, develop ]
9+ # Trigger on pull requests to main and develop branches
810 pull_request :
9- branches : [ main ] # Trigger on pull requests to main branch
11+ branches : [ main, develop ]
1012
11- # Define the jobs to run
13+ # Define the jobs to run as part of this workflow
1214jobs :
13- # First job: testing across different OS and Python versions
15+ # Job for running tests across different environments
1416 test :
15- # Dynamic OS selection based on matrix strategy
17+ # Dynamic name showing OS and Python version being tested
18+ name : Test on ${{ matrix.os }} / Python ${{ matrix.python-version }}
19+ # OS to run the job on, pulled from matrix strategy
1620 runs-on : ${{ matrix.os }}
1721 strategy :
22+ # Continue running other matrix combinations even if one fails
23+ fail-fast : false
24+ # Define test matrix - will run tests on all combinations of these
1825 matrix :
19- # Define test matrix: will run tests on all combinations of these
20- os : [ubuntu-latest, windows-latest, macos-latest] # Test on all major OS
21- python-version : ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] # Test on multiple Python versions
26+ os : [ubuntu-latest, windows-latest, macos-latest]
27+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
2228
2329 steps :
24- # Step 1: Check out the repository code
30+ # Check out the repository code
2531 - uses : actions/checkout@v3
26-
27- # Step 2: Set up Python environment
32+
33+ # Set up Python environment with specified version
2834 - name : Set up Python ${{ matrix.python-version }}
2935 uses : actions/setup-python@v4
3036 with :
3137 python-version : ${{ matrix.python-version }}
32-
33- # Step 3: Install required Python packages
38+ architecture : x64
39+
40+ # Install required Python packages for testing
3441 - name : Install dependencies
3542 run : |
36- python -m pip install --upgrade pip # Upgrade pip to latest version
37- pip install pytest pytest-cov flake8 # Install testing and linting tools
38-
39- # Step 4: Run code quality checks with flake8
40- - name : Lint with flake8
41- run : |
42- # Check for specific critical errors
43- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
44- # Check overall code quality
45- flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
46-
47- # Step 5: Create a test virtual environment
48- - name : Create test virtual environment
43+ python -m pip install --upgrade pip
44+ pip install pytest pytest-cov mypy types-setuptools
45+
46+ # Run static type checking with mypy in strict mode
47+ - name : Run type checking
4948 run : |
50- python -m venv test_venv
51-
52- # Step 6: Run tests with coverage reporting
53- - name : Test VenvCreator
49+ mypy venv_creator.py test_venv_creator.py --strict
50+
51+ # Run tests with pytest and generate coverage report
52+ - name : Run tests with coverage
5453 run : |
55- pytest -- cov=. --cov-report=xml # Run tests and generate coverage report
56-
57- # Step 7: Upload coverage reports to Codecov
54+ pytest test_venv_creator.py -v -- cov=. --cov-report=xml
55+
56+ # Upload test coverage data to Codecov
5857 - name : Upload coverage to Codecov
5958 uses : codecov/codecov-action@v3
6059 with :
61- file : ./coverage.xml # Coverage report file
62- flags : unittests # Tag these results as unit tests
63- fail_ci_if_error : true # Fail if upload to Codecov fails
60+ file : ./coverage.xml
61+ flags : unittests
62+ name : codecov-${{ matrix.os }}-py${{ matrix.python-version }}
63+ fail_ci_if_error : false
64+
65+ # Job for code linting checks
66+ lint :
67+ name : Lint
68+ runs-on : ubuntu-latest
69+ steps :
70+ # Check out repository code
71+ - uses : actions/checkout@v3
72+
73+ # Set up Python 3.11 environment for linting
74+ - name : Set up Python
75+ uses : actions/setup-python@v4
76+ with :
77+ python-version : ' 3.11'
78+
79+ # Install linting tools
80+ - name : Install dependencies
81+ run : |
82+ python -m pip install --upgrade pip
83+ pip install flake8 black isort
84+
85+ # Run various linting checks:
86+ # - flake8 for code style and errors
87+ # - black for code formatting
88+ # - isort for import sorting
89+ - name : Run linters
90+ run : |
91+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
92+ black . --check
93+ isort . --check-only --profile black
6494
65- # Second job: security scanning
95+ # Job for security vulnerability scanning
6696 security :
67- runs-on : ubuntu-latest # Security checks only need to run on one OS
97+ name : Security checks
98+ runs-on : ubuntu-latest
6899 steps :
69- # Step 1: Check out the repository code
100+ # Check out repository code
70101 - uses : actions/checkout@v3
71-
72- # Step 2: Set up Python environment
102+
103+ # Set up Python 3.11 environment for security checks
73104 - name : Set up Python
74105 uses : actions/setup-python@v4
75106 with :
76- python-version : ' 3.10 ' # Use Python 3.10 for security checks
77-
78- # Step 3: Install security scanning tools
79- - name : Install security scanning tools
107+ python-version : ' 3.11 '
108+
109+ # Install security scanning tools
110+ - name : Install dependencies
80111 run : |
81- pip install bandit safety # bandit for code scanning, safety for dependency checking
82-
83- # Step 4: Run security scans
84- - name : Run security scan
112+ python -m pip install --upgrade pip
113+ pip install bandit safety
114+
115+ # Run security checks:
116+ # - bandit for code security issues
117+ # - safety for known vulnerabilities in dependencies
118+ - name : Run security checks
85119 run : |
86- bandit -r . # Recursively scan all Python files for security issues
87- safety check # Check dependencies for known security vulnerabilities
120+ bandit -r . -c pyproject.toml
121+ safety check
0 commit comments