Skip to content

Commit 966a4a6

Browse files
committed
cirrus-ci conditional tasks (SciTools#4019)
* cirrus-ci conditional tasks * use bc for bash arithmetic * revert back to sed * use expr * reword * minor documentation changes * review actions
1 parent 8180b56 commit 966a4a6

4 files changed

Lines changed: 82 additions & 27 deletions

File tree

.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. Set to a non-empty string to skip.
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. Set to a non-empty string to skip.
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).$(expr $(date +%U) / ${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).$(expr $(date +%U) / ${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).$(expr $(date +%U) / ${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).$(expr $(date +%U) / ${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:
@@ -123,7 +135,8 @@ linux_minimal_task:
123135
#
124136
# Testing Full (Linux)
125137
#
126-
linux_task:
138+
test_full_task:
139+
only_if: $SKIP_TEST_FULL_TASK == "" && $SKIP_ALL_TEST_TASKS == ""
127140
<< : *CREDITS_TEMPLATE
128141
matrix:
129142
env:
@@ -155,6 +168,7 @@ linux_task:
155168
# Testing Documentation Gallery (Linux)
156169
#
157170
gallery_task:
171+
only_if: $SKIP_GALLERY_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
158172
<< : *CREDITS_TEMPLATE
159173
matrix:
160174
env:
@@ -186,6 +200,7 @@ gallery_task:
186200
# Testing Documentation (Linux)
187201
#
188202
doctest_task:
203+
only_if: $SKIP_DOCTEST_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
189204
<< : *CREDITS_TEMPLATE
190205
matrix:
191206
env:
@@ -220,7 +235,8 @@ doctest_task:
220235
#
221236
# Testing Documentation Link Check (Linux)
222237
#
223-
link_task:
238+
linkcheck_task:
239+
only_if: $SKIP_LINKCHECK_TASK == "" && $SKIP_ALL_DOC_TASKS == ""
224240
<< : *CREDITS_TEMPLATE
225241
matrix:
226242
env:

docs/iris/src/common_links.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. _SciTools: https://github.com/SciTools
2+
.. _black: https://black.readthedocs.io/en/stable/
23
.. _Iris: https://github.com/SciTools/iris
34
.. _Iris GitHub: https://github.com/SciTools/iris
45
.. _iris mailing list: https://groups.google.com/forum/#!forum/scitools-iris
@@ -15,6 +16,7 @@
1516
.. _readthedocs.yml: https://github.com/SciTools/iris/blob/master/requirements/ci/readthedocs.yml
1617
.. _cirrus-ci: https://cirrus-ci.com/github/SciTools/iris
1718
.. _.cirrus.yml: https://github.com/SciTools/iris/blob/master/.cirrus.yml
19+
.. _flake8: https://flake8.pycqa.org/en/stable/
1820
.. _.flake8.yml: https://github.com/SciTools/iris/blob/master/.flake8
1921
.. _GitHub Help Documentation: https://docs.github.com/en/github
2022
.. _using git: https://docs.github.com/en/github/using-git
@@ -24,4 +26,3 @@
2426
.. _sphinx: https://www.sphinx-doc.org/en/master/
2527
.. _napolean: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/sphinxcontrib.napoleon.html
2628
.. _legacy documentation: https://scitools.org.uk/iris/docs/v2.4.0/
27-
.. _cirrus-ci: https://cirrus-ci.com/github/SciTools/iris

docs/iris/src/developers_guide/contributing_ci_tests.rst

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
Continuous Integration (CI) Testing
66
===================================
77

8-
The `Iris`_ GitHub repository is configured to run checks on the code
9-
automatically when a pull request is created, updated or merged against
10-
Iris **master**. The checks performed are:
8+
The `Iris`_ GitHub repository is configured to run checks against all its
9+
branches automatically whenever a pull request is created, updated or merged.
10+
The checks performed are:
1111

1212
* :ref:`testing_cla`
1313
* :ref:`testing_cirrus`
@@ -18,29 +18,65 @@ Iris **master**. The checks performed are:
1818
SciTools CLA Checker
1919
********************
2020

21-
A bot that checks the user who created the pull request has signed the
22-
**Contributor's License Agreement (CLA)**. For more information on this this
23-
please see https://scitools.org.uk/organisation.html#governance
21+
A bot which checks that the GitHub author of the pull request has signed the
22+
**SciTools Contributor's License Agreement (CLA)**. For more information on
23+
this please see https://scitools.org.uk/organisation.html#governance.
2424

2525

2626
.. _testing_cirrus:
2727

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 wish to not 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 to a
61+
**non-empty** string:
62+
63+
* ``SKIP_LINT_TASK`` to skip `flake8`_ linting and `black`_ formatting
64+
* ``SKIP_TEST_MINIMAL_TASK`` to skip restricted unit and integration testing
65+
* ``SKIP_TEST_FULL_TASK`` to skip full unit and integration testing
66+
* ``SKIP_GALLERY_TASK`` to skip building the documentation gallery
67+
* ``SKIP_DOCTEST_TASK`` to skip running the documentation doc-tests
68+
* ``SKIP_LINKCHECK_TASK`` to skip checking for broken documentation URL references
69+
* ``SKIP_ALL_TEST_TASKS`` which is equivalent to setting ``SKIP_TEST_MINIMAL_TASK`` and ``SKIP_TEST_FULL_TASK``
70+
* ``SKIP_ALL_DOC_TASKS`` which is equivalent to setting ``SKIP_GALLERY_TASK``, ``SKIP_DOCTEST_TASK``, and ``SKIP_LINKCHECK_TASK``
71+
72+
e.g., to skip the linting task, the following are all equivalent::
73+
74+
SKIP_LINT_TASK: "1"
75+
SKIP_LINT_TASK: "true"
76+
SKIP_LINT_TASK: "false"
77+
SKIP_LINT_TASK: "skip"
78+
SKIP_LINT_TASK: "unicorn"
4179

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

4581
GitHub Checklist
4682
****************
@@ -50,6 +86,10 @@ passing:
5086

5187
.. image:: ci_checks.png
5288

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

92+
93+
.. _Cirrus-CI Dashboard: https://cirrus-ci.com/github/SciTools/iris
94+
.. _Cirrus-CI Documentation: https://cirrus-ci.org/guide/writing-tasks/
95+

docs/iris/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/

0 commit comments

Comments
 (0)