Skip to content

Refactor 'main.py'

Refactor 'main.py' #36

Workflow file for this run

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
# 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