Skip to content

Commit

Permalink
Add code coverage via Github Actions (#124)
Browse files Browse the repository at this point in the history
* Add in code coverage via Github Actions and codecov.io
  • Loading branch information
freemansw1 authored Jun 27, 2022
1 parent fee0208 commit 6460b1d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source=tobac
omit = tobac/tests/*
33 changes: 33 additions & 0 deletions .github/workflows/codecov-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Codecov CI

on: [push, pull_request]

jobs:
run:
runs-on: ubuntu-latest
env:
OS: ubuntu-latest
PYTHON: '3.9'
steps:
- uses: actions/checkout@v2
# Similar to MetPy install-conda action
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
miniforge-variant: mambaforge
channel-priority: strict
channels: conda-forge
show-channel-urls: true
use-only-tar-bz2: true

- name: Install dependencies and generate report
shell: bash -l {0}
run: mamba install --quiet --yes --file conda-requirements.txt coverage pytest-cov &&
python -m coverage run -m pytest --cov=./ --cov-report=xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
flags: unittests

15 changes: 15 additions & 0 deletions tobac/tests/Dockerfile-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mambaorg/micromamba
ARG MAMBA_DOCKERFILE_ACTIVATE=1

RUN micromamba install -y -n base -c conda-forge numpy \
scipy scikit-image pandas pytables matplotlib iris \
cf-units xarray cartopy trackpy numba pytest pip \
pytest-cov coverage

COPY . ./

RUN pip install .

RUN coverage run -m pytest --cov-report=xml &&\
mv coverage.xml shared

0 comments on commit 6460b1d

Please sign in to comment.