1- name : CI with dynamic parallel matrix
1+ name : Build notebooks and publish
22
33on :
44 workflow_dispatch :
@@ -12,20 +12,18 @@ concurrency:
1212 cancel-in-progress : true
1313
1414env :
15- NBCACHE : " .cache "
15+ JULIA_CI : ' true '
1616 JULIA_CONDAPKG_BACKEND : ' Null'
1717 JULIA_CONDAPKG_OFFLINE : ' true'
18- JULIA_CI : ' true'
19- JULIA_NUM_THREADS : ' auto'
18+ JULIA_NUM_THREADS : ' 2'
19+ JULIA_CPU_TARGET : ' generic;icelake-server,clone_all;znver3,clone_all'
20+ NBCACHE : ' .cache'
21+ LITERATE_PROC : ' 2'
2022 PY_VER : ' 3.13'
2123
2224jobs :
23- setup :
25+ execute :
2426 runs-on : ubuntu-latest
25- outputs :
26- matrix : ${{ steps.set-matrix.outputs.matrix }}
27- hash : ${{ steps.hash.outputs.value }}
28- ver : ${{ steps.julia-version.outputs.resolved }}
2927 steps :
3028 - name : Checkout repository
3129 uses : actions/checkout@v6
@@ -40,123 +38,87 @@ jobs:
4038 run : uv pip install --system -r requirements.txt
4139 - name : Read Julia version
4240 id : julia-version
43- run : python -c 'import tomllib; from pathlib import Path; print("resolved =", tomllib.loads(Path("Manifest.toml").read_text())["julia_version"], sep="")' >> "$GITHUB_OUTPUT"
41+ run : python -c 'import tomllib; from pathlib import Path; print("value =", tomllib.loads(Path("Manifest.toml").read_text())["julia_version"], sep="")' >> "$GITHUB_OUTPUT"
4442 - name : Get environment hash
4543 id : hash
4644 run : |
4745 echo "value=${{ hashFiles('Project.toml', 'Manifest.toml', 'src/**') }}" >> "$GITHUB_OUTPUT"
48- echo "ver=${{ runner.os }}-julia-${{ steps.julia-version.outputs.resolved }}" >> "$GITHUB_OUTPUT"
46+ - name : Cache executed notebooks
47+ uses : actions/cache@v4
48+ id : cache-nb
49+ with :
50+ path : |
51+ ${{ env.NBCACHE }}/**/*.ipynb
52+ ${{ env.NBCACHE }}/**/*.sha
53+ key : notebook-${{ steps.hash.outputs.value }}-${{ hashFiles('docs/**') }}
54+ restore-keys : |
55+ notebook-${{ steps.hash.outputs.value }}-
4956 - name : Setup Julia
5057 uses : julia-actions/setup-julia@v2
5158 with :
52- version : ${{ steps.julia-version.outputs.resolved }}
59+ version : ${{ steps.julia-version.outputs.value }}
5360 arch : ${{ runner.arch }}
54- - name : Cache Julia packages
55- uses : actions/cache@v4
61+ - name : Restore Julia packages
62+ uses : actions/cache/restore@v4
63+ if : ${{ runner.environment == 'github-hosted' }}
5664 id : cache-julia
5765 with :
5866 path : ~/.julia
59- key : ${{ runner.os }}-julia-${{ steps.julia-version.outputs.resolved }}-${{ steps.hash.outputs.value }}
67+ key : ${{ runner.os }}-julia-${{ steps.julia-version.outputs.value }}-${{ steps.hash.outputs.value }}
6068 restore-keys : |
61- ${{ runner.os }}-julia-${{ steps.julia-version.outputs.resolved }}-
69+ ${{ runner.os }}-julia-${{ steps.julia-version.outputs.value }}
6270 - name : Install Julia packages
63- if : ${{ steps.cache-julia.outputs.cache-hit != 'true' }}
64- shell : julia --color=yes --project=@. {0}
65- env :
66- JULIA_DEBUG : loading
71+ if : ${{ runner.environment == 'self-hosted' || steps.cache-julia.outputs.cache-hit != 'true' }}
72+ shell : julia --color=yes {0}
6773 run : |
6874 using Pkg, Dates
75+ Pkg.add(["Literate", "JSON", "Tables", "MarkdownTables", "SHA"])
76+ Pkg.activate(".")
6977 Pkg.instantiate()
7078 Pkg.precompile()
7179 if ENV["RUNNER_ENVIRONMENT"] == "github-hosted"
7280 Pkg.gc(;collect_delay=Day(0))
7381 end
74- - name : List notebooks as a JSON array
75- id : set-matrix
76- run : echo "matrix=$(python -c 'import glob, json; print(json.dumps(glob.glob("**/*.ipynb", root_dir="docs", recursive=True) + glob.glob("**/*.jl", root_dir="docs", recursive=True)))')" >> "$GITHUB_OUTPUT"
77-
78- execute :
79- needs : setup
80- strategy :
81- max-parallel : 10
82- fail-fast : false
83- matrix :
84- notebook : ${{ fromJSON(needs.setup.outputs.matrix) }}
85- runs-on : ubuntu-latest
86- env :
87- NB : docs/${{ matrix.notebook }}
88- steps :
89- - name : Checkout
90- uses : actions/checkout@v6
91- - name : Cache notebook
92- uses : actions/cache@v4
93- id : nb-cache
94- with :
95- path : ${{ env.NBCACHE }}
96- key : notebook-${{ needs.setup.outputs.hash }}-${{ hashFiles(env.NB) }}
97- - name : Setup Python
98- uses : actions/setup-python@v6
99- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
100- id : setup-python
101- with :
102- python-version : ${{ env.PY_VER }}
103- - name : Install the latest version of uv
104- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
105- uses : astral-sh/setup-uv@v7
106- - name : Install Python dependencies
107- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
108- run : uv pip install --system -r requirements.txt
109- - name : Setup Julia
110- uses : julia-actions/setup-julia@v2
111- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
112- with :
113- version : ${{ needs.setup.outputs.ver }}
114- arch : ${{ runner.arch }}
115- - name : Restore Julia packages
116- uses : actions/cache/restore@v4
117- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
118- with :
119- path : ~/.julia
120- key : ${{ runner.os }}-julia-${{ needs.setup.outputs.ver }}-${{ needs.setup.outputs.hash }}
121- - name : Execute notebook
122- if : ${{ steps.nb-cache.outputs.cache-hit != 'true' }}
123- run : julia --project=@. .github/ci.jl
124- - name : Convert artifact Name
125- id : art
126- run : echo "name=$(echo ${{ env.NB }} | sed 's/\//-/g')" >> "$GITHUB_OUTPUT"
127- - name : Upload Notebook
128- uses : actions/upload-artifact@v5
129- with :
130- name : notebook-${{ steps.art.outputs.name }}-${{ needs.setup.outputs.hash }}-${{ hashFiles(env.NB) }}
131- path : ${{ env.NBCACHE }}
132- include-hidden-files : true
133- retention-days : 1
134-
82+ - name : Save Julia packages
83+ uses : actions/cache/save@v4
84+ if : ${{ runner.environment == 'github-hosted' && steps.cache-julia.outputs.cache-hit != 'true' }}
85+ with :
86+ path : ~/.julia
87+ key : ${{ steps.cache-julia.outputs.cache-primary-key }}
88+ - name : Run notebooks
89+ if : ${{ steps.cache-nb.outputs.cache-hit != 'true' }}
90+ run : julia --project=@. --color=yes -p ${{ env.LITERATE_PROC }} .github/ci.jl
91+ - name : Upload Notebooks
92+ uses : actions/upload-artifact@v5
93+ with :
94+ path : ${{ env.NBCACHE }}/**/*.ipynb
95+ include-hidden-files : true
96+ name : notebooks
97+ retention-days : 1
13598 render :
13699 needs : execute
137100 runs-on : ubuntu-latest
138101 steps :
139- - name : Checkout
140- uses : actions/checkout@v6
141- - name : Download notebooks
142- uses : actions/download-artifact@v6
143- with :
144- path : ${{ env.NBCACHE }}/
145- pattern : notebook-*
146- merge-multiple : true
147- - name : Copy back built notebooks
148- run : cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/
149- - name : Setup Quarto
150- uses : quarto-dev/quarto-actions/setup@v2
151- - name : Remove jl files to avoid confusion with jupytext
152- run : find docs/ -type f -name "*.jl" -delete
153- - name : Render Quarto Project
154- run : quarto render docs --to html
155- - name : Upload artifact for GH pages
156- uses : actions/upload-pages-artifact@v4
157- if : ${{ github.ref == 'refs/heads/main' }}
158- with :
159- path : _site/
102+ - name : Checkout
103+ uses : actions/checkout@v6
104+ - name : Download notebooks
105+ uses : actions/download-artifact@v6
106+ with :
107+ name : notebooks
108+ path : ${{ env.NBCACHE }}
109+ - name : Copy back built notebooks
110+ run : cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/
111+ - name : Setup Quarto
112+ uses : quarto-dev/quarto-actions/setup@v2
113+ - name : Remove all jl files preventing Quarto from rendering them
114+ run : find docs/ -type f -name '*.jl' -delete
115+ - name : Render Quarto Project
116+ run : quarto render docs/ --to html
117+ - name : Upload pages artifact
118+ uses : actions/upload-pages-artifact@v4
119+ if : ${{ github.ref == 'refs/heads/main' }}
120+ with :
121+ path : _site/
160122
161123 # CI conclusion for GitHub status check
162124 # Adaped from https://brunoscheufler.com/blog/2022-04-09-the-required-github-status-check-that-wasnt
@@ -174,16 +136,14 @@ jobs:
174136 exit 1
175137 fi
176138
177- # Deployment job
178139 deploy :
179140 name : Deploy to GitHub pages
180141 needs : render
181- if : ${{ github.ref == 'refs/heads/main' }}
142+ if : ${{ github.ref == 'refs/heads/main'}}
182143 # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
183144 permissions :
184- pages : write # to deploy to Pages
145+ pages : write # to deploy to Pages
185146 id-token : write # to verify the deployment originates from an appropriate source
186- actions : read # to download an artifact uploaded by `actions/upload-pages-artifact@v3`
187147 environment :
188148 name : github-pages
189149 url : ${{ steps.deployment.outputs.page_url }}
0 commit comments