Skip to content

Commit 09283da

Browse files
larsgebclaude
andcommitted
Add weekly schedule and GitHub Pages notebook rendering
Schedule: CI now runs every Monday at 06:00 UTC to catch regressions. Pages job (macos-14, main branch only): - Builds pybind11 module so notebooks can import _m1_gpu_ops - Converts demo.py and wave_demo.py (jupytext light) to .ipynb via jupytext - Executes and renders to HTML via jupyter nbconvert (MPLBACKEND=Agg) - Generates a simple index.html with links to both rendered notebooks - Deploys to GitHub Pages via actions/upload-pages-artifact + deploy-pages NOTE: requires GitHub Pages source to be set to "GitHub Actions" in Settings → Pages → Source. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 54a84b4 commit 09283da

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
schedule:
9+
- cron: '0 6 * * 1' # every Monday at 06:00 UTC
810

911
jobs:
1012
build-and-test:
@@ -141,3 +143,117 @@ jobs:
141143
142144
print("All smoke tests passed.")
143145
EOF
146+
147+
pages:
148+
name: Render notebooks → GitHub Pages
149+
runs-on: macos-14
150+
needs: build-and-test
151+
# Only publish on main branch pushes and scheduled runs — not on PRs.
152+
if: github.event_name != 'pull_request'
153+
permissions:
154+
pages: write
155+
id-token: write
156+
environment:
157+
name: github-pages
158+
url: ${{ steps.deploy.outputs.page_url }}
159+
160+
steps:
161+
- uses: actions/checkout@v4
162+
with:
163+
submodules: recursive
164+
165+
- name: Install dependencies
166+
run: brew install cmake libomp
167+
env:
168+
HOMEBREW_NO_AUTO_UPDATE: 1
169+
170+
- name: Bootstrap Xcode
171+
run: sudo xcodebuild -runFirstLaunch
172+
173+
- name: Set up Python venv
174+
run: |
175+
python3 -m venv .venv
176+
.venv/bin/pip install --quiet \
177+
numpy pybind11 matplotlib jupytext nbconvert ipykernel
178+
# Register this venv as the "python3" Jupyter kernel so nbconvert
179+
# executes notebooks with the same Python that has _m1_gpu_ops built in.
180+
.venv/bin/python3 -m ipykernel install --user --name python3
181+
182+
- name: Build with pybind11
183+
run: |
184+
PYBIND11_DIR=$(.venv/bin/python3 -c "import pybind11; print(pybind11.get_cmake_dir())")
185+
cmake -B build -Dpybind11_DIR="$PYBIND11_DIR"
186+
cmake --build build --parallel
187+
188+
- name: Render notebooks to HTML
189+
env:
190+
MPLBACKEND: Agg # non-interactive backend — no display needed
191+
run: |
192+
# Convert jupytext light .py → .ipynb, execute, render to HTML.
193+
# Working directory is repo root so "build/" relative paths resolve.
194+
.venv/bin/jupytext --to notebook demo.py
195+
.venv/bin/jupytext --to notebook wave_demo.py
196+
mkdir -p _site
197+
.venv/bin/jupyter nbconvert \
198+
--to html --execute \
199+
--ExecutePreprocessor.timeout=300 \
200+
--output-dir _site \
201+
demo.ipynb wave_demo.ipynb
202+
203+
- name: Create index page
204+
run: |
205+
.venv/bin/python3 - << 'PYEOF'
206+
import datetime, pathlib
207+
date = datetime.date.today().isoformat()
208+
html = """<!DOCTYPE html>
209+
<html lang="en">
210+
<head>
211+
<meta charset="UTF-8">
212+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
213+
<title>m1-gpu-cpp demos</title>
214+
<style>
215+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
216+
max-width: 680px; margin: 48px auto; padding: 0 24px;
217+
color: #24292e; line-height: 1.6; }
218+
h1 { font-size: 1.6em; border-bottom: 1px solid #e1e4e8; padding-bottom: 10px; }
219+
.card { border: 1px solid #e1e4e8; border-radius: 6px;
220+
padding: 16px 20px; margin: 12px 0; }
221+
.card h2 { font-size: 1.1em; margin: 0 0 6px; }
222+
.card h2 a { color: #0366d6; text-decoration: none; }
223+
.card h2 a:hover { text-decoration: underline; }
224+
.card p { margin: 0; color: #586069; font-size: 0.9em; }
225+
footer { margin-top: 32px; color: #586069; font-size: 0.85em; }
226+
</style>
227+
</head>
228+
<body>
229+
<h1>m1-gpu-cpp &mdash; Metal GPU Computing Demos</h1>
230+
<p>GPU-accelerated scientific computing on Apple Silicon using Metal Shading
231+
Language, exposed to Python via pybind11.</p>
232+
<div class="card">
233+
<h2><a href="demo.html">General operations demo</a></h2>
234+
<p>1D/2D array ops &middot; Laplacian stencils &middot; Mandelbrot
235+
&middot; N-body &middot; heat diffusion</p>
236+
</div>
237+
<div class="card">
238+
<h2><a href="wave_demo.html">Elastic wave propagation demo</a></h2>
239+
<p>2D elastic FD (Virieux staggered-grid) &middot; seismograms
240+
&middot; wavefield snapshots</p>
241+
</div>
242+
<footer>
243+
Rendered DATE_PLACEHOLDER by CI &middot;
244+
<a href="https://github.com/larsgeb/m1-gpu-cpp">source on GitHub</a>
245+
</footer>
246+
</body>
247+
</html>
248+
""".replace("DATE_PLACEHOLDER", date)
249+
pathlib.Path("_site/index.html").write_text(html)
250+
PYEOF
251+
252+
- name: Upload Pages artifact
253+
uses: actions/upload-pages-artifact@v3
254+
with:
255+
path: _site
256+
257+
- name: Deploy to GitHub Pages
258+
id: deploy
259+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)