Skip to content

Commit 23542e5

Browse files
committed
cirrus-ci conditional tasks
1 parent fdfd1c7 commit 23542e5

File tree

5 files changed

+70
-20
lines changed

5 files changed

+70
-20
lines changed

.cirrus.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ container:
1818

1919

2020
env:
21+
# Skip specific tasks by name.
22+
SKIP_LINT_TASK: ""
23+
SKIP_TEST_MINIMAL_TASK: ""
24+
SKIP_TEST_FULL_TASK: ""
25+
SKIP_GALLERY_TASK: ""
26+
SKIP_DOCTEST_TASK: ""
27+
SKIP_LINKCHECK_TASK: ""
28+
# Skip task groups by type.
29+
SKIP_ALL_TEST_TASKS: ""
30+
SKIP_ALL_DOC_TASKS: ""
2131
# Maximum cache period (in weeks) before forcing a new cache upload.
2232
CACHE_PERIOD: "2"
2333
# Increment the build number to force new cartopy cache upload.
@@ -50,7 +60,7 @@ linux_task_template: &LINUX_TASK_TEMPLATE
5060
fingerprint_script:
5161
- wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
5262
- echo "${CIRRUS_OS} $(sha256sum miniconda.sh)"
53-
- echo "$(date +%Y).$(($(date +%U) / ${CACHE_PERIOD})):${CONDA_CACHE_BUILD}"
63+
- echo "$(date +%Y).$(($(echo $(date +%U) | sed 's/^0*//') / ${CACHE_PERIOD})):${CONDA_CACHE_BUILD}"
5464
populate_script:
5565
- bash miniconda.sh -b -p ${HOME}/miniconda
5666
- conda config --set always_yes yes --set changeps1 no
@@ -62,12 +72,12 @@ linux_task_template: &LINUX_TASK_TEMPLATE
6272
folder: ${HOME}/.local/share/cartopy
6373
fingerprint_script:
6474
- echo "${CIRRUS_OS}"
65-
- echo "$(date +%Y).$(($(date +%U) / ${CACHE_PERIOD})):${CARTOPY_CACHE_BUILD}"
75+
- echo "$(date +%Y).$(($(echo $(date +%U) | sed 's/^0*//') / ${CACHE_PERIOD})):${CARTOPY_CACHE_BUILD}"
6676
nox_cache:
6777
folder: ${CIRRUS_WORKING_DIR}/.nox
6878
fingerprint_script:
6979
- echo "${CIRRUS_TASK_NAME}"
70-
- echo "$(date +%Y).$(($(date +%U) / ${CACHE_PERIOD})):${NOX_CACHE_BUILD}"
80+
- echo "$(date +%Y).$(($(echo $(date +%U) | sed 's/^0*//') / ${CACHE_PERIOD})):${NOX_CACHE_BUILD}"
7181
- sha256sum ${CIRRUS_WORKING_DIR}/requirements/ci/py$(echo ${PY_VER} | tr -d ".").yml
7282

7383

@@ -82,14 +92,15 @@ compute_credits_template: &CREDITS_TEMPLATE
8292
# Linting
8393
#
8494
lint_task:
95+
only_if: $SKIP_LINT_TASK == ""
8596
<< : *CREDITS_TEMPLATE
8697
auto_cancellation: true
8798
name: "${CIRRUS_OS}: flake8 and black"
8899
pip_cache:
89100
folder: ~/.cache/pip
90101
fingerprint_script:
91102
- echo "${CIRRUS_TASK_NAME}"
92-
- echo "$(date +%Y).$(($(date +%U) / ${CACHE_PERIOD})):${PIP_CACHE_BUILD} ${PIP_CACHE_PACKAGES}"
103+
- echo "$(date +%Y).$(($(echo $(date +%U) | sed 's/^0*//') / ${CACHE_PERIOD})):${PIP_CACHE_BUILD} ${PIP_CACHE_PACKAGES}"
93104
lint_script:
94105
- pip list
95106
- python -m pip install --retries 3 --upgrade ${PIP_CACHE_PACKAGES}
@@ -101,7 +112,8 @@ lint_task:
101112
#
102113
# Testing Minimal (Linux)
103114
#
104-
linux_minimal_task:
115+
test_minimal_task:
116+
only_if: $SKIP_TEST_MINIMAL_TASK == "" && $SKIP_ALL_TEST_TASKS == ""
105117
<< : *CREDITS_TEMPLATE
106118
matrix:
107119
env:
@@ -125,7 +137,8 @@ linux_minimal_task:
125137
#
126138
# Testing Full (Linux)
127139
#
128-
linux_task:
140+
test_full_task:
141+
only_if: $SKIP_TEST_FULL_TASK == "" && $SKIP_ALL_TEST_TASKS == ""
129142
<< : *CREDITS_TEMPLATE
130143
matrix:
131144
env:
@@ -159,6 +172,7 @@ linux_task:
159172
# Testing Documentation Gallery (Linux)
160173
#
161174
gallery_task:
175+
only_if: $SKIP_GALLERY_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
162176
<< : *CREDITS_TEMPLATE
163177
matrix:
164178
env:
@@ -188,6 +202,7 @@ gallery_task:
188202
# Testing Documentation (Linux)
189203
#
190204
doctest_task:
205+
only_if: $SKIP_DOCTEST_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
191206
<< : *CREDITS_TEMPLATE
192207
matrix:
193208
env:
@@ -222,7 +237,8 @@ doctest_task:
222237
#
223238
# Testing Documentation Link Check (Linux)
224239
#
225-
link_task:
240+
linkcheck_task:
241+
only_if: $SKIP_LINKCHECK_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
226242
<< : *CREDITS_TEMPLATE
227243
matrix:
228244
env:

docs/src/common_links.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
.. _black: https://black.readthedocs.io/en/stable/
55
.. _.cirrus.yml: https://github.com/SciTools/iris/blob/master/.cirrus.yml
6+
.. _flake8: https://flake8.pycqa.org/en/stable/
67
.. _.flake8.yml: https://github.com/SciTools/iris/blob/master/.flake8
78
.. _cirrus-ci: https://cirrus-ci.com/github/SciTools/iris
89
.. _conda: https://docs.conda.io/en/latest/

docs/src/developers_guide/contributing_ci_tests.rst

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,46 @@ please see https://scitools.org.uk/organisation.html#governance
2828
Cirrus-CI
2929
*********
3030

31-
The unit and integration tests in Iris are an essential mechanism to ensure
31+
Iris unit and integration tests are an essential mechanism to ensure
3232
that the Iris code base is working as expected. :ref:`developer_running_tests`
33-
may be run manually but to ensure the checks are performed a
34-
continuous integration testing tool named `cirrus-ci`_ is used.
33+
may be performed manually by a developer locally. However Iris is configured to
34+
use the `cirrus-ci`_ service for automated Continuous Integration (CI) testing.
3535

36-
A `cirrus-ci`_ configuration file named `.cirrus.yml`_
37-
is in the Iris repository which tells Cirrus-CI what commands to run. The
38-
commands include retrieving the Iris code base and associated test files using
39-
conda and then running the tests. `cirrus-ci`_ allows for a matrix of tests to
40-
be performed to ensure that all expected variations test successfully.
36+
The `cirrus-ci`_ configuration file `.cirrus.yml`_ in the root of the Iris repository
37+
defines the tasks to be performed by `cirrus-ci`_. For further details
38+
refer to the `Cirrus-CI Documentation`_. The tasks performed during CI include:
39+
40+
* linting the code base and ensuring it adheres to the `black`_ format
41+
* running the system, integration and unit tests for Iris
42+
* ensuring the documentation gallery builds successfully
43+
* performing all doc-tests within the code base
44+
* checking all URL references within the code base and documentation are valid
45+
46+
The above `cirrus-ci`_ tasks are run automatically against all `Iris`_ branches
47+
on GitHub whenever a pull request is submitted, updated or merged. See the
48+
`Cirrus-CI Dashboard`_ for details of recent past and active Iris jobs.
49+
50+
.. _skipping Cirrus-CI tasks:
51+
52+
Skipping Cirrus-CI Tasks
53+
------------------------
54+
55+
As a developer you may not wish to run all the CI tasks when you are actively
56+
developing e.g., you are writing documentation and there is no need for linting,
57+
or long running compute intensive testing tasks to be executed.
58+
59+
As a convenience, it is possible to easily skip one or more tasks by setting
60+
the appropriate environment variable within the `.cirrus.yml`_ file:
61+
62+
* ``SKIP_LINT_TASK`` to skip `flake8`_ linting and `black`_ formatting
63+
* ``SKIP_TEST_MINIMAL_TASK`` to skip restricted unit and integration testing
64+
* ``SKIP_TEST_FULL_TASK`` to skip full unit and integration testing
65+
* ``SKIP_GALLERY_TASK`` to skip building the documentation gallery
66+
* ``SKIP_DOCTEST_TASK`` to skip running the documentation doc-tests
67+
* ``SKIP_LINKCHECK_TASK`` to skip checking for broken documentation URL references
68+
* ``SKIP_ALL_TEST_TASKS`` which is equivalent to setting ``SKIP_TEST_MINIMAL_TASK`` and ``SKIP_TEST_FULL_TASK``
69+
* ``SKIP_ALL_DOC_TASKS`` which is equivalent to setting ``SKIP_GALLERY_TASK``, ``SKIP_DOCTEST_TASK``, and ``SKIP_LINKCHECK_TASK``
4170

42-
The `cirrus-ci`_ tests are run automatically against the `Iris`_ master
43-
repository when a pull request is submitted, updated or merged.
4471

4572
GitHub Checklist
4673
****************
@@ -50,6 +77,10 @@ passing:
5077

5178
.. image:: ci_checks.png
5279

53-
If any CI checks fail, then the pull request is unlikely to be merged to the
80+
If any CI tasks fail, then the pull request is unlikely to be merged to the
5481
Iris target branch by a core developer.
5582

83+
84+
.. _Cirrus-CI Dashboard: https://cirrus-ci.com/github/SciTools/iris
85+
.. _Cirrus-CI Documentation: https://cirrus-ci.org/guide/writing-tasks/
86+

docs/src/developers_guide/contributing_code_formatting.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,4 @@ will look similar to::
5858
their officially documentation for more information.
5959

6060

61-
.. _black: https://black.readthedocs.io/en/stable/
62-
.. _flake8: https://flake8.pycqa.org/en/stable/
6361
.. _pre-commit: https://pre-commit.com/

docs/src/whatsnew/latest.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ This document explains the changes made to Iris for this release
124124
#. `@akuhnregnier`_ replaced `deprecated numpy 1.20 aliases for builtin types`_.
125125
(:pull:`3997`)
126126

127+
#. `@bjlittle`_ added conditional task execution to `.cirrus.yml`_ to allow
128+
developers to easily disable `cirrus-ci`_ tasks. See
129+
:ref:`skipping Cirrus-CI tasks`. (:pull:`4018`)
130+
127131

128132
.. comment
129133
Whatsnew author names (@github name) in alphabetical order. Note that,

0 commit comments

Comments
 (0)