-
Notifications
You must be signed in to change notification settings - Fork 2
53 lines (49 loc) · 1.45 KB
/
example-execution.yml
File metadata and controls
53 lines (49 loc) · 1.45 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
name: Example Execution
on:
push:
pull_request:
jobs:
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run examples in fresh virtual environments
run: |
set -euo pipefail
found=0
failed=0
for example in examples/*; do
[ -d "$example" ] || continue
entry=""
if [ -f "$example/run_demo.py" ]; then
entry="run_demo.py"
elif [ -f "$example/main.py" ]; then
entry="main.py"
else
continue
fi
found=1
echo "::group::$example"
venv="$(mktemp -d)"
python -m venv "$venv"
"$venv/bin/python" -m pip install --upgrade pip
"$venv/bin/python" -m pip install -e .
if [ -f "$example/requirements.txt" ]; then
"$venv/bin/python" -m pip install -r "$example/requirements.txt"
fi
if ! (cd "$example" && "$venv/bin/python" "$entry"); then
failed=1
echo "FAIL $example"
else
echo "PASS $example"
fi
rm -rf "$venv"
echo "::endgroup::"
done
if [ "$found" -eq 0 ]; then
echo "No examples with run_demo.py or main.py found."
fi
exit "$failed"