diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4603ea3..831ee41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ on: - cron: '0 0 * * *' # Daily “At 00:00” workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: Python (${{ matrix.python-version }}, ${{ matrix.os }}) @@ -15,40 +19,24 @@ jobs: defaults: run: shell: bash -l {0} - strategy: fail-fast: false matrix: os: [ "ubuntu-latest", "macos-latest", "macos-14", "windows-latest"] python-version: [ "3.9", "3.11", "3.12" ] steps: - - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - name: checkout uses: actions/checkout@v4 - with: - token: ${{ github.token }} - - name: conda_setup - uses: conda-incubator/setup-miniconda@v3 - if: matrix.os != 'macos-14' - with: - activate-environment: geocat_viz_build - channel-priority: strict - python-version: ${{ matrix.python-version }} - channels: conda-forge - environment-file: build_envs/environment.yml - - name: conda_setup_m1 + + - name: environment setup uses: conda-incubator/setup-miniconda@v3 - if: matrix.os == 'macos-14' with: - installer-url: https://github.com/conda-forge/miniforge/releases/download/23.11.0-0/Mambaforge-23.11.0-0-MacOSX-arm64.sh activate-environment: geocat_viz_build channel-priority: strict python-version: ${{ matrix.python-version }} channels: conda-forge environment-file: build_envs/environment.yml + - name: Install geocat-viz run: | python -m pip install . --no-deps @@ -57,6 +45,10 @@ jobs: run: | conda list + - name: tests + run: | + python -m pytest + link-check: runs-on: ubuntu-latest defaults: @@ -65,9 +57,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - token: ${{ github.token }} - - name: conda_setup + + - name: environment setup uses: conda-incubator/setup-miniconda@v3 with: activate-environment: gv-docs @@ -75,12 +66,15 @@ jobs: python-version: 3.9 channels: conda-forge environment-file: build_envs/docs.yml + - name: Install geocat-viz run: | python -m pip install . + - name: check conda list run: | conda list + - name: Make docs with linkcheck run: | cd docs diff --git a/build_envs/environment.yml b/build_envs/environment.yml index b78dfcc..f06c8eb 100644 --- a/build_envs/environment.yml +++ b/build_envs/environment.yml @@ -7,13 +7,13 @@ dependencies: - make - matplotlib - sphinx - - pip - cmaps - numpy - xarray - metpy - pint + - pytest + - pytest-mpl - geocat-datafiles - - pip: - - pre-commit - - scikit-learn + - pre-commit + - scikit-learn diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 6dc285f..a57ce02 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -5,6 +5,18 @@ Release Notes ============= +v2024.04.0 (unreleased) +--------------------------- + +Internal Changes +^^^^^^^^^^^^^^^^ +* Remove M1 workaround for CI and tokens that are no longer needed by `Katelyn FitzGerald`_ in (:pr:`232`) + +Testing +^^^^^^^ +* Add basic testing infrastructure by `Katelyn FitzGerald`_ and `Julia Kent`_ in (:pr:`233`) + + v2024.03.0 (March 26, 2024) --------------------------- This release deprecates ``TaylorDiagram`` method names ``add_xgrid()`` and diff --git a/setup.cfg b/setup.cfg index 5c5e6a1..9711735 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,9 @@ install_requires = setuptools scikit-learn metpy +tests_require = + pytest + pytest-mpl [options.packages.find] where = src @@ -64,7 +67,7 @@ docs = [tool:pytest] python_files = test_*.py -testpaths = test +testpaths = tests [aliases] test = pytest diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_util.py b/tests/test_util.py new file mode 100644 index 0000000..8084bec --- /dev/null +++ b/tests/test_util.py @@ -0,0 +1,13 @@ +import pytest +import matplotlib as mpl + +from geocat.viz.util import truncate_colormap + + +def test_truncate_colormap(): + cmap = mpl.colormaps['terrain'] + truncated_cmap = truncate_colormap(cmap, 0.1, 0.9) + + assert isinstance(truncated_cmap, mpl.colors.LinearSegmentedColormap) + assert truncated_cmap(0.0) == cmap(0.1) + assert truncated_cmap(1.0) == cmap(0.9)