From fe546d6a508ed138823efc7c668a27fc30aa3ae0 Mon Sep 17 00:00:00 2001 From: Jacob Stevens-Haas <37048747+Jacob-Stevens-Haas@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:32:46 +0000 Subject: [PATCH] CI: Add notebook review workflow (#471) Add background notebook runner action. Also: Only build draft paper on pushes to master --- .github/workflows/draft-pdf.yml | 8 ++++++- .github/workflows/notebooks.yml | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/notebooks.yml diff --git a/.github/workflows/draft-pdf.yml b/.github/workflows/draft-pdf.yml index 0dec7ffe3..4550f6314 100644 --- a/.github/workflows/draft-pdf.yml +++ b/.github/workflows/draft-pdf.yml @@ -1,4 +1,10 @@ -on: [push] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: paper: diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml new file mode 100644 index 000000000..dd932bd26 --- /dev/null +++ b/.github/workflows/notebooks.yml @@ -0,0 +1,39 @@ +on: + schedule: + # run twice a month during times when hopefully few other jobs are scheduled + - cron: '0 12 6,21 * *' + +jobs: + find-notebooks: + runs-on: ubuntu-latest + outputs: + paths: ${{ steps.find-notebooks.outputs.paths }} + steps: + - name: List Files + id: find-notebooks + uses: mirko-felice/list-files-action@v3.0.5 + with: + repo: ${{ github.repository }} + ref: ${{ github.ref }} + path: "examples" + ext: ".ipynb" + + run-notebooks: + needs: find-notebooks + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + files: ${{ fromJson(needs.find-notebooks.outputs.paths) }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.9" + - name: Install dependencies + run: | + pip install .[cvxpy,miosr] sympy nbconvert jupyter matplotlib seaborn pandas dysts + - name: Run Notebook + run: | + jupyter nbconvert --execute --to notebook --inplace ${{ matrix.files }}