Merge pull request #52 from cadifyai/enhancement/add-coverage #174
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Code | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# required by sticky-pull-request-comment | |
permissions: | |
pull-requests: write | |
jobs: | |
linting: | |
runs-on: ubuntu-latest | |
steps: | |
#---------------------------------------------- | |
# check-out repo and set-up python | |
#---------------------------------------------- | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
#---------------------------------------------- | |
# install and run linters | |
#---------------------------------------------- | |
- run: python -m pip install black flake8 isort | |
- run: | | |
flake8 . --count --show-source --statistics | |
black . --check | |
isort . --check | |
test: | |
needs: linting | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | |
runs-on: "ubuntu-latest" | |
steps: | |
#---------------------------------------------- | |
# check-out repo and set-up python | |
#---------------------------------------------- | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
#---------------------------------------------- | |
# --------- install dependencies --------- | |
#---------------------------------------------- | |
- name: Install dependencies | |
run: poetry install --no-interaction --no-root | |
#---------------------------------------------- | |
# add matrix specifics and run test suite | |
#---------------------------------------------- | |
- name: Run tests | |
run: | | |
poetry run coverage run -m pytest tests/ | |
poetry run coverage xml | |
#---------------------------------------------- | |
# create coverage summary | |
#---------------------------------------------- | |
- name: Code Coverage Summary Report | |
uses: irongut/CodeCoverageSummary@v1.3.0 | |
with: | |
filename: coverage.xml | |
format: markdown | |
output: both # console and .md file | |
badge: true | |
fail_below_min: true | |
thresholds: '95 100' | |
#---------------------------------------------- | |
# write job summary | |
#---------------------------------------------- | |
- name: Write job summary | |
run: | | |
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |