Skip to content

Commit 356f0a3

Browse files
committed
feat: added workflow for PR validation with pylint and pytests
1 parent 9bde132 commit 356f0a3

19 files changed

Lines changed: 600 additions & 47 deletions

.github/workflows/lint.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint
2+
3+
# This workflow runs when a pull request is opened or updated
4+
on:
5+
pull_request:
6+
branches: [ main ]
7+
types: [ opened, synchronize, reopened ]
8+
# Optional: Run on push to main as well to ensure main stays clean
9+
push:
10+
branches: [ main ]
11+
12+
jobs:
13+
pylint:
14+
name: Pylint Validation
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.9'
25+
cache: 'pip'
26+
27+
# Install dependencies needed for linting
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install pylint
32+
# Install package dependencies
33+
pip install -e .
34+
# Install test dependencies
35+
pip install -e ".[test]"
36+
37+
# Run pylint on the src directory using the .pylintrc configuration
38+
- name: Run pylint
39+
run: |
40+
pylint --rcfile=pylintrc src/secops

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test
2+
3+
# This workflow runs when a pull request is opened or updated
4+
on:
5+
pull_request:
6+
branches: [ main ]
7+
types: [ opened, synchronize, reopened ]
8+
# Optional: Run on push to main as well
9+
push:
10+
branches: [ main ]
11+
12+
jobs:
13+
tox:
14+
name: Run Tests with Tox
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
# Define Python versions as specified in tox.ini
19+
python-version: ['3.9','3.10','3.11','3.12']
20+
21+
steps:
22+
- name: Check out repository code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
cache: 'pip'
30+
31+
# Install tox and dependencies
32+
- name: Install tox
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install tox
36+
37+
# Run tox for the specific Python version with coverage, excluding integration tests
38+
- name: Run tox with coverage
39+
run: |
40+
tox -- -m "not integration" --cov=secops --cov-report=xml --cov-report=term -vv -n auto
41+
env:
42+
PYTHONPATH: ${{ github.workspace }}
43+
# Map GitHub Actions Python versions to tox environments
44+
TOXENV: py${{ matrix.python-version == '3.9' && '39' || matrix.python-version == '3.10' && '310' || matrix.python-version == '3.11' && '311' || matrix.python-version == '3.12' && '312'}}
45+
46+
# Only run coverage checks on Python 3.9
47+
- name: Check coverage threshold
48+
if: matrix.python-version == '3.9'
49+
run: |
50+
pip install coverage
51+
coverage report --fail-under=60
52+
53+
# Only upload coverage report for Python 3.9
54+
- name: Upload coverage report
55+
if: matrix.python-version == '3.9'
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: coverage-report
59+
path: coverage.xml
60+
retention-days: 7

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ tests/config.py
22
env/
33
.pytest_cache/
44
__pycache__/
5-
.github/
5+
# GitHub workflow files are now allowed
6+
# Previously: .github/
7+
68
.vscode/
79
.env
810
how-to-upload.txt
@@ -16,4 +18,5 @@ temp_test_data_tables.py
1618
/.idea/
1719
*.iml
1820
tests/config_prbss.py
19-
tests/config_purple.py
21+
tests/config_purple.py
22+
.tox

0 commit comments

Comments
 (0)