Add pre-commit hooks to match GitHub CI pipeline (#7)

* Add pre-commit hooks to match CI pipeline linting rules

* Add pre-commit hooks that match GitHub CI pipeline exactly

* Ran lint check
This commit is contained in:
Jatin K Malik
2025-04-17 00:05:34 -05:00
committed by GitHub
parent 642be732db
commit a28f55b72e
12 changed files with 205 additions and 28 deletions
+15 -15
View File
@@ -17,30 +17,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install development dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 black isort
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
- name: Check formatting with black
run: |
black --check src/ tests/
- name: Check import sorting with isort
run: |
isort --check-only --profile black src/ tests/
@@ -50,18 +50,18 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.8]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install system dependencies
run: |
sudo apt-get update
@@ -76,7 +76,7 @@ jobs:
gobject-introspection \
libcairo-gobject2 \
gir1.2-gtk-3.0
- name: Cache apt packages
uses: actions/cache@v3
with:
@@ -84,7 +84,7 @@ jobs:
key: ${{ runner.os }}-apt-${{ hashFiles('**/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-apt-
- name: Set up virtual environment
run: |
python -m venv venv
@@ -95,14 +95,14 @@ jobs:
python -m pip install pytest pytest-cov
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
echo "PATH=$VIRTUAL_ENV/bin:$PATH" >> $GITHUB_ENV
- name: Run pytest suite with coverage
run: |
source venv/bin/activate
# Make sure Python can find the 'src' module
PYTHONPATH=$PWD pytest --cov=src tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
+1 -1
View File
@@ -34,4 +34,4 @@ jobs:
files: |
dist/*.whl
dist/*.tar.gz
generate_release_notes: true
generate_release_notes: true