From 6421dd14461de6c25032d3964eda7837e572a5c9 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Sun, 29 Oct 2023 18:05:57 +0100 Subject: [PATCH 1/3] Mark test_computationerror_ipython as flaky Add pytest-rerunfailures to [tests] optional deps. --- genno/tests/core/test_exceptions.py | 9 +++++++++ pyproject.toml | 1 + 2 files changed, 10 insertions(+) diff --git a/genno/tests/core/test_exceptions.py b/genno/tests/core/test_exceptions.py index 97a7806e..2ff39e36 100644 --- a/genno/tests/core/test_exceptions.py +++ b/genno/tests/core/test_exceptions.py @@ -1,5 +1,8 @@ +import os import re +import pytest + from genno import ComputationError, Computer from genno.testing import assert_logs from genno.testing.jupyter import get_cell_output, run_notebook @@ -48,6 +51,12 @@ def test_computationerror_format(caplog): ) +@pytest.mark.flaky( + reruns=5, + rerun_delay=2, + condition="GITHUB_ACTIONS" in os.environ, + reason="Flaky; fails occasionally on GitHub Actions runners", +) def test_computationerror_ipython(test_data_path, tmp_path): # NB this requires nbformat >= 5.0, because the output kind "evalue" was # different pre-5.0 diff --git a/pyproject.toml b/pyproject.toml index e7cda8e7..80373a97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ tests = [ "nbclient", "pytest", "pytest-cov", + "pytest-rerunfailures", "pytest-xdist", ] sparse = ["sparse >= 0.12"] From 4a064e4052b5f972dfb4bfbca58d271454e37a70 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Sun, 29 Oct 2023 18:27:17 +0100 Subject: [PATCH 2/3] Remove Sphinx build step from "pytest" CI workflow --- .github/workflows/pytest.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index d4f4410e..59734286 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -25,7 +25,8 @@ jobs: python: # llvmlite (thus numba, thus sparse) usually lags the latest Python # release. Only test SparseDataArray where possible. - # Earliest version supported by genno; matches xarray/setup.cfg + # Earliest version supported by genno = earliest Python that has not + # reached EOL - {version: "3.8", extras: ",sparse"} - {version: "3.9", extras: ",sparse"} - {version: "3.10", extras: ",sparse"} @@ -38,7 +39,7 @@ jobs: # Compiling these on the job runner requires a more elaborate build # environment, currently out of scope for genno. Exclude these versions # from CI. - # - {version: "3.12.0-alpha.2", extras: ""} # Development version + # - {version: "3.13.0-rc.1", extras: ""} # Development version fail-fast: false @@ -61,14 +62,15 @@ jobs: macos-skip-brew-update: true - name: Install the Python package and dependencies - run: pip install --upgrade --upgrade-strategy=eager .[docs,tests${{ matrix.python.extras }}] + run: pip install --upgrade --upgrade-strategy=eager .[tests${{ matrix.python.extras }}] - name: Run test suite using pytest - run: pytest genno --trace-config --color=yes --verbose --cov-report=xml --cov-report=term --numprocesses auto - - - name: Test documentation build using Sphinx - if: startsWith(matrix.os, 'ubuntu') - run: make -C doc html + run: | + pytest genno \ + --trace-config --color=yes --verbose \ + --cov-report=xml --cov-report=term \ + --numprocesses auto + shell: bash - name: Upload test coverage to Codecov.io uses: codecov/codecov-action@v3 From 8f8fd9547b86cdbd9f11aabc25825a18c88d0b26 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Sun, 29 Oct 2023 18:48:56 +0100 Subject: [PATCH 3/3] Force recreation of pre-commit venv for mypy --- .github/workflows/pytest.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 59734286..394b1396 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -83,4 +83,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 + + - name: Force recreation of pre-commit virtual environment for mypy + if: github.event_name == 'schedule' # Comment this line to run on a PR + run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true + env: { GH_TOKEN: "${{ github.token }}" } + - uses: pre-commit/action@v3.0.0