-
Notifications
You must be signed in to change notification settings - Fork 8
158 lines (132 loc) · 4.63 KB
/
ci.yml
File metadata and controls
158 lines (132 loc) · 4.63 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Python-Simulink CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
test:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest]
exclude:
# Windows with Python 3.12 has some compatibility issues
- os: windows-latest
python-version: "3.12"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip 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 and build libraries
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Build libraries with fallback support (MATLAB if available, manual build otherwise)
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "Building libraries with fallback support..."
make build-libraries || make build-all-so
fi
- name: Run linting
run: |
python -m flake8 --version || pip install flake8
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
python -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test all examples
run: |
# Install additional dependencies for testing
pip install pandas numpy matplotlib scipy control pytest pytest-cov
# Test all examples using our comprehensive test script
python test_all_examples.py
- name: Test Example2 with pytest
run: |
cd Example2
python -m pytest tests/ -v --tb=short
env:
# Set environment variable to handle .so file loading
LD_LIBRARY_PATH: ${{ github.workspace }}/Example2
build-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Build all examples and libraries
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Build all libraries with fallback support (MATLAB if available, manual build otherwise)
echo "Building all libraries with fallback support..."
make build-libraries || make build-all-libs || make build-examples
- name: Check for pre-built libraries
run: |
echo "Checking for pre-built libraries..."
make check-all-libs
- name: Validate Python files
run: |
echo "Validating Python files..."
make validate
- name: Upload generated libraries as artifacts
uses: actions/upload-artifact@v3
with:
name: linux-libraries
path: |
Example1/*.so
Example1/*.a
Example2/*.so
Example2/*.a
Example3/*.so
Example3/*.a
retention-days: 30
documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check documentation
run: |
echo "Checking README files..."
test -f README.md && echo "Main README exists"
test -f Example1/README.md && echo "Example1 README exists"
test -f Example2/README.md && echo "Example2 README exists"
test -f Example3/README.md && echo "Example3 README exists"
- name: Validate notebook files
run: |
echo "Checking notebook files..."
test -f Example1/dllModel.ipynb && echo "Example1 notebook exists"
test -f Example2/discrete_tf.ipynb && echo "Example2 notebook exists"
test -f Example3/bouncing_ball.ipynb && echo "Example3 notebook exists"
security:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run security scan
uses: snyk/actions/python@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high