-
Notifications
You must be signed in to change notification settings - Fork 8
310 lines (286 loc) · 11.5 KB
/
run-test-suite.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
# A GitHub Action to run the cfunits test suite after events on main.
name: Run test suite
# Triggers the workflow on push or PR events for the main branch (only)
on:
push:
branches:
- main
pull_request:
# default (from docs) is just on [opened, synchronize, reopened]
types: [opened, reopened, ready_for_review, edited]
branches:
- main
# Note a workflow can have 1+ jobs that can run sequentially or in parallel.
jobs:
run-test-suite-job_basic:
#name: run test suite on ubuntu, macos with different python versions
name: unix-like, conda
# Set-up the build matrix. We run on different distros and Python versions.
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-latest, macos-10.15, macos-latest]
python-version: [3.7, 3.8, 3.9]
deprecated: [false]
beta: [false]
include:
# python 3.6 reached EOL
# https://devguide.python.org/#status-of-python-branches
- os: ubuntu-18.04
python-version: 3.6
deprecated: true
beta: false
- os: ubuntu-latest
python-version: 3.6
deprecated: true
beta: false
- os: macos-10.15
python-version: 3.6
deprecated: true
beta: false
- os: macos-latest
python-version: 3.6
deprecated: true
beta: false
# ignore error on deprecated or beta versions
continue-on-error: ${{ matrix.deprecated || matrix.beta }}
# Run on new and old(er) versions of the distros we support (Linux, Mac OS)
runs-on: ${{ matrix.os }}
# The sequence of tasks that will be executed as part of this job:
steps:
- name: Checkout
uses: actions/checkout@v2
# Provide a notification message
- name: Notify about setup
run: echo Now setting up the environment for the cfunits test suite...
# Prepare to run the test-suite on different versions of Python 3:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Setup conda, which is the simplest way to access all dependencies,
# especially as some are C-based so otherwise difficult to setup.
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: 'latest'
activate-environment: cfunits-latest
python-version: ${{ matrix.python-version }}
channels: conda-forge
# Ensure shell is configured with conda activated:
- name: Check conda config
shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
# Install cfunits dependencies pre-testing
# We do so with conda which was setup in a previous step.
- name: Install dependencies
shell: bash -l {0}
run: |
conda install -c conda-forge udunits2=2.2.20
pip install pycodestyle
# (The other, Python-based, deps are installed during the below command)
# Important! Must install our development version of cfunits to test:
pip install -e .
# Install libraries required for testing only (not for the core library)
# We do so with conda which was setup in a previous step.
- name: Install coverage
shell: bash -l {0}
run: |
conda install coverage dask
# Provide another notification message
- name: Notify about starting testing
run: echo Setup complete. Now starting to run the cfunits test suite...
# Finally run the test suite and generate a coverage report!
- name: Run test suite and generate a coverage report
shell: bash -l {0}
run: |
cd cfunits/test
./run_tests_and_coverage --nohtml
# For one job only, generate a coverage report:
- name: Upload coverage report to Codecov
# Get coverage from only one job (choose with Ubuntu Python 3.7 as
# representative). Note that we could use a separate workflow
# to setup Codecov reports, but given the amount of steps required to
# install including dependencies via conda, that a separate workflow
# would have to run anyway, it is simplest to add it in this flow.
# Also, it means code coverage is only generated if the test suite is
# passing at least for that job, avoiding useless coverage reports.
uses: codecov/[email protected]
if: |
matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7
with:
file: ./cfunits/test/cfunits_coverage_reports/coverage.xml
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
# End with a message indicating the suite has completed its run
- name: Notify about a completed run
run: |
echo The cfunits test suite run has completed.
run-test-suite-job_ubuntu_packages:
name: run test suite on ubuntu with mostly ubuntu packages
# Instead of running against the conda packages, we use here the packages
# from the used Linux distribution.
# Set-up the build matrix. We run on different distros and Python versions.
strategy:
matrix:
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
os: [ubuntu-20.04]
deprecated: [false]
beta: [false]
include:
# python 3.6 reached EOL and this version is default on ubuntu-18.04,
# therefore ubuntu-18.04 is deprecated
- os: ubuntu-18.04
deprecated: true
beta: false
# ignore error on deprecated or beta versions
continue-on-error: ${{ matrix.deprecated || matrix.beta }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
# check environment
- name: check environment
run: |
dpkg --print-architecture
lsb_release -a
lscpu
- name: check python version
run: python3 -V
# install dependencies
- name: install dependencies (ubuntu 18.04 packages)
if: matrix.os == 'ubuntu-18.04'
run: sudo apt install python3-setuptools python3-wheel libudunits2-0 python3-pycodestyle python3-coverage python3-numpy
- name: install cython (on ubuntu 18.04)
# This is a fix, since cftime needs a newer version of cython:
if: matrix.os == 'ubuntu-18.04'
run: pip3 install 'cython>0.26.1'
- name: install dependencies (ubuntu 20.04 packages)
if: matrix.os == 'ubuntu-20.04'
run: sudo apt install python3-setuptools python3-wheel libudunits2-0 python3-pycodestyle python3-coverage python3-numpy
# Install cfunits
# Important! Must install our development version of cfunits to test:
# pip install -e .
- name: install cfunits (ubuntu 18.04)
if: matrix.os == 'ubuntu-18.04'
run: pip3 install -e .
- name: install cfunits (ubuntu 20.04)
if: matrix.os == 'ubuntu-20.04'
# https://github.com/pypa/pip/issues/7953
run: pip3 install --user --no-use-pep517 -e .
- name: python3 -c "import cfunits; print(cfunits.__file__)"
run: |
mkdir foo
cd foo
python3 -c "import cfunits; print(cfunits.__file__)"
# Finally run the test suite and generate a coverage report!
- name: Run test suite and generate a coverage report
run: |
cd cfunits/test
./run_tests_and_coverage --nohtml
run-test-suite-job_i386_debian:
name: run test suite on debian latest (32 bit)
# https://github.com/daniel-mohr/i386_debian_latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: create test script for docker
run: |
echo "#!/bin/sh -l" > run_test_suite
echo "set -e -v" >> run_test_suite
echo "echo 'install dependencies (debian packages)'" >> run_test_suite
echo "DEBIAN_FRONTEND=noninteractive apt install -q -y lsb-release python3-setuptools python3-wheel python3-pip libudunits2-0 python3-pycodestyle python3-coverage python3-numpy" >> run_test_suite
echo "echo 'check environment'" >> run_test_suite
echo "uname -a" >> run_test_suite
echo "dpkg --print-architecture" >> run_test_suite
echo "lsb_release -a" >> run_test_suite
echo "lscpu" >> run_test_suite
echo "python3 -V" >> run_test_suite
echo "pip3 install --user --no-use-pep517 -e ." >> run_test_suite
echo "mkdir foo" >> run_test_suite
echo "(cd foo && python3 -c 'import cfunits; print(cfunits.__file__)')" >> run_test_suite
echo "echo 'Run test suite and generate a coverage report'" >> run_test_suite
echo "cd cfunits/test" >> run_test_suite
echo "./run_tests_and_coverage --nohtml" >> run_test_suite
chmod +x run_test_suite
- name: cat test script
run: cat run_test_suite
- name: run test suite in docker image
uses: daniel-mohr/i386_debian_latest@v0
with:
cmdfile: ./run_test_suite
run-test-suite-job_windows:
name: run test suite on windows using Miniconda for package management
# Set-up the build matrix.
strategy:
# due to error in cfunits we disable fail-fast to check CI configuration
fail-fast: false
matrix:
# https://github.com/actions/virtual-environments#available-environments
os: [windows-2019]
deprecated: [false]
beta: [false]
include:
- os: windows-2016
# https://github.com/actions/virtual-environments/issues/4312
deprecated: true
beta: false
- os: windows-2022
deprecated: false
beta: true
continue-on-error: ${{ matrix.deprecated || matrix.beta }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
# check environment
- name: check python version
run: python -V
# use conda to install dependencies
- name: conda init powershell
run: |
&($env:CONDA + "\Scripts\conda") init powershell
- name: install dependencies (via conda and pip from conda)
run: |
#conda install --yes --only-deps -c conda-forge cfunits
conda install -c conda-forge cftime numpy udunits2
conda install --yes -c conda-forge coverage
pip install pycodestyle
- name: set conda environment for cfunits
run: conda env config vars set UDUNITS2_XML_PATH=$env:CONDA"\Library\share\udunits\udunits2.xml"
# Ensure shell is configured with conda activated:
- name: Check conda config
run: |
conda info
conda list
conda config --show-sources
conda config --show
# Install cfunits
# Important! Must install our development version of cfunits to test:
# pip install -e .
- name: install cfunits
run: pip install -e .
- name: python -c "import cfunits; print(cfunits.__file__)"
run: |
mkdir foo
cd foo
python -c "import cfunits; print(cfunits.__file__)"
# Finally run the test suite and generate a coverage report!
- name: Run test suite
# coverage is not available in bash
# therefore run in powershell (it's windows!)
run: |
cd cfunits/test
coverage erase
coverage run --source=.. --omit="*/test/*" run_tests.py
- name: generate a coverage report
# coverage is not available in bash
# therefore run in powershell (it's windows!)
run: |
cd cfunits/test
coverage report