name: Notebook Test on: [push] jobs: nb-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install deps run: | python -m pip install --upgrade pip pip install papermill nbformat ipykernel - name: Ensure kernel run: python -m ipykernel install --user --name python3 - name: Create sample notebook if missing shell: bash run: | set -euo pipefail if [ ! -f notebook.ipynb ]; then printf '%s\n' \ 'import nbformat as nbf' \ 'nb = nbf.v4.new_notebook()' \ 'nb.cells = [' \ ' nbf.v4.new_markdown_cell("# Demo Notebook"),' \ ' nbf.v4.new_code_cell("x = 2 + 2\nprint('\'Result:\'', x)")' \ ']' \ 'with open("notebook.ipynb", "w", encoding="utf-8") as f:' \ ' nbf.write(nb, f)' \ > create_nb.py python create_nb.py fi - name: Execute notebook with Papermill run: papermill notebook.ipynb output.ipynb -k python3