Skip to content

Merge pull request #2369 from rcomer/ne-test-fixes #94

Merge pull request #2369 from rcomer/ne-test-fixes

Merge pull request #2369 from rcomer/ne-test-fixes #94

Workflow file for this run

name: Tests
on: [push, pull_request]
jobs:
build:
if: github.repository == 'scitools/cartopy'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, '3.10', '3.11', '3.12']
shapely-dev: [false]
include:
- os: ubuntu-latest
python-version: '3.11'
shapely-dev: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Minimum packages
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
id: minimum-packages
run: |
pip install cython==0.29.24 matplotlib==3.5.3 numpy==1.21 owslib==0.24.1 pyproj==3.3.1 scipy==1.6.3 shapely==1.7.1 pyshp==2.3.1
- name: Coverage packages
id: coverage
# only want the coverage to be run on the latest ubuntu
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
run: |
echo "CYTHON_COVERAGE=1" >> $GITHUB_ENV
# Also add doctest here to avoid windows runners which expect a different path separator
echo "EXTRA_TEST_ARGS=--cov=cartopy -ra --doctest-modules" >> $GITHUB_ENV
pip install cython
- name: Install Shapely dev
if: matrix.shapely-dev
run: |
# Install Shapely from source on ubuntu
sudo apt-get update
sudo apt-get install -yy libgeos-dev
pip install git+https://github.com/shapely/shapely.git@main
- name: Install Cartopy
id: install
run: |
pip install -e .[test]
python -c "import cartopy; print('Version ', cartopy.__version__)"
- name: Install extras
# Default is to install just the minimum testing requirements,
# but we want to get as much coverage as possible.
if: steps.minimum-packages.conclusion == 'skipped'
run: |
pip install .[ows,plotting,speedups]
- name: Testing
id: test
# we need to force bash to use line continuations on Windows
shell: bash
run: |
# Check that the downloader tool at least knows where to get the data from (but don't actually download it)
python -m cartopy.feature.download gshhs physical --dry-run
# It should also be available as a script
cartopy_feature_download gshhs physical --dry-run
CARTOPY_GIT_DIR=$PWD
pytest -rfEsX -n 4 \
--color=yes \
--mpl --mpl-generate-summary=html \
--mpl-results-path="cartopy_test_output-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.shapely-dev }}" \
--pyargs cartopy ${EXTRA_TEST_ARGS}
- name: Coveralls
if: steps.coverage.conclusion == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
coveralls --service=github
- name: Upload image results
uses: actions/upload-artifact@v4
if: failure()
with:
name: image-failures-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.shapely-dev }}
path: cartopy_test_output-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.shapely-dev }}