Skip to content

Overhaul to github actions workflows #3

Overhaul to github actions workflows

Overhaul to github actions workflows #3

Workflow file for this run

name: Notebooks - Nightly
on:
pull_request:
branches: [ main ]
schedule:
- cron: "0 3 * * *" # 3 AM UTC nightly
workflow_dispatch:
jobs:
# ---------------------------------------------------------
# 1) Gather all notebooks (except skip-list)
# ---------------------------------------------------------
gather_all_notebooks:
runs-on: ubuntu-latest
outputs:
notebooks: ${{ steps.get_nbs.outputs.notebooks }}
steps:
- uses: actions/checkout@v2
- id: get_nbs
run: |
IGNORE_LIST=("experimental_notebook.ipynb")
NBS=$(find python-recipes -name '*.ipynb')
FILTERED_NBS=()
for nb in $NBS; do
skip=false
# Check if in ignore list
for ignore_nb in "${IGNORE_LIST[@]}"; do
if [[ "$nb" == *"$ignore_nb" ]]; then
skip=true
break
fi
done
if [ "$skip" = false ]; then
FILTERED_NBS+=("$nb")
fi
done
NB_JSON=$(printf '%s\n' "${FILTERED_NBS[@]}" | jq -R . | jq -s -c .)
# Ensure at least "[]" if empty
if [ -z "$NB_JSON" ] || [ "$NB_JSON" = "[]" ]; then
NB_JSON="[]"
fi
echo "All valid notebooks: $NB_JSON"
echo "notebooks=$NB_JSON" >> $GITHUB_OUTPUT
# ---------------------------------------------------------
# 2) Test all notebooks in parallel
# ---------------------------------------------------------
test_all_notebooks:
needs: gather_all_notebooks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
notebook: ${{ fromJson(needs.gather_all_notebooks.outputs.notebooks) }}
services:
redis:
image: redis/redis-stack-server:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v2
# Setup Python
- uses: actions/setup-python@v4
with:
python-version: '3.11'
# # Cache pip
# - name: Cache pip
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('requirements-test.txt') }}
# restore-keys: ${{ runner.os }}-pip-
- name: Create and activate venv
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install pytest nbval
- name: Test notebook
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LLAMA_CLOUD_API_KEY: ${{ secrets.LLAMA_CLOUD_API_KEY }}
GCP_REGION: ${{ secrets.GCP_REGION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
run: |
echo "Testing notebook: ${{ matrix.notebook }}"
source venv/bin/activate
pytest --nbval-lax --disable-warnings "${{ matrix.notebook }}"