-
Notifications
You must be signed in to change notification settings - Fork 54
115 lines (106 loc) · 4.2 KB
/
tutorials.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Test Tutorial Notebooks
on:
push:
branches: master
repository_dispatch:
types: [run-test-tutorials-command]
workflow_dispatch:
env:
PYTEST_ADDOPTS: "--color=yes"
python-version: "3.9"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-tutuorials:
name: 📓 Build Tutorial Notebook
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
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@v3
if: ${{ github.event_name != 'repository_dispatch' }}
- uses: actions/checkout@v3
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.5.0
if: ${{ github.event_name == 'repository_dispatch' }}
with:
sha: ${{ github.event.client_payload.pull_request.head.sha }}
# can't use default token
# https://github.saobby.my.eu.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@v4
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@v3
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
run: |
conda info
conda list
- name: 🌈 Install pangeo-forge-recipes package
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
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.5.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 }}