-
Notifications
You must be signed in to change notification settings - Fork 6
155 lines (136 loc) · 4.98 KB
/
test_changed_notebook.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
# This workflows executes new or modified example notebooks.
name: test_changed_notebooks
defaults:
run:
shell: bash # To override PowerShell on Windows
on:
# Trigger the workflow on push or PR to any branch
push:
paths:
- '**/*.ipynb'
pull_request:
paths:
- '**/*.ipynb'
# don't trigger for draft PRs
types: [ opened, synchronize, reopened, ready_for_review ]
# Trigger the workflow on manual dispatch
workflow_dispatch:
jobs:
select-runner:
runs-on: ubuntu-22.04
outputs:
runner: ${{ steps.select_runner.outputs.runner }}
steps:
- uses: actions/checkout@v3
- name: Select runner
id: select_runner
run: |
if [ "${{ github.repository }}" = "NeuroDesk/example-notebooks" ]; then
echo "runner=cirun-oracle--${{ github.run_id }}" >> $GITHUB_OUTPUT
else
echo "runner=ubuntu-22.04" >> $GITHUB_OUTPUT
fi
get-notebooks:
runs-on: ubuntu-22.04
outputs:
notebook_list: ${{ steps.list_changed_notebooks.outputs.notebook_list }}
steps:
- uses: actions/checkout@v3
- name: Find all notebooks with changes
id: find_changed_notebooks
uses: tj-actions/[email protected]
with:
files: "books/**"
dir_names_exclude_current_dir: "true"
- name: Filter down to changed notebooks
id: list_changed_notebooks
run: |
echo ${{ steps.find_changed_notebooks.outputs.all_changed_and_modified_files }}
changed_notebooks=$(echo "${{ steps.find_changed_notebooks.outputs.all_changed_and_modified_files }}")
notebook_list='['
for NOTEBOOK in $(echo "${changed_notebooks}"); do
notebook_list+="\"${NOTEBOOK}\","
done
notebook_list=$(sed '$s/,$//' <<< $notebook_list)
notebook_list+=']'
echo "notebook_list=${notebook_list}"
echo "notebook_list=${notebook_list}" >> $GITHUB_OUTPUT
test-notebooks:
needs: [ select-runner, get-notebooks ]
if: ${{ needs.get-notebooks.outputs.notebook_list != '[]' }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
notebooks: ${{ fromJson(needs.get-notebooks.outputs.notebook_list) }}
steps:
- uses: actions/checkout@v3
- name: Test singularity and cvmfs before pushing to neurocommand
run:
/bin/bash .github/workflows/setup_cvmfs.sh
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install jupyter-book ghp-import graphviz ipyniivue
- name: Run ${{ matrix.notebooks }}
shell: bash
run: |
echo ${{ github.workspace }}
echo $GITHUB_WORKSPACE
export PATH=$HOME/.local/bin:$PATH
echo "PATH=$PATH"
export LD_PRELOAD=
echo "LD_PRELOAD=$LD_PRELOAD"
export APPTAINER_BINDPATH=${{ github.workspace }},/cvmfs
echo "APPTAINER_BINDPATH=$APPTAINER_BINDPATH"
export LMOD_CMD=/usr/share/lmod/lmod/libexec/lmod
export MPLCONFIGDIR=${{ github.workspace }}/matplotlib-mpldir
export MODULEPATH=$(find /cvmfs/neurodesk.ardc.edu.au/neurodesk-modules/ -maxdepth 1 -mindepth 1 -type d -exec realpath {} \; | tr '\n' ':')
echo "MODULEPATH=$MODULEPATH"
sed -i 's/timeout:.*/timeout: 200/' _config.yml
echo "NOTEBOOK=$(basename -s .ipynb ${{ matrix.notebooks }})" >> $GITHUB_ENV
echo "DIRNAME=$(dirname ${{ matrix.notebooks }})" >> $GITHUB_ENV
jb build ${{ matrix.notebooks }}
- name: Restructure
shell: bash
run: |
tree ./books/_build/**/**/html
mkdir -p ./books/_build/**/**/html/$DIRNAME
cp -R ./books/_build/**/**/html/_static ./books/_build/**/**/html/$DIRNAME
if [ -d ./books/_build/**/**/html/_images ]; then
cp -R ./books/_build/**/**/html/_images ./books/_build/**/**/html/$DIRNAME
fi
cp ./books/_build/**/**/html/$NOTEBOOK.html ./books/_build/**/**/html/$DIRNAME
- name: Push to GitHub Pages
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./books/_build/**/**/html
keep_files: true
cname: www.neurodesk.org
build-structure:
needs: [ test-notebooks ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install jupyter-book ghp-import graphviz ipyniivue
- name: Run all
shell: bash
working-directory: ./books
run: |
export PATH=$HOME/.local/bin:$PATH
sed -i 's/execute_notebooks: .*/execute_notebooks: off/' _config.yml
cat _config.yml
jb build .
- name: Push to GitHub Pages
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./books/_build/html
keep_files: true
cname: www.neurodesk.org