-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathconfig.yml
310 lines (297 loc) · 9.93 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
---
version: 2.1
orbs:
coverage-reporter: codacy/coverage-reporter@13.13.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
log_versions:
steps:
- run:
name: Log versions
command: |
. /opt/conda/etc/profile.d/conda.sh
conda env export --name base > /logs/base_environment.yml
conda activate esmvaltool
esmvaltool version
dpkg -l > /logs/versions.txt
conda env export > /logs/environment.yml
pip freeze > /logs/requirements.txt
test_and_report:
steps:
- run:
name: Run tests
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
mamba --version
pytest -n 4 --junitxml=test-reports/report.xml
esmvaltool version
esmvaltool -- --help
ncl -V
cdo --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/ .
when: always
- store_artifacts:
path: pytest.tar.gz
- run:
name: Compress test-report artifacts
command: tar -cvzf test-reports.tar.gz test-reports/
when: always
- store_artifacts:
path: test-reports.tar.gz
test_installation_from_source:
parameters:
extra:
type: string
flags:
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: |
# Install
. /opt/conda/etc/profile.d/conda.sh
mkdir /logs
mamba --version
mamba install -c conda-forge "mamba>=2" # mamba<2 can't solve env
mamba env create -n esmvaltool -f environment.yml
conda activate esmvaltool
mamba list >> /logs/conda.txt
pip install << parameters.flags >> ".[<<parameters.extra>>]"> /logs/install.txt 2>&1
esmvaltool install Julia > /logs/install_julia.txt 2>&1
if [[ "<<parameters.flags>>" != *'--editable'* ]]
then
rm -r esmvaltool
fi
- log_versions
- run:
name: Lint source code
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
pre-commit run --all
- test_and_report
- save_cache:
key: install-<< parameters.extra >>-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- /opt/conda/pkgs
- /root/.cache/pip
- .pytest_cache
jobs:
run_tests:
# Run tests
docker:
- image: esmvalgroup/esmvaltool: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: |
set -x
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
mkdir /logs
pip install .[test] > /logs/install.txt 2>&1
esmvaltool install Julia > /logs/install_julia.txt 2>&1
- run:
name: Check Python code style and mistakes
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
pre-commit run --all
- run:
name: Remove source code to test the installed software
command: rm -r esmvaltool
- test_and_report
- save_cache:
key: test-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- /root/.cache/pip
- .pytest_cache
- 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:latest
resource_class: large
steps:
- test_installation_from_source:
extra: test
test_installation_from_source_develop_mode:
# Test development installation
docker:
- image: condaforge/miniforge3:latest
resource_class: large
steps:
- test_installation_from_source:
extra: develop
flags: "--editable"
test_upstream_development:
# Test running recipes with the development version of ESMValCore. The
# purpose of this test to discover backward-incompatible changes early on in
# the development cycle.
docker:
- image: condaforge/miniforge3:latest
resource_class: large
steps:
- run:
name: Install git and ssh
environment:
DEBIAN_FRONTEND: noninteractive # needed to install tzdata
command: apt update && apt install -y git ssh
- checkout
- run:
name: Generate cache key
command: echo $(date '+%Y')-$(expr $(date '+%V') / 2) | tee cache_key.txt
- restore_cache:
key: test-upstream-{{ .Branch }}-{{ checksum "cache_key.txt" }}
- run:
name: Install
command: |
# Install according to instructions on readthedocs with the
# development version of ESMValTool and ESMValCore:
# https://docs.esmvaltool.org/en/latest/quickstart/installation.html#install-from-source
. /opt/conda/etc/profile.d/conda.sh
mkdir /logs
mamba install -c conda-forge "mamba>=2" # mamba<2 can't solve env
mamba env create -n esmvaltool -f environment.yml
conda activate esmvaltool
mamba list >> /logs/conda.txt
pip install --editable .[develop]
esmvaltool install Julia > /logs/install_julia.txt 2>&1
git clone https://github.com/ESMValGroup/ESMValCore $HOME/ESMValCore
pip install --editable $HOME/ESMValCore[develop]
- log_versions
- test_and_report
- run:
name: Run recipes
command: |
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
mkdir -p ~/climate_data
esmvaltool config get_config_user
echo "search_esgf: when_missing" >> ~/.config/esmvaltool/config-user.yml
cat ~/.config/esmvaltool/config-user.yml
for recipe in esmvaltool/recipes/testing/recipe_*.yml; do
esmvaltool run "$recipe"
done
- store_artifacts:
path: /root/esmvaltool_output
- save_cache:
key: test-upstream-{{ .Branch }}-{{ checksum "cache_key.txt" }}
paths:
- /opt/conda/pkgs
- /root/.cache/pip
- /root/climate_data
build_documentation:
# Test building documentation
docker:
- image: condaforge/miniforge3:latest
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 > /logs/versions.txt
conda env export > /logs/environment.yml
pip freeze > /logs/requirements.txt
# Test building documentation
MPLBACKEND=Agg sphinx-build -W doc/sphinx/source doc/spinx/build
- store_artifacts:
path: /logs
test_installation_from_conda:
# Test conda package installation
docker:
- image: condaforge/miniforge3:latest
resource_class: large
steps:
- run:
command: |
. /opt/conda/etc/profile.d/conda.sh
set -x
# Install prerequisites
mkdir /logs
# Install ESMValTool in a new conda environment
mamba create -y --name esmvaltool -c conda-forge esmvaltool julia 'python=3.11' >> /logs/conda.txt 2>&1
# Activate the environment
set +x; conda activate esmvaltool; set -x
# install the Julia dependencies
esmvaltool install Julia > /logs/install_Julia.txt 2>&1
# Log versions
mamba env export > /logs/environment.yml
# Test installation
esmvaltool -- --help
esmvaltool version
ncl -V
cdo --version
- store_artifacts:
path: /logs
workflows:
commit:
jobs:
- run_tests
- test_installation_from_source_test_mode
- test_installation_from_source_develop_mode
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- run_tests
- test_installation_from_source_test_mode
- test_installation_from_source_develop_mode
- test_upstream_development
- build_documentation
- test_installation_from_conda