diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e6fd289 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + execute-notebooks: + name: Execute notebooks + runs-on: ubuntu-latest + + defaults: + run: + shell: bash -el {0} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up micromamba environment + uses: mamba-org/setup-micromamba@v2 + with: + environment-file: environment.yml + cache-environment: true + + - name: List available kernels + run: jupyter kernelspec list + + - name: Execute notebooks + run: | + set +e # don't stop on first failure; we want to see all results + mkdir -p executed + failed=0 + + # NOTE: openmp-demo.ipynb is skipped — example5() allocates ~8 GB + # which exceeds the ~7 GB RAM on standard GitHub-hosted runners. + # TODO: revisit (shrink N for CI, skip just example5 via cell metadata, + # or run on a larger runner). + for nb in openmp/*.ipynb; do + if [ "$(basename "$nb")" = "openmp-demo.ipynb" ]; then + echo "::warning file=$nb::Skipping $nb (needs >7GB RAM)" + continue + fi + + echo "=== Executing $nb ===" + LD_PRELOAD="$CONDA_PREFIX/lib/libomp.so" \ + jupyter nbconvert --to notebook --execute "$nb" \ + --output "../executed/$(basename "$nb")" \ + --ExecutePreprocessor.timeout=300 + if [ $? -ne 0 ]; then + echo "::error file=$nb::Failed to execute $nb" + failed=$((failed + 1)) + fi + done + + echo "" + echo "=== Summary: $failed notebook(s) failed ===" + exit $failed + + - name: Upload executed notebooks as artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: executed-notebooks + path: executed/ + if-no-files-found: ignore \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..8b76ec8 --- /dev/null +++ b/environment.yml @@ -0,0 +1,9 @@ +name: livecpp-ci +channels: + - conda-forge +dependencies: + - python>=3.11 + - xeus-cpp + - jupyter + - nbconvert + - llvm-openmp \ No newline at end of file