-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (69 loc) · 2.55 KB
/
Copy pathmain.yml
File metadata and controls
88 lines (69 loc) · 2.55 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Multi-Folder Python CI/CD
# Trigger the workflow on push and pull requests
on:
push:
branches: [master, unittest]
pull_request:
branches: [ master ]
jobs:
# Job 1: Code Quality and Linting
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install quality tools
run: |
python -m pip install --upgrade pip
pip install black isort pylint
- name: Check code with pylint
run: |
pylint --exit-zero --output-format=text . --ignore=venv,env,.venv,.env || echo "Pylint completed with issues"
continue-on-error: true
- name: Check import sorting with isort
run: |
isort --check-only --diff . || echo "Import sorting issues found (not blocking)"
continue-on-error: true
# Job 2: Run Unit Tests
run-tests:
runs-on: ubuntu-latest
needs: [code-quality]
strategy:
matrix:
python-version: [3.9, '3.10']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov coverage
# Install requirements if available
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Install common packages
pip install requests numpy pandas || echo "Some packages failed"
- name: Run all unit tests with pytest
run: |
echo "Running tests with pytest..."
python -m pytest -v --tb=short --cov=. --cov-report=xml --cov-report=term-missing --ignore=venv --ignore=.venv || echo "pytest completed with issues"
- name: Run unittest discovery
run: |
echo "Running tests with unittest discovery..."
python -m unittest discover -s . -p "test_*.py" -v 2>&1 || echo "unittest discovery completed with issues"
- name: Run individual test files
run: |
echo "Running individual test files..."
find . -name "test_*.py" -not -path "./venv/*" | while read test_file; do
echo "=== Running $test_file ==="
cd "$(dirname "$test_file")"
python "$(basename "$test_file")" || echo "Failed: $test_file"
cd - > /dev/null
done