Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/unit tests #3

Merged
merged 10 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Testing

on:
pull_request:
branches:
- main

push:
branches:
- main

jobs:
Testing:
runs-on: ubuntu-latest
steps:
# check-out repo
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# install poetry
- name: Install poetry
run: pipx install poetry==1.6.0
# set-up python with cache
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
# install requirements
- name: Install requirements
run: poetry install --with test
# run unit tests
- name: Run unit tests
run: |
set -o pipefail
poetry run make unit-tests-cov-fail
# add pytest coverage report to PR
- name: Pytest coverage comment
if: ${{ success() && github.event_name == 'pull_request' }}
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
title: Coverage Report
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##@ Testing
.PHONY: unit-tests
unit-tests:
@pytest

.PHONY: unit-tests-cov
unit-tests-cov:
@pytest --cov=src --cov-report term-missing --cov-report=html

.PHONY: unit-tests-cov-fail
unit-tests-cov-fail:
@pytest --cov=src --cov-report term-missing --cov-report=html --cov-fail-under=80 --junitxml=pytest.xml | tee pytest-coverage.txt

##@ Formatting

.PHONY: format-black
Expand Down Expand Up @@ -27,10 +40,18 @@ lint-flake8:

.PHONY: lint-mypy
lint-mypy:
@mypy --config-file pyproject.toml ./src
@mypy --config-file pyproject.toml .

.PHONY: lint-mypy-report
lint-mypy-report:
@mypy --config-file pyproject.toml ./src --html-report ./mypy_html
@mypy --config-file pyproject.toml . --html-report ./mypy_html

lint: lint-black lint-isort lint-flake8 lint-mypy

##@ Clean-up

lint: lint-black lint-isort lint-flake8 lint-mypy
clean-cov:
@rm -rf .coverage
@rm -rf htmlcov
@rm -rf pytest.xml
@rm -rf pytest-coverage.txt
Loading