update paths for diff cover #27
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: Tests and Style | |
on: [push, pull_request] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
python-version: [3.11.4] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Switch to Current Branch | |
run: git checkout ${{ env.BRANCH }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -e . | |
- name: Run flake8 | |
run: | | |
pip install flake8 | |
# stop the build if there are flake8 errors | |
flake8 . --count --show-source --statistics | |
- name: Run unit tests | |
run: | | |
pip install pytest | |
python -m pytest src/jp2_remediator/tests/unit | |
- name: Run coverage | |
run: | | |
pip install coverage | |
python -m coverage run -p -m pytest src/jp2_remediator/tests/unit | |
python -m coverage combine | |
python -m coverage report -m --skip-covered | |
python -m coverage xml | |
# Fetch base branch for comparison (e.g., main) | |
- name: Fetch base branch | |
run: git fetch origin main | |
# Install diff-cover globally to access it | |
- name: Install diff-cover globally | |
run: pip install --target=/usr/local/bin diff-cover | |
# Compare coverage with the base branch | |
- name: Compare coverage | |
run: | | |
git checkout main | |
python -m coverage run -p -m pytest src/jp2_remediator/tests/unit | |
python -m coverage xml -o coverage-base.xml | |
git checkout - | |
~/.local/bin/diff-cover --compare-branch=main coverage.xml | |
python diff-cover --compare-branch=main coverage.xml | |
# Fail if coverage decreases | |
- name: Fail if coverage decreases | |
run: | | |
~/.local/bin/diff-cover --compare-branch=main coverage.xml --fail-under=100 | |