Skip to content
26 changes: 17 additions & 9 deletions .github/workflows/nightly-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ jobs:
runs-on: ubuntu-latest
outputs:
notebooks: ${{ steps.get_nbs.outputs.notebooks }}
has_notebooks: ${{ steps.get_nbs.outputs.has_notebooks }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- id: get_nbs
run: |
# 1) Read ignore patterns from .github/ignore-notebooks.txt
# 1) Find all available notebooks
NBS=$(find python-recipes -name '*.ipynb')

# 2) Load notebooks to ignore
IGNORE_LIST=()
while IFS= read -r skip_nb || [ -n "$skip_nb" ]; do
# Skip empty lines or comment lines
[[ -z "$skip_nb" || "$skip_nb" =~ ^# ]] && continue
IGNORE_LIST+=("$skip_nb")
done < .github/ignore-notebooks.txt

# 2) Find all .ipynb in python-recipes (or your path)
NBS=$(find python-recipes -name '*.ipynb')

# 3) Filter out notebooks that match anything in IGNORE_LIST
FILTERED_NBS=()
for nb in $NBS; do
Expand All @@ -42,29 +43,36 @@ jobs:
break
fi
done

if [ "$skip" = false ]; then
FILTERED_NBS+=("$nb")
fi
done

# 4) Convert the final array to compact JSON for GitHub Actions
# 4) Stuff into a single-line JSON array
NB_JSON=$(printf '%s\n' "${FILTERED_NBS[@]}" \
| jq -R . \
| jq -s -c .)

# 5) Default to an empty array if there's nothing left
if [ -z "$NB_JSON" ] || [ "$NB_JSON" = "[]" ]; then
NB_JSON="[]"
fi

echo "All valid notebooks: $NB_JSON"

# 5) Check if there's anything in FILTERED_NBS
if [ "${#FILTERED_NBS[@]}" -gt 0 ]; then
echo "has_notebooks=true" >> $GITHUB_OUTPUT
else
echo "has_notebooks=false" >> $GITHUB_OUTPUT
fi

echo "notebooks=$NB_JSON" >> $GITHUB_OUTPUT

# ---------------------------------------------------------
# 2) Test all notebooks in parallel
# ---------------------------------------------------------
test_all_notebooks:
if: ${{ needs.gather_all_notebooks.outputs.has_notebooks == 'true' }}
needs: gather_all_notebooks
runs-on: ubuntu-latest
strategy:
Expand All @@ -79,7 +87,7 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Setup Python
- uses: actions/setup-python@v4
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ jobs:
runs-on: ubuntu-latest
outputs:
notebooks: ${{ steps.get_nbs.outputs.notebooks }}
has_notebooks: ${{ steps.get_nbs.outputs.has_notebooks }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- id: get_nbs
- name: Gather notebooks
id: get_nbs
run: |
# Compare this commit/PR to 'main' and list changed .ipynb files
# 1) Compare this commit/PR to 'main' and list changed notebooks
git fetch --depth=1 origin main
CHANGED_NOTEBOOKS=$(git diff --name-only origin/main | grep '\.ipynb$' || true)

# 1) Read ignore patterns from .github/ignore-notebooks.txt
# 2) Load notebooks to ignore
IGNORE_LIST=()
while IFS= read -r skip_nb || [ -n "$skip_nb" ]; do
# Skip empty lines or comment lines
[[ -z "$skip_nb" || "$skip_nb" =~ ^# ]] && continue
IGNORE_LIST+=("$skip_nb")
done < .github/ignore-notebooks.txt

# 2) Filter out notebooks in CHANGED_NOTEBOOKS that match ignore patterns
# 3) Filter out ignored notebooks
FILTERED_NBS=()
for nb in $CHANGED_NOTEBOOKS; do
skip=false

# Check if in ignore list
for ignore_nb in "${IGNORE_LIST[@]}"; do
# Partial match:
Expand All @@ -47,33 +48,31 @@ jobs:
break
fi
done

if [ "$skip" = false ]; then
FILTERED_NBS+=("$nb")
fi
done

# 3) Build a single-line JSON array
# 4) Stuff into a single-line JSON array
NB_JSON=$(printf '%s\n' "${FILTERED_NBS[@]}" \
| jq -R . \
| jq -s -c .)

# 4) Fallback to an empty array if there's nothing left
if [ -z "$NB_JSON" ] || [ "$NB_JSON" = "[]" ]; then
NB_JSON="[]"
fi

echo "All valid notebooks: $NB_JSON"

# 5) Write to $GITHUB_OUTPUT
if [ "$NB_JSON" != "[]" ]; then
# 5) Check if there's anything in FILTERED_NBS
if [ "${#FILTERED_NBS[@]}" -gt 0 ]; then
echo "has_notebooks=true" >> $GITHUB_OUTPUT
else
echo "has_notebooks=false" >> $GITHUB_OUTPUT
fi

echo "notebooks=$NB_JSON" >> $GITHUB_OUTPUT

# ---------------------------------------------------------
# 2) Test each changed notebook in parallel
# ---------------------------------------------------------
Expand All @@ -93,7 +92,7 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Setup Python
- uses: actions/setup-python@v4
Expand Down
224 changes: 221 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,222 @@
.env
node_modules/
# Created by https://www.toptal.com/developers/gitignore/api/python,venv,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=python,venv,macos

### macOS ###
# General
.DS_Store
.pytest_cache/
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

### venv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
pyvenv.cfg
pip-selfcheck.json

libs/redis/docs/.Trash*
.python-version
.idea/*
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.9
3.11
Loading