Skip to content

Dev

Dev #128

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Tests
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
# cancel any currently running workflows in this same PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Use bash by default in all jobs
defaults:
run:
shell: bash -el {0}
jobs:
#############################################################################
# Run tests and upload to codecov
test:
name: ${{ matrix.os }} python=${{ matrix.python }} dependencies=${{ matrix.dependencies }}
runs-on: ${{ matrix.os }}-latest
strategy:
# Otherwise, the workflow would stop if a single job fails. We want to
# run all of them to catch failures in different combinations.
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
dependencies:
- oldest
- latest
include:
- dependencies: oldest
python: "3.9"
- dependencies: latest
python: "3.10"
env:
REQUIREMENTS: env/requirements-build.txt env/requirements-tests.txt
# Used to tag codecov submissions
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
DEPENDENCIES: ${{ matrix.dependencies }}
steps:
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Switch to Current Branch
run: git checkout ${{ env.BRANCH }}
# Install Mambaforge with conda-forge dependencies
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: antarctic_plots
environment-file: env/env_test.yml
python-version: ${{ matrix.python }}
channels: conda-forge,nodefaults
channel-priority: strict
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
use-mamba: true
auto-activate-base: false
# Show installed pkg information for postmortem diagnostic
- name: List installed packages
run: mamba list
- name: Run the tests
continue-on-error: true
run: |
mkdir -p .cov
pytest --cov . --cov-config=pyproject.toml --cov-report xml:.cov/coverage.xml -m ""
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: .cov/coverage.xml
# Don't mark the job as failed if the upload fails for some reason.
# It does sometimes but shouldn't be the reason for running
# everything again unless something else is broken.
fail_ci_if_error: false