From 6fd04e6dfaca160c3ea7f43d926f367bd57da35b Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:45:18 +0000 Subject: [PATCH 01/22] Trigger benchmarks if lock files have changed. --- .github/workflows/benchmarks_run.yml | 38 +++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 69d753e4cc..d97083f092 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -16,15 +16,39 @@ on: required: false type: string pull_request: - types: [labeled] + # Add the `labeled` type to the default list. + types: [labeled, opened, synchronize, reopened] jobs: + run_type: + runs-on: ubuntu-latest + if: github.repository == 'SciTools/iris' + outputs: + overnight: ${{ steps.overnight.outputs.overnight }} + branch: ${{ steps.branch.outputs.branch }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb + id: locks-changed + with: + paths: requirements/locks/*.lock + - id: overnight + if: github.event_name != 'pull_request' + run: echo "overnight=true" >> "$GITHUB_OUTPUT" + - id: branch + if: > + steps.locks-changed.outputs.changed == 'true' + || + github.event.label.name == 'benchmark_this' + run: echo "branch=true" >> "$GITHUB_OUTPUT" + + benchmark: - if: > - github.repository == 'SciTools/iris' && - (github.event_name != 'pull_request' || - github.event.label.name == 'benchmark_this') runs-on: ubuntu-latest + needs: run_type + if: needs.run_type.outputs.overnight == true || needs.run_type.outputs.branch == true env: IRIS_TEST_DATA_LOC_PATH: benchmarks @@ -76,7 +100,7 @@ jobs: echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV - name: Benchmark this pull request - if: ${{ github.event.label.name == 'benchmark_this' }} + if: needs.run_type.outputs.branch == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} @@ -85,7 +109,7 @@ jobs: - name: Run overnight benchmarks id: overnight - if: ${{ github.event_name != 'pull_request' }} + if: needs.run_type.outputs.overnight == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 9cb58302c7c9f27a97bac1889173be0891ec0bed Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:52:28 +0000 Subject: [PATCH 02/22] Check for 'true' string not boolean --- .github/workflows/benchmarks_run.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index d97083f092..64b6e4c9d3 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -20,7 +20,7 @@ on: types: [labeled, opened, synchronize, reopened] jobs: - run_type: + pre-checks: runs-on: ubuntu-latest if: github.repository == 'SciTools/iris' outputs: @@ -47,8 +47,8 @@ jobs: benchmark: runs-on: ubuntu-latest - needs: run_type - if: needs.run_type.outputs.overnight == true || needs.run_type.outputs.branch == true + needs: pre-checks + if: needs.pre-checks.outputs.overnight == 'true' || needs.pre-checks.outputs.branch == 'true' env: IRIS_TEST_DATA_LOC_PATH: benchmarks @@ -100,7 +100,7 @@ jobs: echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV - name: Benchmark this pull request - if: needs.run_type.outputs.branch == 'true' + if: needs.pre-checks.outputs.branch == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} @@ -109,7 +109,7 @@ jobs: - name: Run overnight benchmarks id: overnight - if: needs.run_type.outputs.overnight == 'true' + if: needs.pre-checks.outputs.overnight == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 621a7745153a5a9a8fd4b98d753aed6586cd5af4 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 10:12:39 +0000 Subject: [PATCH 03/22] Temporarily disable other CI. --- .github/workflows/ci-citation.yml | 30 ----- .github/workflows/ci-manifest.yml | 26 ---- .github/workflows/ci-tests.yml | 144 --------------------- .github/workflows/ci-wheels.yml | 165 ------------------------ .github/workflows/labeler.yml | 15 --- .github/workflows/refresh-lockfiles.yml | 18 --- .github/workflows/stale.yml | 83 ------------ .readthedocs.yml | 31 ----- 8 files changed, 512 deletions(-) delete mode 100644 .github/workflows/ci-citation.yml delete mode 100644 .github/workflows/ci-manifest.yml delete mode 100644 .github/workflows/ci-tests.yml delete mode 100644 .github/workflows/ci-wheels.yml delete mode 100644 .github/workflows/labeler.yml delete mode 100644 .github/workflows/refresh-lockfiles.yml delete mode 100644 .github/workflows/stale.yml delete mode 100644 .readthedocs.yml diff --git a/.github/workflows/ci-citation.yml b/.github/workflows/ci-citation.yml deleted file mode 100644 index 99cced758b..0000000000 --- a/.github/workflows/ci-citation.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: ci-citation - -on: - pull_request: - paths: - - "CITATION.cff" - - push: - paths: - - "CITATION.cff" - - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - validate: - name: "validate" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: "check CITATION.cff" - uses: citation-file-format/cffconvert-github-action@4cf11baa70a673bfdf9dad0acc7ee33b3f4b6084 - with: - args: "--validate" diff --git a/.github/workflows/ci-manifest.yml b/.github/workflows/ci-manifest.yml deleted file mode 100644 index 0868811ac6..0000000000 --- a/.github/workflows/ci-manifest.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Reference -# - https://github.com/actions/checkout - -name: ci-manifest - -on: - pull_request: - branches: - - "*" - - push: - branches-ignore: - - "auto-update-lockfiles" - - "pre-commit-ci-update-config" - - "dependabot/*" - - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - manifest: - name: "check-manifest" - uses: scitools/workflows/.github/workflows/ci-manifest.yml@2024.02.0 diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml deleted file mode 100644 index 5f1b2397ef..0000000000 --- a/.github/workflows/ci-tests.yml +++ /dev/null @@ -1,144 +0,0 @@ -# reference: -# - https://github.com/actions/cache -# - https://github.com/actions/checkout -# - https://github.com/marketplace/actions/setup-miniconda - -name: ci-tests - -on: - push: - branches: - - "main" - - "v*x" - tags: - - "v*" - pull_request: - branches: - - "*" - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - tests: - name: "${{ matrix.session }} (py${{ matrix.python-version }} ${{ matrix.os }})" - - runs-on: ${{ matrix.os }} - - defaults: - run: - shell: bash -l {0} - - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - python-version: ["3.11"] - session: ["doctest", "gallery", "linkcheck"] - include: - - os: "ubuntu-latest" - python-version: "3.11" - session: "tests" - coverage: "--coverage" - - os: "ubuntu-latest" - python-version: "3.10" - session: "tests" - - os: "ubuntu-latest" - python-version: "3.9" - session: "tests" - - env: - IRIS_TEST_DATA_VERSION: "2.22" - ENV_NAME: "ci-tests" - - steps: - - name: "checkout" - uses: actions/checkout@v4 - - - name: "environment configure" - env: - # Maximum cache period (in weeks) before forcing a cache refresh. - CACHE_WEEKS: 2 - run: | - echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV} - echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV} - - - name: "data cache" - uses: ./.github/workflows/composite/iris-data-cache - with: - cache_build: 0 - env_name: ${{ env.ENV_NAME }} - version: ${{ env.IRIS_TEST_DATA_VERSION }} - - - name: "conda package cache" - uses: ./.github/workflows/composite/conda-pkg-cache - with: - cache_build: 0 - cache_period: ${{ env.CACHE_PERIOD }} - env_name: ${{ env.ENV_NAME }} - - - name: "conda install" - uses: conda-incubator/setup-miniconda@v3 - with: - miniforge-version: latest - channels: conda-forge,defaults - activate-environment: ${{ env.ENV_NAME }} - auto-update-conda: false - use-only-tar-bz2: true - - - name: "conda environment cache" - uses: ./.github/workflows/composite/conda-env-cache - with: - cache_build: 0 - cache_period: ${{ env.CACHE_PERIOD }} - env_name: ${{ env.ENV_NAME }} - install_packages: "cartopy nox pip" - - - name: "conda info" - run: | - conda info - conda list - - - name: "cartopy cache" - uses: ./.github/workflows/composite/cartopy-cache - with: - cache_build: 0 - cache_period: ${{ env.CACHE_PERIOD }} - env_name: ${{ env.ENV_NAME }} - - - name: "nox cache" - uses: ./.github/workflows/composite/nox-cache - with: - cache_build: 2 - env_name: ${{ env.ENV_NAME }} - lock_file: ${{ env.LOCK_FILE }} - - # TODO: drop use of site.cfg and explicit use of mplrc - - name: "iris configure" - env: - SITE_CFG: lib/iris/etc/site.cfg - MPL_RC: ${HOME}/.config/matplotlib/matplotlibrc - run: | - mkdir -p $(dirname ${SITE_CFG}) - echo ${SITE_CFG} - echo "[Resources]" >> ${SITE_CFG} - echo "test_data_dir = ${HOME}/iris-test-data/test_data" >> ${SITE_CFG} - echo "doc_dir = ${GITHUB_WORKSPACE}/docs" >> ${SITE_CFG} - cat ${SITE_CFG} - mkdir -p $(dirname ${MPL_RC}) - echo ${MPL_RC} - echo "backend : agg" >> ${MPL_RC} - echo "image.cmap : viridis" >> ${MPL_RC} - cat ${MPL_RC} - - - name: "iris ${{ matrix.session }}" - env: - PY_VER: ${{ matrix.python-version }} - run: | - nox --session ${{ matrix.session }} -- --verbose ${{ matrix.coverage }} - - - name: Upload coverage report - uses: codecov/codecov-action@v4 - if: ${{ matrix.coverage }} diff --git a/.github/workflows/ci-wheels.yml b/.github/workflows/ci-wheels.yml deleted file mode 100644 index 35dda2e0a6..0000000000 --- a/.github/workflows/ci-wheels.yml +++ /dev/null @@ -1,165 +0,0 @@ -# Reference: -# - https://github.com/actions/checkout -# - https://github.com/actions/download-artifact -# - https://github.com/actions/upload-artifact -# - https://github.com/pypa/build -# - https://github.com/pypa/gh-action-pypi-publish -# - https://test.pypi.org/help/#apitoken - -name: ci-wheels - -on: - pull_request: - - push: - tags: - - "v*" - branches-ignore: - - "auto-update-lockfiles" - - "pre-commit-ci-update-config" - - "dependabot/*" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: "build sdist & wheel" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: "building" - shell: bash - run: | - pipx run build - - - uses: actions/upload-artifact@v4 - with: - name: pypi-artifacts - path: ${{ github.workspace }}/dist/* - - test-wheel: - needs: build - name: "test wheel (py${{ matrix.python-version }})" - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - strategy: - fail-fast: false - matrix: - python-version: ["3.9", "3.10", "3.11"] - session: ["wheel"] - env: - ENV_NAME: "ci-wheels" - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/download-artifact@v4 - with: - name: pypi-artifacts - path: ${{ github.workspace }}/dist - - - name: "environment configure" - env: - # Maximum cache period (in weeks) before forcing a cache refresh. - CACHE_WEEKS: 2 - run: | - echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV} - echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV} - - - name: "conda package cache" - uses: ./.github/workflows/composite/conda-pkg-cache - with: - cache_build: 0 - cache_period: ${{ env.CACHE_PERIOD }} - env_name: ${{ env.ENV_NAME }} - - - name: "conda install" - uses: conda-incubator/setup-miniconda@v3 - with: - miniforge-version: latest - channels: conda-forge,defaults - activate-environment: ${{ env.ENV_NAME }} - auto-update-conda: false - use-only-tar-bz2: true - - - name: "conda environment cache" - uses: ./.github/workflows/composite/conda-env-cache - with: - cache_build: 0 - cache_period: ${{ env.CACHE_PERIOD }} - env_name: ${{ env.ENV_NAME }} - install_packages: "nox pip" - - - name: "nox cache" - uses: ./.github/workflows/composite/nox-cache - with: - cache_build: 1 - env_name: ${{ env.ENV_NAME }} - lock_file: ${{ env.LOCK_FILE }} - - - name: "nox install and test wheel" - env: - PY_VER: ${{ matrix.python-version }} - run: | - nox --session ${{ matrix.session }} -- --verbose - - show-artifacts: - needs: build - name: "show artifacts" - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v4 - with: - name: pypi-artifacts - path: ${{ github.workspace }}/dist - - - shell: bash - run: | - ls -l ${{ github.workspace }}/dist - - publish-artifacts-test-pypi: - needs: test-wheel - name: "publish to test.pypi" - runs-on: ubuntu-latest - # upload to Test PyPI for every commit on main branch - # and check for the SciTools repo - if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'SciTools' - steps: - - uses: actions/download-artifact@v4 - with: - name: pypi-artifacts - path: ${{ github.workspace }}/dist - - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true - print_hash: true - - publish-artifacts-pypi: - needs: test-wheel - name: "publish to pypi" - runs-on: ubuntu-latest - # upload to PyPI for every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && github.repository_owner == 'SciTools' - steps: - - uses: actions/download-artifact@v4 - with: - name: pypi-artifacts - path: ${{ github.workspace }}/dist - - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - print_hash: true diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 7914ec2531..0000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Reference -# - https://github.com/actions/labeler - -name: "Pull Request Labeler" -on: -- pull_request_target - -jobs: - labeler: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@v5 \ No newline at end of file diff --git a/.github/workflows/refresh-lockfiles.yml b/.github/workflows/refresh-lockfiles.yml deleted file mode 100644 index 082aed2cb1..0000000000 --- a/.github/workflows/refresh-lockfiles.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Updates the environment lock files. See the called workflow in the -# scitools/workflows repo for more details. - -name: Refresh Lockfiles - - -on: - workflow_dispatch: - schedule: - # Run once a week on a Saturday night - # N.B. "should" be quoted, according to - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule - - cron: "1 0 * * 6" - -jobs: - refresh_lockfiles: - uses: scitools/workflows/.github/workflows/refresh-lockfiles.yml@2024.02.0 - secrets: inherit diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 3df5aa3a18..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,83 +0,0 @@ -# See https://github.com/actions/stale - -name: Stale issues and pull-requests - -on: - schedule: - # Run once a day - # N.B. "should" be quoted, according to - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule - - cron: "0 0 * * *" - -jobs: - stale: - if: "github.repository == 'SciTools/iris'" - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - # Idle number of days before marking issues/prs stale. - days-before-stale: 500 - - # Idle number of days before closing stale issues/prs. - days-before-close: 28 - - # Comment on the staled issues. - stale-issue-message: | - In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity. - - If this issue is still important to you, then please comment on this issue and the stale label will be removed. - - Otherwise this issue will be automatically closed in 28 days time. - - # Comment on the staled prs. - stale-pr-message: | - In order to maintain a backlog of relevant PRs, we automatically label them as stale after 500 days of inactivity. - - If this PR is still important to you, then please comment on this PR and the stale label will be removed. - - Otherwise this PR will be automatically closed in 28 days time. - - # Comment on the staled issues while closed. - close-issue-message: | - This stale issue has been automatically closed due to a lack of community activity. - - If you still care about this issue, then please either: - * Re-open this issue, if you have sufficient permissions, or - * Add a comment stating that this is still relevant and someone will re-open it on your behalf. - - # Comment on the staled prs while closed. - close-pr-message: | - This stale PR has been automatically closed due to a lack of community activity. - - If you still care about this PR, then please either: - * Re-open this PR, if you have sufficient permissions, or - * Add a comment pinging `@SciTools/iris-devs` who will re-open on your behalf. - - # Label to apply on staled issues. - stale-issue-label: Stale - - # Label to apply on staled prs. - stale-pr-label: Stale - - # Labels on issues exempted from stale. - exempt-issue-labels: - "Status: Blocked,Status: Decision Required,Peloton 🚴‍♂️,Good First Issue, Dragon 🐉, Dragon Sub-Task 🦎, Release: Major" - - # Labels on prs exempted from stale. - exempt-pr-labels: - "Status: Blocked,Status: Decision Required,Peloton 🚴‍♂️,Good First Issue, Dragon 🐉, Dragon Sub-Task 🦎, Release: Major" - - # Max number of operations per run. - operations-per-run: 300 - - # Remove stale label from issues/prs on updates/comments. - remove-stale-when-updated: true - - # Order to get issues/PRs. - ascending: true - - # Exempt all issues/prs with milestones from stale. - exempt-all-milestones: true diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index d82bd513ca..0000000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2 - -build: - os: "ubuntu-22.04" - tools: - python: "mambaforge-22.9" - jobs: - post_checkout: - # The SciTools/iris repository is shallow i.e., has a .git/shallow, - # therefore complete the repository with a full history in order - # to allow setuptools-scm to correctly auto-discover the version. - - git fetch --unshallow - - git fetch --all - # Need to stash the local changes that Read the Docs makes so that - # setuptools_scm can generate the correct Iris version. - pre_install: - - git stash - post_install: - - git stash pop - -conda: - environment: requirements/readthedocs.yml - -sphinx: - configuration: docs/src/conf.py - fail_on_warning: false - -python: - install: - - method: pip - path: . From bce39e39155a183780e2e594a5c33b40ff6443eb Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:16:52 +0000 Subject: [PATCH 04/22] Limit branch actions to pull requests --- .github/workflows/benchmarks_run.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 64b6e4c9d3..f0d2038cbd 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -39,9 +39,13 @@ jobs: run: echo "overnight=true" >> "$GITHUB_OUTPUT" - id: branch if: > - steps.locks-changed.outputs.changed == 'true' - || - github.event.label.name == 'benchmark_this' + github.event_name == 'pull_request' + && + ( + steps.locks-changed.outputs.changed == 'true' + || + github.event.label.name == 'benchmark_this' + ) run: echo "branch=true" >> "$GITHUB_OUTPUT" From 4c18e235310d91c4b685232d08de5fb7e0dbfca6 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:29:15 +0000 Subject: [PATCH 05/22] Unified continue check. --- .github/workflows/benchmarks_run.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index f0d2038cbd..3de9e66fba 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -26,12 +26,13 @@ jobs: outputs: overnight: ${{ steps.overnight.outputs.overnight }} branch: ${{ steps.branch.outputs.branch }} + continue: ${{ steps.check-continue.outputs.continue }} steps: - uses: actions/checkout@v4 with: fetch-depth: 2 - - uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb - id: locks-changed + - id: locks-changed + uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb with: paths: requirements/locks/*.lock - id: overnight @@ -47,12 +48,18 @@ jobs: github.event.label.name == 'benchmark_this' ) run: echo "branch=true" >> "$GITHUB_OUTPUT" + - id: check-continue + if: > + steps.overnight.outputs.overnight == 'true' + || + steps.branch.outputs.branch == 'true' + run: echo "continue=true" >> "$GITHUB_OUTPUT" benchmark: runs-on: ubuntu-latest needs: pre-checks - if: needs.pre-checks.outputs.overnight == 'true' || needs.pre-checks.outputs.branch == 'true' + if: needs.pre-checks.outputs.continue == 'true' env: IRIS_TEST_DATA_LOC_PATH: benchmarks From 8f097b18ff868aa53e4b5fdf4eccccf9496dc5c8 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:39:58 +0000 Subject: [PATCH 06/22] Benchmarks temporary debug mode. --- .github/workflows/benchmarks_run.yml | 70 ++-------------------------- 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 3de9e66fba..3b88709b41 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -70,53 +70,13 @@ jobs: TEST_DATA_CACHE_BUILD: "2" steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install ASV & Nox - run: | - pip install "asv!=0.6.2" nox - - - name: Cache environment directories - id: cache-env-dir - uses: actions/cache@v4 - with: - path: | - .nox - benchmarks/.asv/env - $CONDA/pkgs - key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }} - - - name: Cache test data directory - id: cache-test-data - uses: actions/cache@v4 - with: - path: | - ${{ env.IRIS_TEST_DATA_PATH }} - key: - test-data-${{ env.IRIS_TEST_DATA_VERSION }}-${{ env.TEST_DATA_CACHE_BUILD }} - - - name: Fetch the test data - if: steps.cache-test-data.outputs.cache-hit != 'true' - run: | - wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip - unzip -q iris-test-data.zip - mkdir --parents ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_LOC_PATH} - mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH} - - - name: Set test data var - run: | - echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV - - name: Benchmark this pull request if: needs.pre-checks.outputs.branch == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} run: | - python benchmarks/bm_runner.py branch origin/${{ github.base_ref }} + echo "Running benchmarks in branch mode." - name: Run overnight benchmarks id: overnight @@ -132,30 +92,6 @@ jobs: if [ "$first_commit" != "" ] then - python benchmarks/bm_runner.py overnight $first_commit + echo "first commit = ${first_commit}" + echo "Running benchmarks in overnight mode." fi - - - name: Warn of failure - if: > - failure() && - steps.overnight.outcome == 'failure' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - title="Overnight benchmark workflow failed: \`${{ github.run_id }}\`" - body="Generated by GHA run [\`${{github.run_id}}\`](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})" - gh issue create --title "$title" --body "$body" --label "Bot" --label "Type: Performance" --repo $GITHUB_REPOSITORY - - - name: Upload any benchmark reports - if: success() || steps.overnight.outcome == 'failure' - uses: actions/upload-artifact@v4 - with: - name: benchmark_reports - path: .github/workflows/benchmark_reports - - - name: Archive asv results - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: asv-raw-results - path: benchmarks/.asv/results From 55222516ad1c35f6520050b34e85785cc2228188 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:42:02 +0000 Subject: [PATCH 07/22] Demonstrate lock file trigger for benchmarks. --- requirements/locks/py311-linux-64.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/locks/py311-linux-64.lock b/requirements/locks/py311-linux-64.lock index 053251b045..15d9df594a 100644 --- a/requirements/locks/py311-linux-64.lock +++ b/requirements/locks/py311-linux-64.lock @@ -1,6 +1,7 @@ # Generated by conda-lock. # platform: linux-64 # input_hash: 9f4d0f3ce6f3f0d7af7672fdc6f449b404e067882f805f0b3c416eb77ae0f4c0 +# DELETE THIS @EXPLICIT https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81 https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2024.2.2-hbcca054_0.conda#2f4327a1cbe7f022401b236e915a5fef From fbb4ab7172275856e0707b1278cb40cc88c370c7 Mon Sep 17 00:00:00 2001 From: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> Date: Fri, 23 Feb 2024 13:13:47 +0000 Subject: [PATCH 08/22] Demonstrate overnight mode. --- .github/workflows/benchmarks_run.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 3b88709b41..4c592b284b 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -18,11 +18,14 @@ on: pull_request: # Add the `labeled` type to the default list. types: [labeled, opened, synchronize, reopened] + push: + branches: + - bm_trigger_locks + jobs: pre-checks: runs-on: ubuntu-latest - if: github.repository == 'SciTools/iris' outputs: overnight: ${{ steps.overnight.outputs.overnight }} branch: ${{ steps.branch.outputs.branch }} From d18f300a867471241532bf048a5bd60df9b1d224 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 13:18:27 +0000 Subject: [PATCH 09/22] Revert "Demonstrate overnight mode." This reverts commit fbb4ab7172275856e0707b1278cb40cc88c370c7. --- .github/workflows/benchmarks_run.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 4c592b284b..3b88709b41 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -18,14 +18,11 @@ on: pull_request: # Add the `labeled` type to the default list. types: [labeled, opened, synchronize, reopened] - push: - branches: - - bm_trigger_locks - jobs: pre-checks: runs-on: ubuntu-latest + if: github.repository == 'SciTools/iris' outputs: overnight: ${{ steps.overnight.outputs.overnight }} branch: ${{ steps.branch.outputs.branch }} From 5a5edcaf73b6cd96c9d1262828bcc58c7532d126 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 13:23:45 +0000 Subject: [PATCH 10/22] Revert "Demonstrate lock file trigger for benchmarks." This reverts commit 55222516ad1c35f6520050b34e85785cc2228188. --- requirements/locks/py311-linux-64.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements/locks/py311-linux-64.lock b/requirements/locks/py311-linux-64.lock index 15d9df594a..053251b045 100644 --- a/requirements/locks/py311-linux-64.lock +++ b/requirements/locks/py311-linux-64.lock @@ -1,7 +1,6 @@ # Generated by conda-lock. # platform: linux-64 # input_hash: 9f4d0f3ce6f3f0d7af7672fdc6f449b404e067882f805f0b3c416eb77ae0f4c0 -# DELETE THIS @EXPLICIT https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81 https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2024.2.2-hbcca054_0.conda#2f4327a1cbe7f022401b236e915a5fef From cc03034eddf38336b2d8452d1f64c3c59c93c03c Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 13:31:01 +0000 Subject: [PATCH 11/22] Minor visual improvements. --- .github/pull_request_template.md | 5 +++++ benchmarks/bm_runner.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 597c413457..34bc59182c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,3 +7,8 @@ --- [Consult Iris pull request check list]( https://scitools-iris.readthedocs.io/en/latest/developers_guide/contributing_pull_request_checklist.html) + +--- +Add any of the below labels to trigger actions on this PR: + +- https://github.com/SciTools/iris/labels/benchmark_this diff --git a/benchmarks/bm_runner.py b/benchmarks/bm_runner.py index 10dc5f469a..69f58c4f5f 100644 --- a/benchmarks/bm_runner.py +++ b/benchmarks/bm_runner.py @@ -171,7 +171,7 @@ def _gh_create_reports(commit_sha: str, results_full: str, results_shifts: str) performance_report = dedent( ( """ - ### Performance Benchmark Report: {commit_sha} + # :stopwatch: Performance Benchmark Report: {commit_sha}
Performance shifts From 2c41fb58f3a01ee16dfdcbf65ceefd33324c1bce Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 13:45:51 +0000 Subject: [PATCH 12/22] Explanatory notes. --- .github/labeler.yml | 9 ++++++--- docs/src/whatsnew/latest.rst | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index adee762bfc..7ec448be18 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,6 +1,9 @@ -# Make sure any dependency changes are benchmarked (only changes to the locks -# make a material difference - changes to the Conda YAML files are not -# benchmarked). +# benchmark_this automatically triggers the benchmark workflow when added by +# a user. No triggering happens when GitHub Actions adds the label (this +# avoids security vulnerabilities), so alternative lock-file triggers are +# therefore included in workflows/benchmarks_run.yml. Automatic labelling is +# still included here to make it easier to search pull requests, and to +# reinforce the culture of using this label. benchmark_this: - changed-files: - any-glob-to-any-file: 'requirements/locks/*.lock' diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index ab5d18d3eb..9a35729498 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -72,11 +72,11 @@ This document explains the changes made to Iris for this release 💼 Internal =========== -#. `@trexfeathers`_ used the `Pull Request Labeler Github action`_ to add the - ``benchmark_this`` label (:ref:`more info `) to - pull requests that modify ``requirements/locks/*.lock`` files - ensuring - that we know whether dependency changes will affect performance. - (:pull:`5763`) +#. `@trexfeathers`_ setup automatic benchmarking on pull requests that modify + ``requirements/locks/*.lock`` files - ensuring that we know whether + dependency changes will affect performance. Such pull requests are also + labelled using the `Pull Request Labeler Github action`_ to increase + visibility. (:pull:`5763`, :pull:`5776`) .. comment From 7806ff50dad6ce739c6eb46aba12441766098c5b Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 16:22:46 +0000 Subject: [PATCH 13/22] Revert "Benchmarks temporary debug mode." This reverts commit 8f097b18ff868aa53e4b5fdf4eccccf9496dc5c8. --- .github/workflows/benchmarks_run.yml | 70 ++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 3b88709b41..3de9e66fba 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -70,13 +70,53 @@ jobs: TEST_DATA_CACHE_BUILD: "2" steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install ASV & Nox + run: | + pip install "asv!=0.6.2" nox + + - name: Cache environment directories + id: cache-env-dir + uses: actions/cache@v4 + with: + path: | + .nox + benchmarks/.asv/env + $CONDA/pkgs + key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }} + + - name: Cache test data directory + id: cache-test-data + uses: actions/cache@v4 + with: + path: | + ${{ env.IRIS_TEST_DATA_PATH }} + key: + test-data-${{ env.IRIS_TEST_DATA_VERSION }}-${{ env.TEST_DATA_CACHE_BUILD }} + + - name: Fetch the test data + if: steps.cache-test-data.outputs.cache-hit != 'true' + run: | + wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip + unzip -q iris-test-data.zip + mkdir --parents ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_LOC_PATH} + mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH} + + - name: Set test data var + run: | + echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV + - name: Benchmark this pull request if: needs.pre-checks.outputs.branch == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} run: | - echo "Running benchmarks in branch mode." + python benchmarks/bm_runner.py branch origin/${{ github.base_ref }} - name: Run overnight benchmarks id: overnight @@ -92,6 +132,30 @@ jobs: if [ "$first_commit" != "" ] then - echo "first commit = ${first_commit}" - echo "Running benchmarks in overnight mode." + python benchmarks/bm_runner.py overnight $first_commit fi + + - name: Warn of failure + if: > + failure() && + steps.overnight.outcome == 'failure' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + title="Overnight benchmark workflow failed: \`${{ github.run_id }}\`" + body="Generated by GHA run [\`${{github.run_id}}\`](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})" + gh issue create --title "$title" --body "$body" --label "Bot" --label "Type: Performance" --repo $GITHUB_REPOSITORY + + - name: Upload any benchmark reports + if: success() || steps.overnight.outcome == 'failure' + uses: actions/upload-artifact@v4 + with: + name: benchmark_reports + path: .github/workflows/benchmark_reports + + - name: Archive asv results + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: asv-raw-results + path: benchmarks/.asv/results From bff3510696e3623c5fef45cbfd64303b10d567b1 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 16:23:40 +0000 Subject: [PATCH 14/22] Revert "Temporarily disable other CI." This reverts commit 621a7745153a5a9a8fd4b98d753aed6586cd5af4. --- .github/workflows/ci-citation.yml | 30 +++++ .github/workflows/ci-manifest.yml | 26 ++++ .github/workflows/ci-tests.yml | 144 +++++++++++++++++++++ .github/workflows/ci-wheels.yml | 165 ++++++++++++++++++++++++ .github/workflows/labeler.yml | 15 +++ .github/workflows/refresh-lockfiles.yml | 18 +++ .github/workflows/stale.yml | 83 ++++++++++++ .readthedocs.yml | 31 +++++ 8 files changed, 512 insertions(+) create mode 100644 .github/workflows/ci-citation.yml create mode 100644 .github/workflows/ci-manifest.yml create mode 100644 .github/workflows/ci-tests.yml create mode 100644 .github/workflows/ci-wheels.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/refresh-lockfiles.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .readthedocs.yml diff --git a/.github/workflows/ci-citation.yml b/.github/workflows/ci-citation.yml new file mode 100644 index 0000000000..99cced758b --- /dev/null +++ b/.github/workflows/ci-citation.yml @@ -0,0 +1,30 @@ +name: ci-citation + +on: + pull_request: + paths: + - "CITATION.cff" + + push: + paths: + - "CITATION.cff" + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + validate: + name: "validate" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: "check CITATION.cff" + uses: citation-file-format/cffconvert-github-action@4cf11baa70a673bfdf9dad0acc7ee33b3f4b6084 + with: + args: "--validate" diff --git a/.github/workflows/ci-manifest.yml b/.github/workflows/ci-manifest.yml new file mode 100644 index 0000000000..0868811ac6 --- /dev/null +++ b/.github/workflows/ci-manifest.yml @@ -0,0 +1,26 @@ +# Reference +# - https://github.com/actions/checkout + +name: ci-manifest + +on: + pull_request: + branches: + - "*" + + push: + branches-ignore: + - "auto-update-lockfiles" + - "pre-commit-ci-update-config" + - "dependabot/*" + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + manifest: + name: "check-manifest" + uses: scitools/workflows/.github/workflows/ci-manifest.yml@2024.02.0 diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000000..5f1b2397ef --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,144 @@ +# reference: +# - https://github.com/actions/cache +# - https://github.com/actions/checkout +# - https://github.com/marketplace/actions/setup-miniconda + +name: ci-tests + +on: + push: + branches: + - "main" + - "v*x" + tags: + - "v*" + pull_request: + branches: + - "*" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: "${{ matrix.session }} (py${{ matrix.python-version }} ${{ matrix.os }})" + + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.11"] + session: ["doctest", "gallery", "linkcheck"] + include: + - os: "ubuntu-latest" + python-version: "3.11" + session: "tests" + coverage: "--coverage" + - os: "ubuntu-latest" + python-version: "3.10" + session: "tests" + - os: "ubuntu-latest" + python-version: "3.9" + session: "tests" + + env: + IRIS_TEST_DATA_VERSION: "2.22" + ENV_NAME: "ci-tests" + + steps: + - name: "checkout" + uses: actions/checkout@v4 + + - name: "environment configure" + env: + # Maximum cache period (in weeks) before forcing a cache refresh. + CACHE_WEEKS: 2 + run: | + echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV} + echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV} + + - name: "data cache" + uses: ./.github/workflows/composite/iris-data-cache + with: + cache_build: 0 + env_name: ${{ env.ENV_NAME }} + version: ${{ env.IRIS_TEST_DATA_VERSION }} + + - name: "conda package cache" + uses: ./.github/workflows/composite/conda-pkg-cache + with: + cache_build: 0 + cache_period: ${{ env.CACHE_PERIOD }} + env_name: ${{ env.ENV_NAME }} + + - name: "conda install" + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + channels: conda-forge,defaults + activate-environment: ${{ env.ENV_NAME }} + auto-update-conda: false + use-only-tar-bz2: true + + - name: "conda environment cache" + uses: ./.github/workflows/composite/conda-env-cache + with: + cache_build: 0 + cache_period: ${{ env.CACHE_PERIOD }} + env_name: ${{ env.ENV_NAME }} + install_packages: "cartopy nox pip" + + - name: "conda info" + run: | + conda info + conda list + + - name: "cartopy cache" + uses: ./.github/workflows/composite/cartopy-cache + with: + cache_build: 0 + cache_period: ${{ env.CACHE_PERIOD }} + env_name: ${{ env.ENV_NAME }} + + - name: "nox cache" + uses: ./.github/workflows/composite/nox-cache + with: + cache_build: 2 + env_name: ${{ env.ENV_NAME }} + lock_file: ${{ env.LOCK_FILE }} + + # TODO: drop use of site.cfg and explicit use of mplrc + - name: "iris configure" + env: + SITE_CFG: lib/iris/etc/site.cfg + MPL_RC: ${HOME}/.config/matplotlib/matplotlibrc + run: | + mkdir -p $(dirname ${SITE_CFG}) + echo ${SITE_CFG} + echo "[Resources]" >> ${SITE_CFG} + echo "test_data_dir = ${HOME}/iris-test-data/test_data" >> ${SITE_CFG} + echo "doc_dir = ${GITHUB_WORKSPACE}/docs" >> ${SITE_CFG} + cat ${SITE_CFG} + mkdir -p $(dirname ${MPL_RC}) + echo ${MPL_RC} + echo "backend : agg" >> ${MPL_RC} + echo "image.cmap : viridis" >> ${MPL_RC} + cat ${MPL_RC} + + - name: "iris ${{ matrix.session }}" + env: + PY_VER: ${{ matrix.python-version }} + run: | + nox --session ${{ matrix.session }} -- --verbose ${{ matrix.coverage }} + + - name: Upload coverage report + uses: codecov/codecov-action@v4 + if: ${{ matrix.coverage }} diff --git a/.github/workflows/ci-wheels.yml b/.github/workflows/ci-wheels.yml new file mode 100644 index 0000000000..35dda2e0a6 --- /dev/null +++ b/.github/workflows/ci-wheels.yml @@ -0,0 +1,165 @@ +# Reference: +# - https://github.com/actions/checkout +# - https://github.com/actions/download-artifact +# - https://github.com/actions/upload-artifact +# - https://github.com/pypa/build +# - https://github.com/pypa/gh-action-pypi-publish +# - https://test.pypi.org/help/#apitoken + +name: ci-wheels + +on: + pull_request: + + push: + tags: + - "v*" + branches-ignore: + - "auto-update-lockfiles" + - "pre-commit-ci-update-config" + - "dependabot/*" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: "build sdist & wheel" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: "building" + shell: bash + run: | + pipx run build + + - uses: actions/upload-artifact@v4 + with: + name: pypi-artifacts + path: ${{ github.workspace }}/dist/* + + test-wheel: + needs: build + name: "test wheel (py${{ matrix.python-version }})" + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + session: ["wheel"] + env: + ENV_NAME: "ci-wheels" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v4 + with: + name: pypi-artifacts + path: ${{ github.workspace }}/dist + + - name: "environment configure" + env: + # Maximum cache period (in weeks) before forcing a cache refresh. + CACHE_WEEKS: 2 + run: | + echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV} + echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV} + + - name: "conda package cache" + uses: ./.github/workflows/composite/conda-pkg-cache + with: + cache_build: 0 + cache_period: ${{ env.CACHE_PERIOD }} + env_name: ${{ env.ENV_NAME }} + + - name: "conda install" + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + channels: conda-forge,defaults + activate-environment: ${{ env.ENV_NAME }} + auto-update-conda: false + use-only-tar-bz2: true + + - name: "conda environment cache" + uses: ./.github/workflows/composite/conda-env-cache + with: + cache_build: 0 + cache_period: ${{ env.CACHE_PERIOD }} + env_name: ${{ env.ENV_NAME }} + install_packages: "nox pip" + + - name: "nox cache" + uses: ./.github/workflows/composite/nox-cache + with: + cache_build: 1 + env_name: ${{ env.ENV_NAME }} + lock_file: ${{ env.LOCK_FILE }} + + - name: "nox install and test wheel" + env: + PY_VER: ${{ matrix.python-version }} + run: | + nox --session ${{ matrix.session }} -- --verbose + + show-artifacts: + needs: build + name: "show artifacts" + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: pypi-artifacts + path: ${{ github.workspace }}/dist + + - shell: bash + run: | + ls -l ${{ github.workspace }}/dist + + publish-artifacts-test-pypi: + needs: test-wheel + name: "publish to test.pypi" + runs-on: ubuntu-latest + # upload to Test PyPI for every commit on main branch + # and check for the SciTools repo + if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'SciTools' + steps: + - uses: actions/download-artifact@v4 + with: + name: pypi-artifacts + path: ${{ github.workspace }}/dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + print_hash: true + + publish-artifacts-pypi: + needs: test-wheel + name: "publish to pypi" + runs-on: ubuntu-latest + # upload to PyPI for every tag starting with 'v' + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && github.repository_owner == 'SciTools' + steps: + - uses: actions/download-artifact@v4 + with: + name: pypi-artifacts + path: ${{ github.workspace }}/dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + print_hash: true diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000000..7914ec2531 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,15 @@ +# Reference +# - https://github.com/actions/labeler + +name: "Pull Request Labeler" +on: +- pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 \ No newline at end of file diff --git a/.github/workflows/refresh-lockfiles.yml b/.github/workflows/refresh-lockfiles.yml new file mode 100644 index 0000000000..082aed2cb1 --- /dev/null +++ b/.github/workflows/refresh-lockfiles.yml @@ -0,0 +1,18 @@ +# Updates the environment lock files. See the called workflow in the +# scitools/workflows repo for more details. + +name: Refresh Lockfiles + + +on: + workflow_dispatch: + schedule: + # Run once a week on a Saturday night + # N.B. "should" be quoted, according to + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule + - cron: "1 0 * * 6" + +jobs: + refresh_lockfiles: + uses: scitools/workflows/.github/workflows/refresh-lockfiles.yml@2024.02.0 + secrets: inherit diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..3df5aa3a18 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,83 @@ +# See https://github.com/actions/stale + +name: Stale issues and pull-requests + +on: + schedule: + # Run once a day + # N.B. "should" be quoted, according to + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule + - cron: "0 0 * * *" + +jobs: + stale: + if: "github.repository == 'SciTools/iris'" + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + # Idle number of days before marking issues/prs stale. + days-before-stale: 500 + + # Idle number of days before closing stale issues/prs. + days-before-close: 28 + + # Comment on the staled issues. + stale-issue-message: | + In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity. + + If this issue is still important to you, then please comment on this issue and the stale label will be removed. + + Otherwise this issue will be automatically closed in 28 days time. + + # Comment on the staled prs. + stale-pr-message: | + In order to maintain a backlog of relevant PRs, we automatically label them as stale after 500 days of inactivity. + + If this PR is still important to you, then please comment on this PR and the stale label will be removed. + + Otherwise this PR will be automatically closed in 28 days time. + + # Comment on the staled issues while closed. + close-issue-message: | + This stale issue has been automatically closed due to a lack of community activity. + + If you still care about this issue, then please either: + * Re-open this issue, if you have sufficient permissions, or + * Add a comment stating that this is still relevant and someone will re-open it on your behalf. + + # Comment on the staled prs while closed. + close-pr-message: | + This stale PR has been automatically closed due to a lack of community activity. + + If you still care about this PR, then please either: + * Re-open this PR, if you have sufficient permissions, or + * Add a comment pinging `@SciTools/iris-devs` who will re-open on your behalf. + + # Label to apply on staled issues. + stale-issue-label: Stale + + # Label to apply on staled prs. + stale-pr-label: Stale + + # Labels on issues exempted from stale. + exempt-issue-labels: + "Status: Blocked,Status: Decision Required,Peloton 🚴‍♂️,Good First Issue, Dragon 🐉, Dragon Sub-Task 🦎, Release: Major" + + # Labels on prs exempted from stale. + exempt-pr-labels: + "Status: Blocked,Status: Decision Required,Peloton 🚴‍♂️,Good First Issue, Dragon 🐉, Dragon Sub-Task 🦎, Release: Major" + + # Max number of operations per run. + operations-per-run: 300 + + # Remove stale label from issues/prs on updates/comments. + remove-stale-when-updated: true + + # Order to get issues/PRs. + ascending: true + + # Exempt all issues/prs with milestones from stale. + exempt-all-milestones: true diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000000..d82bd513ca --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,31 @@ +version: 2 + +build: + os: "ubuntu-22.04" + tools: + python: "mambaforge-22.9" + jobs: + post_checkout: + # The SciTools/iris repository is shallow i.e., has a .git/shallow, + # therefore complete the repository with a full history in order + # to allow setuptools-scm to correctly auto-discover the version. + - git fetch --unshallow + - git fetch --all + # Need to stash the local changes that Read the Docs makes so that + # setuptools_scm can generate the correct Iris version. + pre_install: + - git stash + post_install: + - git stash pop + +conda: + environment: requirements/readthedocs.yml + +sphinx: + configuration: docs/src/conf.py + fail_on_warning: false + +python: + install: + - method: pip + path: . From b3660bd10f3c56e825214cb5ef42786732eb8fa0 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Fri, 23 Feb 2024 16:31:51 +0000 Subject: [PATCH 15/22] Fix docs indentation. --- docs/src/whatsnew/latest.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 9a35729498..776c35e18f 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -74,7 +74,7 @@ This document explains the changes made to Iris for this release #. `@trexfeathers`_ setup automatic benchmarking on pull requests that modify ``requirements/locks/*.lock`` files - ensuring that we know whether - dependency changes will affect performance. Such pull requests are also + dependency changes will affect performance. Such pull requests are also labelled using the `Pull Request Labeler Github action`_ to increase visibility. (:pull:`5763`, :pull:`5776`) From 14a8f355c42c93c6bbca14ab793b2bb2a08a3588 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 12:21:51 +0000 Subject: [PATCH 16/22] Custom ASV build command using setup.py. --- .github/labeler.yml | 10 +++++----- .github/workflows/benchmarks_run.yml | 6 +++--- benchmarks/asv.conf.json | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 7ec448be18..f5829dc0e9 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,9 +1,9 @@ # benchmark_this automatically triggers the benchmark workflow when added by # a user. No triggering happens when GitHub Actions adds the label (this -# avoids security vulnerabilities), so alternative lock-file triggers are -# therefore included in workflows/benchmarks_run.yml. Automatic labelling is -# still included here to make it easier to search pull requests, and to -# reinforce the culture of using this label. +# avoids security vulnerabilities), so alternative triggers for the below +# files are therefore included in workflows/benchmarks_run.yml. Automatic +# labelling is still included here to make it easier to search pull requests, +# and to reinforce the culture of using this label. benchmark_this: - changed-files: - - any-glob-to-any-file: 'requirements/locks/*.lock' + - any-glob-to-any-file: ['requirements/locks/*.lock', "setup.py", "pyproject.toml"] diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 3de9e66fba..52b969b9fc 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -34,7 +34,7 @@ jobs: - id: locks-changed uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb with: - paths: requirements/locks/*.lock + paths: requirements/locks/*.lock setup.py pyproject.toml - id: overnight if: github.event_name != 'pull_request' run: echo "overnight=true" >> "$GITHUB_OUTPUT" @@ -54,8 +54,8 @@ jobs: || steps.branch.outputs.branch == 'true' run: echo "continue=true" >> "$GITHUB_OUTPUT" - - + + benchmark: runs-on: ubuntu-latest needs: pre-checks diff --git a/benchmarks/asv.conf.json b/benchmarks/asv.conf.json index 4184629448..51983ec04d 100644 --- a/benchmarks/asv.conf.json +++ b/benchmarks/asv.conf.json @@ -6,6 +6,10 @@ "environment_type": "conda-delegated", "show_commit_url": "https://github.com/scitools/iris/commit/", "branches": ["upstream/main"], + "build_command": [ + "python setup.py build", + "python -mpip wheel --no-deps -w {build_cache_dir} {build_dir}" + ], "benchmark_dir": "./benchmarks", "env_dir": ".asv/env", From c490597f22ec84aa59e74aa0acdc5da3595971c4 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 12:22:47 +0000 Subject: [PATCH 17/22] Remove ASV pin. --- .github/workflows/benchmarks_run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 52b969b9fc..9a79675c26 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -77,7 +77,7 @@ jobs: - name: Install ASV & Nox run: | - pip install "asv!=0.6.2" nox + pip install asv nox - name: Cache environment directories id: cache-env-dir From 218bdb7ce2f28b33599e6842d0c1a1425aaa88f9 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 15:30:26 +0000 Subject: [PATCH 18/22] Don't trigger benchmarks when pyproject.toml changes. --- .github/labeler.yml | 2 +- .github/workflows/benchmarks_run.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index f5829dc0e9..14e9a95d30 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -6,4 +6,4 @@ # and to reinforce the culture of using this label. benchmark_this: - changed-files: - - any-glob-to-any-file: ['requirements/locks/*.lock', "setup.py", "pyproject.toml"] + - any-glob-to-any-file: ['requirements/locks/*.lock', "setup.py"] diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 9a79675c26..9a5eb441da 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -34,7 +34,8 @@ jobs: - id: locks-changed uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb with: - paths: requirements/locks/*.lock setup.py pyproject.toml + # SEE ALSO .github/labeler.yml . + paths: requirements/locks/*.lock setup.py - id: overnight if: github.event_name != 'pull_request' run: echo "overnight=true" >> "$GITHUB_OUTPUT" From 6030c98c29896b430dbcdffc70dc301922b20c9e Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 15:31:24 +0000 Subject: [PATCH 19/22] More accurate name for files-changed step. --- .github/workflows/benchmarks_run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 9a5eb441da..209729dced 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 2 - - id: locks-changed + - id: files-changed uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb with: # SEE ALSO .github/labeler.yml . @@ -44,7 +44,7 @@ jobs: github.event_name == 'pull_request' && ( - steps.locks-changed.outputs.changed == 'true' + steps.files-changed.outputs.changed == 'true' || github.event.label.name == 'benchmark_this' ) From b95548bc0e5c397998a86b622e5e1682d10e461b Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 15:34:11 +0000 Subject: [PATCH 20/22] Don't have a continue output. --- .github/workflows/benchmarks_run.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 209729dced..519e2de87a 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -26,7 +26,6 @@ jobs: outputs: overnight: ${{ steps.overnight.outputs.overnight }} branch: ${{ steps.branch.outputs.branch }} - continue: ${{ steps.check-continue.outputs.continue }} steps: - uses: actions/checkout@v4 with: @@ -49,18 +48,14 @@ jobs: github.event.label.name == 'benchmark_this' ) run: echo "branch=true" >> "$GITHUB_OUTPUT" - - id: check-continue - if: > - steps.overnight.outputs.overnight == 'true' - || - steps.branch.outputs.branch == 'true' - run: echo "continue=true" >> "$GITHUB_OUTPUT" benchmark: runs-on: ubuntu-latest needs: pre-checks - if: needs.pre-checks.outputs.continue == 'true' + if: > + needs.pre-checks.outputs.overnight == 'true' || + needs.pre-checks.outputs.branch == 'true' env: IRIS_TEST_DATA_LOC_PATH: benchmarks From 21b1b9197c80f0eb6320d7bf72941dd8f71e4084 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 15:35:59 +0000 Subject: [PATCH 21/22] Remove confusing variable name clash. --- .github/workflows/benchmarks_run.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmarks_run.yml b/.github/workflows/benchmarks_run.yml index 519e2de87a..626db393db 100644 --- a/.github/workflows/benchmarks_run.yml +++ b/.github/workflows/benchmarks_run.yml @@ -24,8 +24,8 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'SciTools/iris' outputs: - overnight: ${{ steps.overnight.outputs.overnight }} - branch: ${{ steps.branch.outputs.branch }} + overnight: ${{ steps.overnight.outputs.check }} + branch: ${{ steps.branch.outputs.check }} steps: - uses: actions/checkout@v4 with: @@ -37,7 +37,7 @@ jobs: paths: requirements/locks/*.lock setup.py - id: overnight if: github.event_name != 'pull_request' - run: echo "overnight=true" >> "$GITHUB_OUTPUT" + run: echo "check=true" >> "$GITHUB_OUTPUT" - id: branch if: > github.event_name == 'pull_request' @@ -47,7 +47,7 @@ jobs: || github.event.label.name == 'benchmark_this' ) - run: echo "branch=true" >> "$GITHUB_OUTPUT" + run: echo "check=true" >> "$GITHUB_OUTPUT" benchmark: From cd196935663f8becc16ab44c6063eaf7b1a0ad76 Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Tue, 27 Feb 2024 15:43:01 +0000 Subject: [PATCH 22/22] Update What's New entry. --- docs/src/whatsnew/latest.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 776c35e18f..8cc5bcdeaa 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -73,10 +73,9 @@ This document explains the changes made to Iris for this release =========== #. `@trexfeathers`_ setup automatic benchmarking on pull requests that modify - ``requirements/locks/*.lock`` files - ensuring that we know whether - dependency changes will affect performance. Such pull requests are also - labelled using the `Pull Request Labeler Github action`_ to increase - visibility. (:pull:`5763`, :pull:`5776`) + files likely to affect performance or performance testing. Such pull + requests are also labelled using the `Pull Request Labeler Github action`_ + to increase visibility. (:pull:`5763`, :pull:`5776`) .. comment