-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (67 loc) · 2.49 KB
/
python-app.yml
File metadata and controls
80 lines (67 loc) · 2.49 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
# GitHub Actions for Python CI/CD
name: Python CI/CD Workflow
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12.3"] # ✅ Match local Python version
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pylint pytest-cov pytest-xdist pytest-timeout
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Debug - List all files
run: |
echo "📂 Listing all files in workspace:"
ls -R
echo "📂 Checking app/plugins directory:"
ls -R app/plugins || echo "⚠️ No plugins found"
- name: Install Project (Editable Mode)
run: |
if [ -f setup.py ]; then
pip install -e .
else
echo "⚠️ setup.py not found. Skipping editable install."
fi
- name: Ensure required directories and files exist
run: |
mkdir -p logs
touch logs/app.log
touch history.csv
echo "id,a,b,operation,result" > history.csv # ✅ Ensure history.csv is not empty
echo "✅ Logs and history file initialized"
- name: Debug - Check history.csv contents
run: |
echo "🔍 Checking history.csv contents:"
cat history.csv || echo "⚠️ history.csv is empty!"
- name: Run Linter (Pylint)
run: |
CHANGED_FILES=$(git diff --name-only origin/main | grep '\.py$' || echo "")
if [ -n "$CHANGED_FILES" ]; then pylint $CHANGED_FILES --exit-zero; else echo "No Python files changed"; fi
- name: Run Tests with Coverage (Sequential Execution to Match Local)
run: |
pytest --cov --cov-report=term-missing --cov-fail-under=89.5
echo "✅ Pytest completed"