forked from PyDMD/PyDMD
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (155 loc) · 5.19 KB
/
testing_pr.yml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: "Testing Pull Request"
on:
pull_request:
branches:
- "master"
jobs:
prepare_matrix: ##############################################################################
runs-on: ubuntu-latest
outputs:
matrix_unit_test: ${{ steps.setmatrix.outputs.matrix1 }}
matrix_tutorial_test: ${{ steps.setmatrix.outputs.matrix2 }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
- name: Set Dynamic Matrix
id: setmatrix
run: |
matrix_str=$(python utils/info2json.py testing_matrix)
echo "matrix1=$matrix_str" >> $GITHUB_OUTPUT
matrix_str=$(python utils/info2json.py tutorial_testing_matrix)
echo "matrix2=$matrix_str" >> $GITHUB_OUTPUT
check_matrix: ##############################################################################
runs-on: ubuntu-latest
needs: prepare_matrix
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.prepare_matrix.outputs.matrix_unit_test }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
black: ######################################################################################
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install black
run: |
pip install black[jupyter]
- name: Run black formatter on PyDMD source code
run: |
black --check --diff --color pydmd/ utils/ tests/ setup.py
if [[ $? -ne "0" ]]; then
echo "Source code needs re-formatting"
exit 1
fi
- name: Run black formatter on PyDMD tutorials
run: |
black --check --diff --color tutorials/
if [[ $? -ne "0" ]]; then
echo "Tutorials need re-formatting"
exit 1
fi
sort_dependencies: ##########################################################################
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install isort
run: |
pip install isort
- name: Run isort on PyDMD source code
run: |
OUT=$(isort pydmd/ tests/)
if [[ $OUT ]]; then
echo "All imports are properly sorted"
else
echo "$OUT"
fi
unit_test: #################################################################################
needs: prepare_matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJson(needs.prepare_matrix.outputs.matrix_unit_test) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install .[test]
- name: Test with pytest
run: |
pytest
tutorial_test: ##############################################################################
needs: prepare_matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJson(needs.prepare_matrix.outputs.matrix_tutorial_test) }}
fail-fast: false
env:
TUTORIAL_TIMEOUT: 1200s
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .[test]
# Dependencies for tutorials
pip install jupyter pandas opencv-python ffmpeg-python
# timeout not available by default on MacOS
brew install coreutils || true
- uses: actions/cache@v2
id: cache-segtrackv2
with:
path: ./tutorials/tutorial12/SegTrackv2
key: SegTrackv2-key
# This is needed for tutorial12 for large file download
- name: Download SegTrackv2
if: steps.cache-segtrackv2.outputs.cache-hit != 'true'
run: |
curl https://web.engr.oregonstate.edu/~lif/SegTrack2/SegTrackv2.zip --output SegTrackv2.zip
unzip -qq SegTrackv2.zip
mv SegTrackv2 tutorials/tutorial12
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Check tutorial references
run: |
cd tutorials/
for dir in $(ls -d tutorial*/); do
if grep -q "$dir" "README.md"
then
echo "$dir is referenced"
else
echo "$dir not referenced"
exit 1
fi
done
- name: Test tutorials
run: |
set -x
cd tutorials/
for dir in $(ls -d tutorial*/); do
if [[ $dir != tutorial5* ]]
then
cd $dir
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --to notebook --execute *.ipynb
cd ..
fi
done
set +x