-
Notifications
You must be signed in to change notification settings - Fork 115
148 lines (145 loc) · 5.68 KB
/
Copy pathtest-doc-notebooks.yml
File metadata and controls
148 lines (145 loc) · 5.68 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
name: Test documentation notebooks
on:
push:
paths:
- '**'
- '!*'
- '*.py'
- '*.c'
- '*.cpp'
- '*.h'
- '!doc/**'
- 'doc/source/tutorials/**/*.ipynb'
- '!.github/**'
- '.github/workflows/test-doc-notebooks.yml'
pull_request:
paths:
- '**'
- '!doc/**'
- 'doc/source/tutorials/**/*.ipynb'
schedule:
# 00:00 UTC on the 15th of every month, so the result is fresh input
# for the update-doc-notebooks workflow that runs later the same day.
- cron: '0 0 15 * *'
permissions:
# Needed so scheduled runs can delete the cached Gaia DR3 query result via
# `gh cache delete` to force a fresh fetch.
actions: write
contents: read
jobs:
run-notebooks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '${{ matrix.python-version }}'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgsl-dev
# Verify GSL is discoverable so galpy's C extensions build correctly
gsl-config --version
gsl-config --cflags
gsl-config --libs
- name: Clone Torus code for actionAngleTorus
run: |
git clone https://github.com/jobovy/Torus.git galpy/actionAngle/actionAngleTorus_c_ext/torus
cd galpy/actionAngle/actionAngleTorus_c_ext/torus
git checkout galpy
cd -
- name: Install galpy and notebook dependencies
run: |
pip install --upgrade pip
# Verbose install so that any GSL/C-extension build issues are visible
# in CI logs.
pip install -v ".[docs]"
pip install jupyter nbconvert nbformat papermill astropy astroquery pyvo numexpr pynbody rebound jax jaxlib
- name: Cache pynbody test snapshot
id: cache-snapshot
uses: actions/cache@v5
with:
path: doc/source/tutorials/potentials/gasoline_ahf
key: pynbody-g15784-v2
- name: Download pynbody test snapshot
if: steps.cache-snapshot.outputs.cache-hit != 'true'
run: |
cd doc/source/tutorials/potentials
curl -L -o gasoline.tar.gz "https://zenodo.org/records/12687409/files/gasoline.tar.gz?download=1"
tar -xzf gasoline.tar.gz gasoline_ahf/
rm gasoline.tar.gz
- name: Refresh Gaia DR3 cache on scheduled runs
# Delete the cached Gaia query result so the staeckel notebook re-runs
# the query and stores fresh data. On non-scheduled runs we skip this
# so the cached result is reused and the ESA Gaia archive query is
# avoided (typically ~5 min, but observed up to ~2 h when the archive
# is degraded).
if: github.event_name == 'schedule'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
run: |
gh cache delete gaia-dr3-solar-neighborhood-v1 --repo "${{ github.repository }}" \
|| echo "No prior Gaia DR3 cache to delete."
- name: Cache Gaia DR3 query result
# Speeds the staeckel notebook up massively on routine runs. The cache
# is refreshed by the scheduled workflow above (and on first run).
uses: actions/cache@v5
with:
path: doc/source/tutorials/action_angle/gaia_dr3_solar_neighborhood.fits
key: gaia-dr3-solar-neighborhood-v1
- name: Refresh Dierickx 2010 cache on scheduled runs
# Delete the cached Vizier query result so the orbit/examples notebook
# re-runs the query and stores fresh data. On non-scheduled runs we
# skip this so the cached result is reused and the Vizier query (which
# has been observed to fail intermittently in CI) is avoided.
if: github.event_name == 'schedule'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
run: |
gh cache delete dierickx-2010-thick-disk-v1 --repo "${{ github.repository }}" \
|| echo "No prior Dierickx 2010 cache to delete."
- name: Cache Dierickx 2010 thick-disk catalog
# Speeds the orbit/examples notebook up and avoids transient Vizier
# failures on routine runs. Refreshed by the scheduled workflow above
# (and on first run).
uses: actions/cache@v5
with:
path: doc/source/tutorials/orbits/dierickx_2010_thick_disk.fits
key: dierickx-2010-thick-disk-v1
- name: Strip notebook outputs
run: |
for nb in $(find doc/source/tutorials -name '*.ipynb'); do
jupyter nbconvert --clear-output --inplace "$nb"
done
- name: Run all tutorial notebooks
run: |
failed_nbs=()
outdir=$(mktemp -d)
for nb in $(find doc/source/tutorials -name '*.ipynb' | sort); do
echo "::group::Running $nb"
outname=$(basename "$nb")
nbdir=$(dirname "$nb")
if papermill --request-save-on-cell-execute --log-output \
--cwd "$nbdir" "$nb" "$outdir/$outname"; then
echo "PASSED: $nb"
else
echo "::error file=$nb::FAILED: $nb"
failed_nbs+=("$nb")
fi
echo "::endgroup::"
done
rm -rf "$outdir"
if [ "${#failed_nbs[@]}" -gt 0 ]; then
echo "::error::The following notebooks failed execution:"
for nb in "${failed_nbs[@]}"; do
echo "::error file=$nb::$nb"
done
exit 1
fi