-
Notifications
You must be signed in to change notification settings - Fork 13
80 lines (74 loc) · 3.13 KB
/
execute-nbs.yaml
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
name: Execute notebooks
on:
pull_request:
branches: [main]
paths:
- "docs/**"
- "environment.yml"
jobs:
runnbs:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if env file has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
- name: Cache notebooks
uses: actions/cache@v2
env:
# Increase this value to reset cache if env file has not changed
CACHE_NUMBER: 0
with:
path: .jupyter_cache
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: tutorials
channel-priority: strict
environment-file: environment.yml
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
use-only-tar-bz2: true # This needs to be set for caching to work properly!
- name: execute notebooks
run: |
mkdir -p .jupyter_cache
# set kernel to "python3" (just in case someone used a custom conda env kernel locally)
for f in docs/notebooks/*.ipynb ; do
jupytext --to notebook --set-kernel python3 $f
done
# First remove all notebooks from the project, then add all again.
# This does not remove them from the cache. This step is required since a notebook could be in the cache, but not in the PR.
jcache notebook clear --force
jcache notebook add docs/notebooks/*.ipynb
jcache project execute --timeout 1800
- name: output logs
run: |
jcache notebook list
for f in docs/notebooks/*.ipynb ; do
jcache notebook info --tb $f
done
# write changed outputs back to the ipynb files
# will fail if there was an execution error
- name: merge notebooks
run: |
for f in docs/notebooks/*.ipynb ; do
jcache notebook merge $f $f
done
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Render notebooks