Update README.md (#542) #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Tutorial Notebooks | |
on: | |
push: | |
branches: main | |
repository_dispatch: | |
types: [run-test-tutorials-command] | |
workflow_dispatch: | |
env: | |
PYTEST_ADDOPTS: "--color=yes" | |
python-version: "3.9" | |
jobs: | |
test-tutuorials: | |
name: π Build Tutorial Notebook | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- nb-path: "hdf_reference/reference_cmip6.ipynb" | |
- nb-path: "xarray_zarr/cmip6-recipe.ipynb" | |
- nb-path: "xarray_zarr/multi_variable_recipe.ipynb" | |
- nb-path: "xarray_zarr/netcdf_zarr_sequential.ipynb" | |
- nb-path: "xarray_zarr/opendap_subset_recipe.ipynb" | |
- nb-path: "xarray_zarr/terraclimate.ipynb" | |
steps: | |
- uses: actions/checkout@v2 | |
if: ${{ github.event_name != 'repository_dispatch' }} | |
- uses: actions/checkout@v2 | |
if: ${{ github.event_name == 'repository_dispatch' }} | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.ACTIONS_BOT_TOKEN }} | |
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.client_payload.pull_request.head.ref }} | |
# start a check | |
- name: β Register Check Started | |
id: start-check | |
uses: LouisBrunner/checks-action@v1.2.0 | |
if: ${{ github.event_name == 'repository_dispatch' }} | |
with: | |
sha: ${{ github.event.client_payload.pull_request.head.sha }} | |
# can't use default token | |
# https://g.nite07.orgmunity/t/create-a-check-run-details-url-is-not-being-set/166002/4?u=bkwhite | |
# https://github.com/LouisBrunner/checks-action/issues/18#issuecomment-970312052 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Test Notebook ${{ matrix.nb-path }} | |
status: in_progress | |
# this seems to be broken | |
details_url: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} | |
- name: π Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.python-version }} | |
architecture: x64 | |
- name: π Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: pangeo-forge-recipes | |
use-mamba: true | |
- name: π― Set cache number | |
id: cache-number | |
# cache will last 3 days by default | |
run: echo CACHE_NUMBER=`expr $(date +'%j') / 3` >> $GITHUB_ENV | |
- name: π― Set environment file | |
id: env-file | |
run: echo "env_file=ci/py${{ env.python-version }}.yml" >> $GITHUB_ENV | |
- uses: actions/cache@v2 | |
name: π Cache environment | |
with: | |
path: /usr/share/miniconda3/envs/pangeo-forge-recipes | |
key: ${{ runner.os }}-conda-${{ env.python-version }}-${{ hashFiles( env.env_file ) }}-${{ env.CACHE_NUMBER }} | |
id: conda-cache | |
- name: π« Update environment | |
run: mamba env update -n pangeo-forge-recipes -f ${{ env.env_file }} | |
if: steps.conda-cache.outputs.cache-hit != 'true' | |
- name: π List conda env | |
shell: bash -l {0} | |
run: | | |
conda info | |
conda list | |
- name: π Install pangeo-forge-recipes package | |
shell: bash -l {0} | |
run: | | |
python -m pip install --no-deps -e . | |
# Everything above here is basically the same as main.yaml | |
# Could we consolidate it somehow? | |
- name: π Build Notebook | |
shell: bash -l {0} | |
run: > | |
pytest --timeout=3000 --nbmake docs/pangeo_forge_recipes/tutorials/${{ matrix.nb-path }} | |
# finish the check | |
# this won't work if we are not inside a repository_dispatch event, | |
# but I don't see how to combine multiple if statements | |
- uses: LouisBrunner/checks-action@v1.2.0 | |
if: ${{ always() && steps.start-check.outputs.check_id }} | |
with: | |
sha: ${{ github.event.client_payload.pull_request.head.sha }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
check_id: ${{ steps.start-check.outputs.check_id }} | |
status: completed | |
conclusion: ${{ job.status }} |