-
Notifications
You must be signed in to change notification settings - Fork 54
147 lines (143 loc) Β· 5.68 KB
/
main.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Tests
on:
push:
branches: "*"
paths-ignore:
- 'docs/**'
pull_request:
branches: master
paths-ignore:
- 'docs/**'
env:
PYTEST_ADDOPTS: "--color=yes"
# This is a pretty complicated workflow. The reason it is this way is that it
# has been optimized to go fast fast. The specific optimizations are
#
# ## Environment building and caching ("prepare-env" job)
#
# This step builds and caches the test environments using conda.
# If there is no cache, building each environment takes 3-4 minutes.
# If there is a cache this step should take about 40 seconds.
# (The time needed to install conda and check the cache.)
#
# The cache key is as follows:
# ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ env.CACHE_NUMBER }}
#
# A key parameter env.CACHE_NUMBER. This is a number that is set based on the current date:
# CACHE_NUMBER=`expr $(date +'%j') / 3`
# This is designed such that the cached environment will be reused for maximum 3 days.
# After 3 days, the CACHE_NUMBER will increment, forcing a new environment to be built.
# This cadence was chosen as a balance between making the tests go fast
# (avoiding rebuilding environments every run), and using a fresh, recent environment.
#
# The test environment is cached in /usr/share/miniconda3/envs/pangeo-forge-recipes
#
# ## Running the tests ("run-tests" job)
#
# This step does not even attempt to build environments. It just loads them from the cache.
# Then it adds the following path to $PATH
# /usr/share/miniconda3/envs/pangeo-forge-recipes/bin
#
# We use pytest marks to parallelize execution across the different executors.
# These marks are configured in tests/conftest.py
jobs:
prepare-env:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
dependencies: ["releases-only", "upstream-dev"]
steps:
- uses: actions/checkout@v2
- name: π Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.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${{ matrix.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-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ matrix.dependencies }}-${{ env.CACHE_NUMBER }}
id: conda-cache
- name: π« Maybe Update environment
if: steps.conda-cache.outputs.cache-hit != 'true'
run: mamba env update -n pangeo-forge-recipes -f ${{ env.env_file }}
- name: π§βπ» Maybe update to upstream dev versions
if: matrix.dependencies == 'upstream-dev'
run: mamba env update -n pangeo-forge-recipes -f ci/upstream-dev.yml
- name: π List conda env
shell: bash -l {0}
run: |
conda info
conda list
run-tests:
needs: prepare-env
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
dependencies: ["releases-only", "upstream-dev"]
pytest-mark: ["no_executor", "executor_function", "executor_generator",
"executor_dask", "executor_prefect", "executor_prefect_dask",
"executor_prefect_wrapper", "executor_beam"]
exclude:
- dependencies: "upstream-dev"
pytest-mark: "executor_function"
- dependencies: "upstream-dev"
pytest-mark: "executor_generator"
steps:
- uses: actions/checkout@v2
- 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${{ matrix.python-version }}.yml" >> $GITHUB_ENV
- uses: actions/cache@v2
name: π Loaded Cached environment
with:
path: /usr/share/miniconda3/envs/pangeo-forge-recipes
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ matrix.dependencies }}-${{ env.CACHE_NUMBER }}
id: conda-cache
- name: π€Ώ Bail out if no cache hit
if: steps.conda-cache.outputs.cache-hit != 'true'
run: false
- name: π― Set path to include conda python
run: echo "/usr/share/miniconda3/envs/pangeo-forge-recipes/bin" >> $GITHUB_PATH
- name: π Install pangeo-forge-recipes package
shell: bash -l {0}
run: |
python -m pip install --no-deps -e .
- name: πββοΈ Run Tests
shell: bash -l {0}
run: |
py.test tests -v -m ${{ matrix.pytest-mark }} \
--cov=pangeo_forge_recipes --cov-config .coveragerc \
--cov-report term-missing \
--cov-report xml \
--durations=10 --durations-min=1.0
- name: π¦ Run Codecov
uses: codecov/[email protected]
with:
file: ./coverage.xml
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false