Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 6 additions & 9 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions: {}
jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 5
permissions:
contents: read
strategy:
Expand Down Expand Up @@ -52,18 +52,15 @@ jobs:
- name: Add conda environment to PATH
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH

- name: Run tests
- name: Install local package
run: pip install --no-deps .

- name: Run fast tests
env:
PY_COLORS: "1"
py_ver: ${{ matrix.py-ver }}
run: |
# Install package and run pytest.
echo '::group::Installing local package'
pip install --no-deps .
echo '::endgroup::'
echo '::group::Running unit tests'
pytest -n logical --verbose --cov --cov-append --cov-config=pyproject.toml
echo '::endgroup::'
make test-fast
mv .coverage ".coverage.${py_ver}"

- name: Upload coverage data as artifact
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/weekly-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,47 @@ jobs:

- name: Check for broken hyperlinks
run: sphinx-build -b linkcheck --color -W --keep-going "docs/source" "docs/build/linkcheck"

full-tests:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
strategy:
fail-fast: false
matrix:
py-ver: ["py312", "py313", "py314"]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false

- name: Cache conda environment
id: conda-env-cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
with:
key: conda|${{runner.os}}-${{runner.arch}}|${{ hashFiles(format('requirements/locks/{0}-lock-linux-64.txt', matrix.py-ver)) }}
path: |
~/conda-env
~/.local/share/cartopy

- name: Create conda environment
if: steps.conda-env-cache.outputs.cache-hit != 'true'
env:
py_ver: ${{ matrix.py-ver }}
run: |
# Check cache hasn't pulled a partial key match.
test ! -e "${HOME}/conda-env"
conda create --prefix="${HOME}/conda-env" --file=requirements/locks/${py_ver}-lock-linux-64.txt

- name: Add conda environment to PATH
run: echo "${HOME}/conda-env/bin" >> $GITHUB_PATH

- name: Install local package
run: pip install --no-deps .

- name: Run full test suite
env:
PY_COLORS: "1"
run: make test-full
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ docs: ## Build documentation.
pre-commit:
pre-commit run --all-files

pytest:
pytest -vv
test: pre-commit ## Run linting and unit tests.
pytest -vv -m 'not slow'

test: pre-commit pytest ## Run linting and unit tests.
test-fast: ## Run fast local tests only.
pytest -vv --cov --cov-append --cov-config=pyproject.toml --numprocesses logical -m 'not slow and not network'

test-full: pre-commit ## Run all tests, including slow or network reliant.
pytest -vv --cov --cov-append --cov-config=pyproject.toml --numprocesses logical

# Mark targets as 'phony' to indicate they don't actually produce a file with
# the same name as their target. Basically for actions rather than files.
.PHONY: help setup docs test
.PHONY: help setup docs test test-fast test-full
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ filterwarnings = [
# first CI run on each branch.
"ignore::cartopy.io.DownloadWarning",
]
markers = ["network: marks tests that use external network resources"]
markers = [
"network: test uses external network resources",
"slow: test is slow to run",
]
minversion = "7"
pythonpath = ["src"]
testpaths = ["tests"]
Expand Down
3 changes: 3 additions & 0 deletions tests/operators/test_ageofair.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_calc_dist():
assert np.allclose(dist, actual_distance, rtol=1e-06, atol=20000)


@pytest.mark.slow
def test_aoa_nocyclic(xwind, ywind, wwind, geopot):
"""Test case when not cyclic."""
assert np.allclose(
Expand All @@ -89,6 +90,7 @@ def test_aoa_nocyclic(xwind, ywind, wwind, geopot):
)


@pytest.mark.slow
def test_aoa_cyclic_parallel_processing(xwind, ywind, wwind, geopot):
"""Test case when cyclic with parallel processing."""
assert np.allclose(
Expand Down Expand Up @@ -176,6 +178,7 @@ def test_aoa_ens(ens_regridded, ens_regridded_out):
)


@pytest.mark.slow
def test_aoa_ens_multicore(ens_regridded, ens_regridded_out):
"""Test case with ensembles ensuring that single core and multicore produce identical values."""
assert np.allclose(
Expand Down
2 changes: 2 additions & 0 deletions tests/operators/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def test_contour_plot_sequence(cube, tmp_working_dir):
assert Path("untitled_462149.0.png").is_file()


@pytest.mark.slow
def test_vector_plot_with_filename(vector_cubes, tmp_working_dir):
"""Plot a vector plot of u10 and v10 components."""
cube_u = vector_cubes[0].slices_over("time").next()
Expand All @@ -481,6 +482,7 @@ def test_vector_plot_with_filename(vector_cubes, tmp_working_dir):
assert Path("testvector_482016.0.png").is_file()


@pytest.mark.slow
def test_vector_plot_sequence(vector_cubes, tmp_working_dir):
"""Plot a sequence of vector plots."""
plot.vector_plot(
Expand Down