-
Notifications
You must be signed in to change notification settings - Fork 80
112 lines (99 loc) · 3.69 KB
/
ci_docs.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
name: validate Docs
on: # Trigger the workflow on push or pull request
# push:
# branches: [main]
pull_request: {}
schedule:
# At the end of every day
- cron: "0 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
build-docs:
runs-on: ubuntu-latest
env:
PUB_BRANCH: publication
PATH_DATASETS: ${{ github.workspace }}/.datasets
timeout-minutes: 20
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches and tags
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('_requirements/docs.txt') }}
restore-keys: pip-
- name: Install dependencies
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y tree
# install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux
sudo apt-get install -y cmake pandoc texlive-latex-extra dvipng texlive-pictures
pip --version
pip install -q -r requirements.txt -r _requirements/docs.txt
pip list
shell: bash
- name: Process folders
run: |
mkdir -p ${PATH_DATASETS}
head=$(git rev-parse origin/"${{ github.base_ref }}")
git diff --name-only $head --output=master-diff.txt
python .actions/assistant.py group-folders master-diff.txt
printf "Changed folders:\n"
cat changed-folders.txt
shell: bash
- name: ">> output"
id: changed
run: python -c "lines = open('changed-folders.txt').readlines(); print(f'::set-output name=nb_dirs::{len(lines)}')"
- uses: oleksiyrudenko/gha-git-credentials@v2.1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
global: true
- name: Sync to pub
run: git merge -s resolve origin/$PUB_BRANCH
- name: Generate notebooks
if: steps.changed.outputs.nb_dirs != 0
run: |
# second half with || [...] is needed for reading the last line
while read -r line || [ -n "$line" ]; do
python .actions/assistant.py convert-ipynb $line
python .actions/assistant.py bash-render $line
cat .actions/_ipynb-render.sh
bash .actions/_ipynb-render.sh
done <<< $(cat changed-folders.txt)
env:
DRY_RUN: 1
shell: bash
- name: Copy notebooks
if: steps.changed.outputs.nb_dirs != 0
run: |
# second half with || [...] is needed for reading the last line
while read -r line || [ -n "$line" ]; do
dir=$(dirname $line)
mkdir -p changed-notebooks/${dir}
cp .notebooks/${line}.ipynb changed-notebooks/${dir}/
done <<< $(cat changed-folders.txt)
tree changed-notebooks
shell: bash
- uses: actions/upload-artifact@v3
if: steps.changed.outputs.nb_dirs != 0
with:
name: notebooks-${{ github.sha }}
path: changed-notebooks/
- name: Make Documentation
working-directory: ./_docs
run: make html --jobs $(nproc) --debug SPHINXOPTS="-W --keep-going" linkcheck
- name: Upload built docs
uses: actions/upload-artifact@v3
with:
name: docs-html-${{ github.sha }}
path: _docs/build/html/
# Use always() to always run this step to publish test results when there are test failures
if: success()