Skip to content

Adding GitHub Actions CI to execute notebooks#5

Draft
Harishankar14 wants to merge 3 commits into
compiler-research:masterfrom
Harishankar14:add-ci-workflow
Draft

Adding GitHub Actions CI to execute notebooks#5
Harishankar14 wants to merge 3 commits into
compiler-research:masterfrom
Harishankar14:add-ci-workflow

Conversation

@Harishankar14
Copy link
Copy Markdown

So this adds a workflow that creates a conda-forge environment with xeus-cpp and executes the OpenMP tutorial notebooks on every push and pull request targeting master. Executed notebooks are uploaded as an artifact for review.

Notes:

  • An environment.yml file is added at the repo root so contributors can reproduce the CI environment locally with: micromamba create -f environment.yml
  • The kernel requires libomp.so to be preloaded at runtime via LD_PRELOAD; without it, the JIT fails to resolve OpenMP symbols (omp_get_thread_num, __kmpc_fork_call, etc.).
  • openmp-demo.ipynb is skipped: example5() allocates ~8 GB which exceeds the ~7 GB RAM available on standard GitHub-hosted runners.

So this adds a workflow that creates a conda-forge environment with xeus-cpp
and executes the OpenMP tutorial notebooks on every push and pull
request targeting master. Executed notebooks are uploaded as an
artifact for review.

Notes:
- An environment.yml file is added at the repo root so contributors
  can reproduce the CI environment locally with:
      micromamba create -f environment.yml
- The kernel requires libomp.so to be preloaded at runtime via
  LD_PRELOAD; without it, the JIT fails to resolve OpenMP symbols
  (omp_get_thread_num, __kmpc_fork_call, etc.).
- openmp-demo.ipynb is skipped: example5() allocates ~8 GB which
  exceeds the ~7 GB RAM available on standard GitHub-hosted runners.
@Harishankar14
Copy link
Copy Markdown
Author

@vgvassilev

@Harishankar14 Harishankar14 marked this pull request as draft May 11, 2026 21:50
@Harishankar14 Harishankar14 marked this pull request as ready for review May 11, 2026 21:51
@Harishankar14
Copy link
Copy Markdown
Author

@vgvassilev
Verified the workflow runs cleanly on my fork:
https://github.com/Harishankar14/live-cpp-tutorials/actions/runs/25699380396
4 of 5 notebooks execute successfully (hello_world, linked_list, mandel, pi_integral). openmp-demo.ipynb is skipped in CI because example5() allocates two int[1_000_000_000] arrays (~8 GB total), which exceeds the ~7 GB RAM on standard GitHub-hosted runners. Happy to follow up with options: shrink N for CI, mark just example5 as skip-execution via cell metadata, or use a larger self-hosted runner and yeah whichever you prefer.
One worth documenting somewhere is that the xcpp23-omp kernel needs libomp.so preloaded at runtime via LD_PRELOAD. Without it, the JIT fails to resolve OpenMP symbols (omp_get_thread_num, __kmpc_fork_call, etc.) even though compilation succeeds. The workflow handles this, but it tripped me up while testing locally so i guess it might be worth a README note for users running the tutorials manually.

let me know if you'd like any changes.

@vgvassilev
Copy link
Copy Markdown
Contributor

Hi @mcbarton, can you take a look?

Copy link
Copy Markdown
Contributor

@mcbarton mcbarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ai generated ci is not useful. Although it will execute the notebook, it will not actually check the outputted result is what we would expect (just because a notebook executes doesn't mean the resultant notebook is correct).

Comment thread .github/workflows/ci.yml
with:
name: executed-notebooks
path: executed/
if-no-files-found: ignore No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Author

@Harishankar14 Harishankar14 May 12, 2026

Choose a reason for hiding this comment

The 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 ??

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml

- name: Execute notebooks
run: |
set +e # don't stop on first failure; we want to see all results
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

Comment thread .github/workflows/ci.yml
fi

echo "=== Executing $nb ==="
LD_PRELOAD="$CONDA_PREFIX/lib/libomp.so" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this LD_PRELOAD. You need the clang resource directory in your environment. Its a known bug in CppInterOp.

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml
Comment thread environment.yml
Comment thread .github/workflows/ci.yml
Comment thread environment.yml
Comment thread .github/workflows/ci.yml
@Harishankar14 Harishankar14 marked this pull request as draft May 12, 2026 08:03
@Harishankar14
Copy link
Copy Markdown
Author

@mcbarton Was not fully AI generated, i get your frustration of reviewing shitty AI generated code, some were my mistakes of writing some shitty script and minor mistakes which were not removed during testing, sorry for that, and yeah , thanks for the feedback, so yeah Would u mind looking at this and maybe some feedbacks on this, i don't want to ruin the thing by creating a vauge commit again ?

name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
  workflow_dispatch:

jobs:
  execute-notebooks:
    runs-on: ubuntu-latest

    defaults:
      run:
        shell: bash -l {0}  # login shell so the micromamba env is activated

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Set up conda environment
        uses: mamba-org/setup-micromamba@v2
        with:
          environment-file: environment.yml
          # No cache-environment: we want a fresh resolve on every run
          # so the CI actually catches upstream conda-forge drift.

      - name: Validate notebooks
        run: |
          set -e

          # TODO(@mcbarton): drop this LD_PRELOAD line once we agree on
          # how xeus-cpp expects the clang resource directory to be
          # surfaced (known CppInterOp issue). Placeholder until then so
          # CI isn't red while we discuss the right env var / path.
          export LD_PRELOAD="$CONDA_PREFIX/lib/libomp.so"

          # --nbval re-executes each cell and diffs the result against
          # the output stored in the .ipynb. Committed outputs are the
          # spec; any divergence fails the build.
          # --current-env runs against the active micromamba env.
          #
          # TODO: replace --ignore with `# NBVAL_SKIP` on just example5()
          # inside openmp-demo.ipynb so the rest of that notebook still
          # runs, or migrate to the self-hosted runner once available.
          pytest --nbval --current-env \
            --ignore=openmp/openmp-demo.ipynb \
            openmp/

@Harishankar14 Harishankar14 requested a review from mcbarton May 12, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants