-
Notifications
You must be signed in to change notification settings - Fork 38
/
config.yml
259 lines (249 loc) · 8.06 KB
/
config.yml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
---
version: 2.1
orbs:
coverage-reporter: codacy/coverage-reporter@14.0.0
codecov: codecov/codecov@4.1.0
commands:
check_changes:
steps:
- run:
name: Check whether or not installation tests are needed
command: |
if (test "$CIRCLE_BRANCH" = main ||
git --no-pager diff --name-only origin/main... |
grep -q -E -f .circleci/install_triggers)
then
echo Running installation tests
else
echo Skipping installation tests
circleci step halt
fi
test_and_report:
parameters:
args:
type: string
default: ""
steps:
- run:
name: Run tests
command: |
mkdir -p test-reports
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
pytest -n 4 --junitxml=test-reports/report.xml << parameters.args >>
esmvaltool version
- store_test_results:
path: test-reports/report.xml
- store_artifacts:
path: /logs
- run:
name: Compress pytest artifacts
command: tar -cvzf pytest.tar.gz -C /tmp/pytest-of-root/pytest-0/ .
- store_artifacts:
path: pytest.tar.gz
- run:
name: Compress test-report artifacts
command: tar -cvzf test-reports.tar.gz test-reports/
- store_artifacts:
path: test-reports.tar.gz
test_installation_from_source:
parameters:
extra:
description: pip "extra"s to install
type: string
default: "test"
flags:
description: pip install flags
type: string
default: ""
upstream_packages:
description: List of packages that will be installed with pip.
type: string
default: ""
steps:
- run:
name: Install git+ssh
environment:
DEBIAN_FRONTEND: noninteractive # needed to install tzdata
command: apt update && apt install -y git ssh
- checkout
- check_changes
- run:
name: Generate cache key
command: date '+%Y-%V' | tee cache_key.txt
- restore_cache:
key: install-<< parameters.extra >>-{{ .Branch }}-{{ checksum "cache_key.txt" }}
- run:
name: Install dependencies
command: |
# Add additional requirements for running all tests
echo "
- r-base
- r-yaml
- ncl
" >> environment.yml
# Installation of development version of packages requires compilers
if [[ "<< parameters.upstream_packages >>" ]]; then
echo " - compilers" >> environment.yml
fi
# Install
. /opt/conda/etc/profile.d/conda.sh
mkdir /logs
mamba env create |& tee /logs/conda.txt
git stash # Restore repository state to get clean version number.
conda activate esmvaltool
pip install << parameters.flags >> ".[<<parameters.extra>>]" << parameters.upstream_packages >> |& tee /logs/install.txt
- run:
name: Log versions
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
dpkg -l | tee /logs/versions.txt
conda env export | tee /logs/environment.yml
pip freeze | tee /logs/requirements.txt
- test_and_report
- save_cache:
key: install-<< parameters.extra >>-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- /opt/conda/pkgs
- /root/.cache/pip
- .mypy_cache
- .pytest_cache
jobs:
run_tests:
# Run tests
docker:
- image: esmvalgroup/esmvalcore:development
resource_class: large
steps:
- checkout
- run:
name: Generate cache key
command: date '+%Y-%V' | tee cache_key.txt
- restore_cache:
key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }}
- run:
name: Install dependencies
command: |
. /opt/conda/etc/profile.d/conda.sh
mkdir /logs
conda activate esmvaltool
pip install .[test] > /logs/install.txt 2>&1
- test_and_report:
args: --cov
- save_cache:
key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- /root/.cache/pip
- .mypy_cache
- .pytest_cache
- run:
name: Install gpg (required by codecov orb)
command: apt update && apt install -y gpg
- codecov/upload:
when: always
file: 'test-reports/coverage.xml'
- coverage-reporter/send_report:
coverage-reports: 'test-reports/coverage.xml'
project-token: $CODACY_PROJECT_TOKEN
skip: true # skip if project-token is not defined (i.e. on a fork)
test_installation_from_source_test_mode:
# Test installation from source
docker:
- image: condaforge/miniforge3
resource_class: large
steps:
- test_installation_from_source
test_installation_from_source_develop_mode:
# Test development installation
docker:
- image: condaforge/miniforge3
resource_class: large
steps:
- test_installation_from_source:
extra: develop
flags: "--editable"
test_with_upstream_developments:
# Test with development versions of upstream packages
docker:
- image: condaforge/miniforge3
resource_class: large
steps:
- test_installation_from_source:
upstream_packages: >-
git+https://github.com/esgf/esgf-pyclient
git+https://github.com/euro-cordex/py-cordex
git+https://github.com/SciTools/cartopy
git+https://github.com/SciTools/cf-units
git+https://github.com/SciTools/iris
git+https://github.com/SciTools/iris-grib
git+https://github.com/SciTools/nc-time-axis
git+https://github.com/SciTools-incubator/iris-esmf-regrid
git+https://github.com/SciTools-incubator/python-stratify
git+https://github.com/Toblerity/Fiona
test_installation_from_conda:
# Test conda package installation
working_directory: /esmvaltool
docker:
- image: condaforge/miniforge3
resource_class: medium
steps:
- run:
command: |
. /opt/conda/etc/profile.d/conda.sh
set -x
# Install prerequisites
mkdir /logs
# Create and activate conda environment
mamba create -y --name esmvaltool 'python=3.11'
set +x; conda activate esmvaltool; set -x
# Install
mamba install -y esmvalcore
# Log versions
conda env export | tee /logs/environment.yml
# Test installation
esmvaltool version
build_documentation:
# Test building documentation
docker:
- image: condaforge/miniforge3
resource_class: medium
steps:
- checkout
- run:
command: |
mkdir /logs
. /opt/conda/etc/profile.d/conda.sh
# Install
mamba env create
conda activate esmvaltool
pip install .[doc]
# Log versions
dpkg -l | tee /logs/versions.txt
conda env export | tee /logs/environment.yml
pip freeze | tee /logs/requirements.txt
# Test building documentation
MPLBACKEND=Agg sphinx-build -W doc doc/build
- store_artifacts:
path: /logs
workflows:
commit:
jobs:
- run_tests
- test_installation_from_source_develop_mode
- test_installation_from_source_test_mode
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- build_documentation
- run_tests
- test_installation_from_conda
- test_installation_from_source_develop_mode
- test_installation_from_source_test_mode
- test_with_upstream_developments