-
Notifications
You must be signed in to change notification settings - Fork 38
165 lines (141 loc) · 5.13 KB
/
notebook_ci.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
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
156
157
158
159
160
161
162
163
164
165
name: CI build
on:
push:
pull_request:
workflow_dispatch:
defaults:
run:
shell: bash -l {0}
jobs:
pytests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- qutip-version: '4'
qutip-branch: 'qutip-4.7.X'
- qutip-version: '5'
qutip-branch: 'master'
steps:
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
folder-path: tutorials-v${{ matrix.qutip-version }}
#use config file to define 403 and 405 errors as valid links
#(APS blocks this link check)
config-file: mlc_config.json
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: test-environment-v${{ matrix.qutip-version }}
use-mamba: true
- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash
- name: Cache Conda env
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('test_environment.yml') }}-${{ env.CACHE_NUMBER }}-qutip-${{ matrix.qutip-version }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache
- name: Install environment
if: steps.cache.outputs.cache-hit != 'true'
run: mamba env update -n test-environment-v${{ matrix.qutip-version }} -f test_environment-v${{ matrix.qutip-version }}.yml
- name: Install QuTiP
run: |
pip install --upgrade pip
python -m pip install jax jax[cpu] equinox diffrax
git clone -b ${{ matrix.qutip-branch }} https://github.com/qutip/qutip.git
cd qutip
pip install -r requirements.txt
pip install .
cd ..
python -m pip install git+https://github.com/qutip/qutip-qip
python -m pip install --no-deps git+https://github.com/qutip/qutip-jax
git clone -b master https://github.com/qutip/qutip-qtrl.git
cd qutip-qtrl
# install qutip-qtrl without deps because it requires qutip 5.0.0a1
pip install --no-deps -e .
- name: Install ffmpeg & LaTeX
run: |
sudo apt update
sudo apt install ffmpeg
sudo apt install texlive-latex-extra
- name: Convert Notebooks
run: |
rm -rf notebooks
mkdir notebooks
cp -r tutorials-v${{ matrix.qutip-version }}/* notebooks
cd notebooks
find . -name '*.md' -exec jupytext --to notebook {} +
find . -name '*.md' -delete
- name: Check PEP8 formatting
run: |
pip install nbqa flake8
find . -name '*.ipynb' -exec nbqa flake8 --max-line-length=88 {} +
- name: Run tests
run: |
jupyter kernel &
cd notebooks
find . -name '*.ipynb' -exec pytest --nbmake --overwrite --nbmake-timeout=600 {} +
rm template.ipynb
- name: Create Notebook Artifact
uses: actions/upload-artifact@v4
with:
name: executed-notebooks-v${{ matrix.qutip-version }}
path: |
notebooks/*.ipynb
notebooks/**/*.ipynb
publish:
needs: pytests
runs-on: ubuntu-latest
if: ${{ github.repository == 'qutip/qutip-tutorials' && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: executed-notebooks-v4
path: publish/tutorials-v4
- uses: actions/download-artifact@v4
with:
name: executed-notebooks-v5
path: publish/tutorials-v5
- name: Build website with Jekyll
run: |
sudo gem install bundler jekyll
sudo apt-get install wget subversion
cd website
# Download resources from qutip.github.io repository
mkdir css
cd css
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/css/bootstrap.css
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/css/site.css
cd ..
mkdir _includes
cd _includes
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/footer.html
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/header.html
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/_includes/navbar.html
cd ..
mkdir images
cd images
wget https://raw.githubusercontent.com/qutip/qutip.github.io/master/images/favicon.ico
cd ..
# build the website
python create_index.py
bundle config path .gems
bundle install
bundle exec jekyll build
mv _site/* ../publish/
- name: Publish Notebooks
run: |
python -m pip install ghp-import
ghp-import -m "Automatic push by ghp-import" -f -n -p -o -r origin -b gh-pages publish