-
Notifications
You must be signed in to change notification settings - Fork 4
Adding GitHub Actions CI to execute notebooks #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
Harishankar14 marked this conversation as resolved.
|
||
|
|
||
| - name: Set up micromamba environment | ||
| uses: mamba-org/setup-micromamba@v2 | ||
|
Harishankar14 marked this conversation as resolved.
|
||
| with: | ||
| environment-file: environment.yml | ||
| cache-environment: true | ||
|
Harishankar14 marked this conversation as resolved.
|
||
|
|
||
| - 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If any notebook fails to execute, we would want the ci to fail. Why run all the notebooks if the ci is going to fail anyway?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jeez, this was a typo, i thing i wrote the wrong piece of line here,lol. |
||
| 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). | ||
|
Harishankar14 marked this conversation as resolved.
|
||
| 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" \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need this |
||
| 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 | ||
|
Harishankar14 marked this conversation as resolved.
|
||
| with: | ||
| name: executed-notebooks | ||
| path: executed/ | ||
| if-no-files-found: ignore | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely if no files are found something went wrong with executing the notebooks. I do not understand why you would want to ignore them
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcbarton Okay yeah i guess we can remove the upload step entirely. With pytest --nbval doing output validation, executed-notebook artifacts aren't needed and the test result is the validation. So both the version pin and the if-no-files-found settings are moot ?? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| name: livecpp-ci | ||
|
Harishankar14 marked this conversation as resolved.
|
||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - python>=3.11 | ||
|
Harishankar14 marked this conversation as resolved.
|
||
| - xeus-cpp | ||
| - jupyter | ||
| - nbconvert | ||
| - llvm-openmp | ||
Uh oh!
There was an error while loading. Please reload this page.