-
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (91 loc) · 3.26 KB
/
python-ci.yml
File metadata and controls
110 lines (91 loc) · 3.26 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Python CI
on:
push:
branches: [ main ]
paths:
- 'implementations/raspberry-pi-i2c/**'
- '.github/workflows/python-ci.yml'
pull_request:
branches: [ main ]
paths:
- 'implementations/raspberry-pi-i2c/**'
- '.github/workflows/python-ci.yml'
jobs:
lint-python:
name: Lint Python Code
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
working-directory: implementations/raspberry-pi-i2c/firmware
run: |
python -m pip install --upgrade pip
pip install pylint flake8 pyflakes
# Install project dependencies (skip hardware-specific ones)
pip install python-osc netifaces || true
- name: Lint with Flake8
working-directory: implementations/raspberry-pi-i2c/firmware
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 src/ utils/ --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 src/ utils/ --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
- name: Check syntax with Pyflakes
working-directory: implementations/raspberry-pi-i2c/firmware
run: |
pyflakes src/*.py utils/*.py || exit 0
validate-config:
name: Validate Configuration
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Validate Python config files
working-directory: implementations/raspberry-pi-i2c/firmware/src
run: |
python -m py_compile config.py
python -m py_compile config_example.py
echo "Configuration files are valid Python"
- name: Check for sensitive data
run: |
# Ensure config_local.py is not committed
if [ -f implementations/raspberry-pi-i2c/firmware/src/config_local.py ]; then
echo "ERROR: config_local.py should not be committed!"
exit 1
fi
echo "No sensitive config files found - OK"
check-dependencies:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Verify requirements.txt
working-directory: implementations/raspberry-pi-i2c/firmware
run: |
pip install --upgrade pip
# Check if requirements.txt is valid
pip install --dry-run -r requirements.txt || exit 0
echo "requirements.txt is valid"
- name: Verify setup.py
working-directory: implementations/raspberry-pi-i2c/firmware
run: |
python setup.py check
echo "setup.py is valid"