Skip to content

CI lockfiles #4108

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

Merged
merged 30 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a9a4757
introducing lock files for testing
jamesp Apr 27, 2021
642a03e
Testing github refresh workflow
jamesp Apr 27, 2021
bb444a8
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
bd58e70
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
f6c2ca5
Action making lockfiles and setting as artifacts
jamesp Apr 27, 2021
596d2a0
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
9dea68d
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
81ba3aa
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
26b3e35
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
5552016
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
ddb3a8e
Added PR creation
jamesp Apr 27, 2021
b20615c
Cleanup refresh-lockfiles.yml
jamesp Apr 27, 2021
8f71bc1
Update .cirrus.yml
jamesp Apr 27, 2021
fc07f17
Update refresh-lockfiles.yml
jamesp Apr 27, 2021
22e325d
Back to cartopy 0.18
jamesp Apr 28, 2021
2ce13b2
Merge branch 'ci-lock' of github.com:jamesp/iris into ci-lock
jamesp Apr 28, 2021
153254d
Script for updating lockfiles
jamesp Apr 28, 2021
59c93b1
License header on update_lockfiles script
jamesp Apr 28, 2021
45311ee
testing reupload_on_changes key in nox cache
jamesp Apr 28, 2021
35570d0
Documentation update
jamesp Apr 28, 2021
0305416
Added whats new entry
jamesp Apr 28, 2021
39c3b6b
Fixed a horrendous number of typos
jamesp Apr 29, 2021
90a0599
Type annotations in the noxfile completed
jamesp Apr 29, 2021
8480c21
switched os.path -> pathlib in tools/update_lockfiles.py
jamesp Apr 29, 2021
48e39b5
Apply suggestions from @trexfeathers code review
jamesp Apr 29, 2021
a539b25
Updated imagehashes
jamesp May 4, 2021
5b3e876
Updated documentation of the github workflow
jamesp May 4, 2021
e3af577
Merge branch 'ci-lock' of github.com:jamesp/iris into ci-lock
jamesp May 4, 2021
3301584
Updated image hash for anomaly log plot
jamesp May 4, 2021
5241637
Reverting imagerepo.json to state at 48e39b57
jamesp May 4, 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
5 changes: 2 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ linux_task_template: &LINUX_TASK_TEMPLATE
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${CARTOPY_CACHE_BUILD}"
nox_cache:
folder: ${CIRRUS_WORKING_DIR}/.nox
reupload_on_changes: true
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 "${NOX_CACHE_BUILD}"

#
# YAML alias for compute credits.
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/refresh-lockfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow periodically creates new environment lock files based on the newest
# available packages and dependencies.
#
# Environment specifications are given as conda environment.yml files found in
# `requirements/ci/py**.yml`. These state the pacakges required, the conda channels
# that the packages will be pulled from, and any versions of packages that need to be
# pinned at specific versions.
#
# For environments that have changed, a pull request will be made and submitted
# to the master branch

name: Refresh Lockfiles


on:
workflow_dispatch:
schedule:
# Run once a week on a Saturday night
- cron: 1 0 * * 6


jobs:

gen_lockfiles:
# this is a matrix job: it splits to create new lockfiles for each
# of the CI test python versions.
# this list below should be changed when covering more python versions
# TODO: generate this matrix automatically from the list of available py**.yml files
# ref: https://tomasvotruba.com/blog/2020/11/16/how-to-make-dynamic-matrix-in-github-actions/
runs-on: ubuntu-latest

strategy:
matrix:
python: ['36', '37', '38']

steps:
- uses: actions/checkout@v2
- name: install conda-lock
run: |
source $CONDA/bin/activate base
conda install -y -c conda-forge conda-lock
- name: generate lockfile
run: |
$CONDA/bin/conda-lock lock -p linux-64 -f requirements/ci/py${{matrix.python}}.yml
mv conda-linux-64.lock py${{matrix.python}}-linux-64.lock
- name: output lockfile
uses: actions/upload-artifact@v2
with:
path: py${{matrix.python}}-linux-64.lock

create_pr:
# once the matrix job has completed all the lock files will have been uploaded as artifacts.
# Download the artifacts, add them to the repo, and create a PR.
runs-on: ubuntu-latest
needs: gen_lockfiles

steps:
- uses: actions/checkout@v2
- name: get artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Update lock files in repo
run: |
cp artifacts/artifact/*.lock requirements/ci/nox.lock
rm -r artifacts

- name: Create Pull Request
uses: peter-evans/create-pull-request@052fc72b4198ba9fbc81b818c6e1859f747d49a8
with:
commit-message: Updated environment lockfiles
delete-branch: true
branch: lockfiles
branch-suffix: timestamp
title: Update CI environment lockfiles
body: |
Lockfiles updated to the latest resolvable environment.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lockfiles:
python tools/update_lockfiles.py -o requirements/ci/nox.lock requirements/ci/py*.yml
31 changes: 30 additions & 1 deletion docs/src/developers_guide/contributing_ci_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ The above `cirrus-ci`_ tasks are run automatically against all `Iris`_ branches
on GitHub whenever a pull-request is submitted, updated or merged. See the
`Cirrus-CI Dashboard`_ for details of recent past and active Iris jobs.


.. _cirrus_test_env:

Cirrus CI Test environment
--------------------------

The test environment on the Cirrus-CI service is determined from the requirement files
in ``requirements/ci/py**.yml``. These are conda environment files that list the entire
set of build, test and run requirements for Iris.

For reproducible test results, these environments are resolved for all their dependencies
and stored as lock files in ``requirements/ci/nox.lock``. The test environments will not
resolve the dependencies each time, instead they will use the lock file to reproduce the
same exact environment each time.

**If you have updated the requirement yaml files with new dependencies, you will need to
generate new lock files.** To do this, run the command::

python tools/update_lockfiles.py -o requirements/ci/nox.lock requirements/ci/py*.yml

or simply::

make lockfiles

and add the changed lockfiles to your pull request.

New lockfiles are generated automatically each week to ensure that Iris continues to be
tested against the latest available version of its dependencies.


.. _skipping Cirrus-CI tasks:

Skipping Cirrus-CI Tasks
Expand Down Expand Up @@ -107,4 +137,3 @@ See the `pre-commit.ci dashboard`_ for details of recent past and active Iris jo
.. _Cirrus-CI Documentation: https://cirrus-ci.org/guide/writing-tasks/
.. _.pre-commit-config.yaml: https://github.com/SciTools/iris/blob/master/.pre-commit-config.yaml
.. _pre-commit.ci dashboard: https://results.pre-commit.ci/repo/github/5312648

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ is merged. Before submitting a pull request please consider this list.
#. **Check all modified and new source files conform to the required**
:ref:`code_formatting`.

#. **Check all new dependencies added to the ``requirements/ci/*.yml`` files.** If
dependencies have been added then new nox testing lockfiles should be generated too,
see :ref:`cirrus_test_env`.

#. **Check the source documentation been updated to explain all new or changed
features**. See :ref:`docstrings`.

Expand Down
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ This document explains the changes made to Iris for this release
#. `@bjlittle`_ updated the perceptual imagehash graphical test support for
`matplotlib`_ 3.4.1. (:pull:`4087`)

#. `@jamesp`_ switched `cirrus-ci`_ testing and `nox`_
testing to use `conda-lock`_ files for static test environments. (:pull:`4108`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand All @@ -175,3 +177,4 @@ This document explains the changes made to Iris for this release
.. _Python 3.8: https://www.python.org/downloads/release/python-380/
.. _README.md: https://github.com/SciTools/iris#-----
.. _xxhash: http://cyan4973.github.io/xxHash/
.. _conda-lock: https://github.com/conda-incubator/conda-lock
Loading