Skip to content

HYRAX-2151: Add CI for notebooks #16

HYRAX-2151: Add CI for notebooks

HYRAX-2151: Add CI for notebooks #16

Workflow file for this run

name: Test notebooks
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# Run every monday at 7am EST
- cron: '0 12 * * 1'
concurrency:
# Cancel intermediate builds only on pull requests
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
defaults:
run:
shell: bash -l {0}
jobs:
run-notebook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v3
with:
environment-file: binder/environment.yml
environment-name: Earthdata2026
create-args: >-
conda
cache-environment: true
- name: Install ci dependencies
run: |
which python
python --version
pip install jupyter nbconvert
- name: Create netrc file
run: |
cat <<EOF > $HOME/.netrc
machine urs.earthdata.nasa.gov
login ${{ secrets.EDL_USERNAME }}
password ${{ secrets.EDL_PASSWORD }}
EOF
chmod 600 $HOME/.netrc
- name: Test each notebook sequentially
run: |
# Loop over all notebooks and count how many fail to complete
NUM_FAILED=0
for file in ./binder/*.ipynb; do
echo ""
echo "*****************************"
echo "Running notebook \"$file\"..."
jupyter nbconvert --to notebook --execute $file --output executed_notebook.ipynb
if [ $? -eq 0 ]; then
echo "...$file succeeded!"
else
echo "...$file failed"
((NUM_FAILED++))
fi
# Clean up!
for data_file in ./binder/data/*.nc4; do
rm $data_file
done
echo "*****************************"
echo ""
done
echo ""
echo "*****************************"
echo "*****************************"
echo ""
if [[ $NUM_FAILED > 0 ]]; then
echo "$NUM_FAILED of $NUM_TOTAL notebooks failed."
exit 1
else
echo "$NUM_TOTAL notebooks succeeded."
fi