Skip to content

Commit

Permalink
CI #19 unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Apr 12, 2024
1 parent 53a4126 commit e0f62c9
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Unit Tests & Code Coverage

on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # allow manual triggering

defaults:
run:
shell: bash -l {0}

jobs:
lint:
name: Code style
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: ruff
uses: chartboost/ruff-action@v1

matrix:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
max-parallel: 5

steps:
- uses: actions/checkout@v4

- name: Create Python ${{ matrix.python-version }} environment
uses: mamba-org/setup-micromamba@v1
with:
cache-environment: true
cache-environment-key: env-key-${{ matrix.python-version }}
condarc: |
channel-priority: flexible
environment-file: environment.yml
environment-name: anaconda-test-env-py-${{ matrix.python-version }}
create-args: >-
coveralls
pytest
pytest-cov
python=${{ matrix.python-version }}
setuptools-scm
- name: Run tests with pytest & coverage
shell: bash -l {0}
run: |
set -vxeuo pipefail
coverage run --concurrency=thread --parallel-mode -m pytest -vvv --exitfirst .
coverage combine
coverage report --precision 3
- name: Upload coverage data to coveralls.io
shell: bash -l {0}
run: |
set -vxeuo pipefail
micromamba list coveralls
which coveralls
coveralls debug
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true

# https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-support
coveralls:
name: Report unit test coverage to coveralls
needs: test-matrix
runs-on: ubuntu-latest
container: python:3-slim

steps:
- name: Gather coverage and report to Coveralls
run: |
set -vxeuo pipefail
echo "Finally!"
pip3 install --upgrade coveralls
# debug mode: output prepared json and reported files list to stdout
# https://coveralls-python.readthedocs.io/en/latest/troubleshooting.html
coveralls debug
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e0f62c9

Please sign in to comment.