uncomment diff cover test #29
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 | |
- name: Install diff-cover | |
run: | | |
pip install --user diff-cover | |
find $HOME -name "diff-cover" || echo "diff-cover not found" | |
- name: Add diff-cover to PATH | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Run diff-cover | |
run: diff-cover coverage.xml | |
# Compare coverage with the base branch | |
- name: Compare coverage | |
run: | | |
pip install diff-cover | |
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 - | |
python diff-cover --compare-branch=main coverage.xml | |
# Fail if coverage decreases | |
- name: Fail if coverage decreases | |
run: | | |
python diff-cover --compare-branch=main coverage.xml --fail-under=100 |