-
Notifications
You must be signed in to change notification settings - Fork 61
154 lines (143 loc) · 4.96 KB
/
sanity-check.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
name: Sanity check
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
find-subprojects:
runs-on: ubuntu-latest
outputs:
notebook: ${{ steps.categorize-subprojects.outputs.notebook }}
gradio: ${{ steps.categorize-subprojects.outputs.gradio }}
webcam: ${{ steps.categorize-subprojects.outputs.webcam }}
js: ${{ steps.categorize-subprojects.outputs.js }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Categorize subprojects
id: categorize-subprojects
run: |
notebook=()
gradio=()
webcam=()
js=()
for dir in $(find demos -type d -maxdepth 1 ! -name utils); do
if [ -f "$dir/package.json" ]; then
js+=("$dir")
elif [ -f "$dir/main.ipynb" ]; then
notebook+=("$dir")
elif grep -q "gradio" "$dir/requirements.txt"; then
gradio+=("$dir")
elif python $dir/main.py -h 2>/dev/null | grep -q -- "--stream"; then
webcam+=("$dir")
fi
done
notebook_json=$(printf '%s\n' "${notebook[@]}" | jq -R -s -c 'split("\n")[:-1]')
gradio_json=$(printf '%s\n' "${gradio[@]}" | jq -R -s -c 'split("\n")[:-1]')
webcam_json=$(printf '%s\n' "${webcam[@]}" | jq -R -s -c 'split("\n")[:-1]')
js_json=$(printf '%s\n' "${js[@]}" | jq -R -s -c 'split("\n")[:-1]')
echo "notebook=$notebook_json" | tee -a $GITHUB_OUTPUT
echo "gradio=$gradio_json" | tee -a $GITHUB_OUTPUT
echo "webcam=$webcam_json" | tee -a $GITHUB_OUTPUT
echo "js=$js_json" | tee -a $GITHUB_OUTPUT
notebook:
needs: find-subprojects
if: ${{ needs.find-subprojects.outputs.notebook != '[]' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.11]
subproject: ${{ fromJson(needs.find-subprojects.outputs.notebook) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
pip list
- name: Execute Notebook
run: |
cd ${{ matrix.subproject }}
jupyter nbconvert --to notebook --execute main.ipynb
gradio:
needs: find-subprojects
if: ${{ needs.find-subprojects.outputs.gradio != '[]' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.11]
subproject: ${{ fromJson(needs.find-subprojects.outputs.gradio) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
pip list
- name: Run Gradio App
run: |
cd ${{ matrix.subproject }}
python main.py
webcam:
needs: find-subprojects
if: ${{ needs.find-subprojects.outputs.webcam != '[]' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.11]
subproject: ${{ fromJson(needs.find-subprojects.outputs.webcam) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
pip list
- name: Download sample video file
run: |
cd ${{ matrix.subproject }}
curl -L -o sample_video.mp4 https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4
- name: Run Webcam Demo
run: |
cd ${{ matrix.subproject }}
python main.py --stream sample_video.mp4
js:
needs: find-subprojects
if: ${{ needs.find-subprojects.outputs.js != '[]' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
subproject: ${{ fromJson(needs.find-subprojects.outputs.js) }}
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: |
cd ${{ matrix.subproject }}
npm install
- name: Run JS Project
run: |
cd ${{ matrix.subproject }}
npm run start