Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cirrus CI #250

Merged
merged 57 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
03d60a9
Travis test with both Iris latest-release and latest-master. (#231)
pp-mo Oct 6, 2020
85a5f4b
Cosmetic change : rename the travis iris-test-version options (#234)
pp-mo Oct 12, 2020
9c6bea6
Version 0.16 release candidate (#232)
pp-mo Oct 12, 2020
5a96b74
Fix RC date in release notes (about to cut). (#235)
pp-mo Oct 12, 2020
9a5859f
Add 'main' conda-forge channel, needed for docs builds. (#240)
pp-mo Jan 20, 2021
e0ade8d
Update requirements to pick up Iris 3. (#243)
pp-mo Jan 27, 2021
93fc344
Remove eccodes bug workaround added in #208. (#224)
pp-mo Jan 27, 2021
df97291
Docstest 0v16 (#244)
pp-mo Jan 27, 2021
d1df9f0
Added getting started .cirrus.yml
jamesp Feb 19, 2021
d0c01c0
Update cirrus to use miniconda image
jamesp Feb 19, 2021
ef1bd66
Update .cirrus.yml
jamesp Feb 19, 2021
c321c13
Update .cirrus.yml
jamesp Feb 19, 2021
b113b62
Added nox testing
jamesp Feb 19, 2021
ac410a6
Path fixes in cirrus.yml
jamesp Feb 19, 2021
f0dfef9
eccodes test added to noxfile
jamesp Feb 19, 2021
fd4f502
Added config and coverage
jamesp Feb 19, 2021
86f81da
Trying to set SITE_CFG
jamesp Feb 19, 2021
6bd2dba
syntax error
jamesp Feb 19, 2021
5e8e0c5
taking the IRIS_DIR from Travis CI config
jamesp Feb 19, 2021
75ee11d
Add allow_failures to the linux task for now
jamesp Feb 19, 2021
cc4c5cd
Dodgy r key...
jamesp Feb 19, 2021
3f22294
Update .cirrus.yml
jamesp Feb 19, 2021
fab9bcf
Allow failures in linting
jamesp Feb 19, 2021
8298d84
Force return error 0 for now
jamesp Feb 19, 2021
b75c7ab
Added eccodes test
jamesp Feb 19, 2021
939d96e
moved matrix
jamesp Feb 19, 2021
41f5a76
Yaml syntax error & * wrong way around
jamesp Feb 19, 2021
15cae9c
Typo
jamesp Feb 19, 2021
d1c07e1
Update iris version dependency
jamesp Feb 22, 2021
006ac83
Date fix
jamesp Feb 22, 2021
dce00e0
Configure Iris in nox
jamesp Feb 22, 2021
d2f6666
Merge branch 'master' of github.com:jamesp/iris-grib
jamesp Feb 22, 2021
6eced74
Updated CI config
jamesp Feb 22, 2021
b550bad
correct site-packages path
jamesp Feb 22, 2021
1615d75
Fix to iris test data path
jamesp Feb 23, 2021
d33cfff
force cache update
jamesp Feb 23, 2021
4fb5ccd
refactored writing iris config in noxfile
jamesp Feb 23, 2021
d1b192e
Merge remote-tracking branch 'upstream/v0.16.x' into cirrus-16
jamesp Feb 23, 2021
5258038
Fix pep8 and license test fails
jamesp Feb 23, 2021
083f62b
Support for testing against packaged iris and building from source
jamesp Feb 24, 2021
1a228d9
Adding yaml to list of cirrus container requirements
jamesp Feb 24, 2021
5e97407
invalidate cirrus cache
jamesp Feb 24, 2021
5854630
really invalidate cirrus cache...
jamesp Feb 24, 2021
7e6d456
yaml -> pyyaml
jamesp Feb 24, 2021
d894ca1
missing iris_dir reference
jamesp Feb 24, 2021
ddb5600
call write_iris_config
jamesp Feb 24, 2021
2d7f31a
docstrings and matrix testing
jamesp Feb 24, 2021
8e21f0a
git syntax error
jamesp Feb 24, 2021
0ce6db5
Merged cirrus ci and nox
jamesp Feb 24, 2021
c5d6778
eccodes selfcheck in basic tests
jamesp Feb 24, 2021
0449696
Removed py3.8 testing for now
jamesp Feb 25, 2021
289dd0e
Fixed regression in setup.py test
jamesp Mar 1, 2021
e895af6
Removed unused imports
jamesp Mar 1, 2021
a9d80d7
Disabled lint checking
jamesp Mar 1, 2021
f5e4703
Removed nox from test dependencies for python3.6 and python3.8
jamesp Mar 2, 2021
40a448d
Removed python3.8 from noxfile
jamesp Mar 2, 2021
69603d9
Removed nox from test requirements
jamesp Mar 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Reference:
# - https://cirrus-ci.org/guide/writing-tasks/
# - https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
# - https://cirrus-ci.org/guide/linux/
# - https://cirrus-ci.org/guide/macOS/
# - https://cirrus-ci.org/guide/windows/
# - https://hub.docker.com/_/gcc/
# - https://hub.docker.com/_/python/

#
# Global defaults.
#
container:
image: python:3.8
cpu: 2
memory: 4G

env:
# Maximum cache period (in weeks) before forcing a new cache upload.
CACHE_PERIOD: "2"
# Increment the build number to force new conda cache upload.
CONDA_CACHE_BUILD: "98"
# Increment the build number to force new nox cache upload.
NOX_CACHE_BUILD: "98"
# Increment the build number to force new pip cache upload.
PIP_CACHE_BUILD: "98"
# Pip package to be upgraded/installed.
PIP_CACHE_PACKAGES: "pip setuptools wheel nox pyyaml"
# Base directory for the iris-test-data.
IRIS_TEST_DATA_DIR: ${HOME}/iris-test-data
# Git commit hash for iris test data.
IRIS_TEST_DATA_REF: "2.0.0"

#
# Linting
#
lint_task:
auto_cancellation: true
allow_failures: true
name: "${CIRRUS_OS}: flake8 and black"
pip_cache:
folder: ~/.cache/pip
fingerprint_script:
- echo "${CIRRUS_TASK_NAME}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${PIP_CACHE_BUILD} ${PIP_CACHE_PACKAGES}"
lint_script:
- pip list
- python -m pip install --retries 3 --upgrade ${PIP_CACHE_PACKAGES}
- pip list
- "nox --session flake8 || :"
- "nox --session black || :"
bjlittle marked this conversation as resolved.
Show resolved Hide resolved


#
# Testing (Linux)
#
linux_task_template: &LINUX_TASK_TEMPLATE
auto_cancellation: true
env:
PATH: ${HOME}/miniconda/bin:${PATH}

container:
image: gcc:latest
cpu: 6
memory: 8G
conda_cache:
folder: ${HOME}/miniconda
fingerprint_script:
- wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- echo "${CIRRUS_OS} $(sha256sum miniconda.sh)"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${CONDA_CACHE_BUILD}"
populate_script:
- bash miniconda.sh -b -p ${HOME}/miniconda
- conda config --set always_yes yes --set changeps1 no
- conda config --set show_channel_urls True
- conda config --add channels conda-forge
- conda update --quiet --name base conda
- conda install --quiet --name base nox pip coverage pyyaml
nox_cache:
folder: ${CIRRUS_WORKING_DIR}/.nox
fingerprint_script:
- echo "${CIRRUS_TASK_NAME}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${NOX_CACHE_BUILD}"
- sha256sum ${CIRRUS_WORKING_DIR}/requirements/ci/py$(echo ${PY_VER} | tr -d ".").yml
- echo "IRIS ${IRIS_SOURCE}"
data_cache:
folder: ${IRIS_TEST_DATA_DIR}
fingerprint_script:
- echo "${IRIS_TEST_DATA_REF}"
populate_script:
- wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_REF}.zip -O iris-test-data.zip
- unzip -q iris-test-data.zip
- mv iris-test-data-$(echo "${IRIS_TEST_DATA_REF}" | sed "s/^v//") ${IRIS_TEST_DATA_DIR}

tests_task:
matrix:
env:
PY_VER: 3.6
env:
PY_VER: 3.7
# env:
# PY_VER: 3.8
name: "${CIRRUS_OS}: py${PY_VER} tests"
<< : *LINUX_TASK_TEMPLATE
tests_script:
- nox --session tests -- --test-data-dir ${IRIS_TEST_DATA_DIR}/test_data
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ sdist
develop-eggs
.installed.cfg

# test
.nox/

# Installer logs
pip-log.txt

Expand All @@ -24,3 +27,4 @@ pip-log.txt
\#*
\.\#*
*.swp
.vscode/
9 changes: 9 additions & 0 deletions iris_grib/tests/runner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Empty file to allow import.

"""
40 changes: 40 additions & 0 deletions iris_grib/tests/runner/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Provides testing capabilities for installed copies of iris-grib.

"""

import argparse

from ._runner import TestRunner


parser = argparse.ArgumentParser(
"iris_grib.tests", description=TestRunner.description
)
for long_opt, short_opt, help_text in TestRunner.user_options:
long_opt = long_opt.strip("=")
if long_opt in TestRunner.boolean_options:
parser.add_argument(
"--" + long_opt,
"-" + short_opt,
action="store_true",
help=help_text,
)
else:
parser.add_argument("--" + long_opt, "-" + short_opt, help=help_text)
args = parser.parse_args()

runner = TestRunner()

runner.initialize_options()
for long_opt, short_opt, help_text in TestRunner.user_options:
arg = long_opt.replace("-", "_").strip("=")
setattr(runner, arg, getattr(args, arg))
runner.finalize_options()

runner.run()
145 changes: 145 additions & 0 deletions iris_grib/tests/runner/_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Provides testing capabilities for installed copies of iris-grib.

"""

# Because this file is imported by setup.py, there may be additional runtime
# imports later in the file.
import multiprocessing
import os
import sys


# NOTE: Do not inherit from object as distutils does not like it.
class TestRunner:
"""Run the iris-grib tests under nose and multiprocessor for performance"""

description = (
"Run tests under nose and multiprocessor for performance. "
"Specifying one or more test flags will run *only* those "
"tests."
)
user_options = [
(
"no-data",
"n",
"Override the paths to the data repositories so it "
"appears to the tests that it does not exist.",
),
("stop", "x", "Stop running tests after the first error or failure."),
("unit-tests", "s", "Run the limited subset of unit tests."),
("integration-tests", "i", "Run the integration tests."),
("default-tests", "d", "Run the default tests."),
(
"coding-tests",
"c",
"Run the coding standards tests. (These are a "
"subset of the default tests.)",
),
(
"num-processors=",
"p",
"The number of processors used for running " "the tests.",
),
("create-missing", "m", "Create missing test result files."),
]
boolean_options = [
"no-data",
"unit-tests",
"stop",
"default-tests",
"integration-tests",
"create-missing",
]

def initialize_options(self):
self.no_data = False
self.stop = False
self.unit_tests = False
self.default_tests = False
self.integration_tests = False
self.num_processors = None
self.create_missing = False

def finalize_options(self):
# These enviroment variables will be propagated to all the
# processes that nose.run creates.
if self.no_data:
print("Running tests in no-data mode...")
import iris.config

iris.config.TEST_DATA_DIR = None
if self.create_missing:
os.environ["IRIS_TEST_CREATE_MISSING"] = "true"

tests = []
if self.unit_tests:
tests.append("unit")
if self.default_tests:
tests.append("default")
if self.integration_tests:
tests.append("integration")
if not tests:
tests.append("default")
print("Running test suite(s): {}".format(", ".join(tests)))
if self.stop:
print("Stopping tests after the first error or failure")
if self.num_processors is None:
# Choose a magic number that works reasonably well for the default
# number of processes.
self.num_processors = (multiprocessing.cpu_count() + 1) // 4 + 1
else:
self.num_processors = int(self.num_processors)

def run(self):
import nose

if hasattr(self, "distribution") and self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require)

tests = []
if self.unit_tests:
tests.append("iris_grib.tests.unit")
if self.default_tests:
tests.append("iris_grib.tests")
if self.integration_tests:
tests.append("iris_grib.tests.integration")

if not tests:
tests.append("iris_grib.tests")

regexp_pat = r"--match=^([Tt]est(?![Mm]ixin)|[Ss]ystem)"

n_processors = max(self.num_processors, 1)

args = [
"",
None,
"--processes=%s" % n_processors,
"--verbosity=2",
regexp_pat,
"--process-timeout=180",
]

if self.stop:
args.append("--stop")

result = True
for test in tests:
args[1] = test
print()
print(
"Running test discovery on %s with %s processors."
% (test, n_processors)
)
# run the tests at module level i.e. my_module.tests
# - test must start with test/Test and must not contain the
# word Mixin.
result &= nose.run(argv=args)
if result is False:
exit(1)
Loading