Skip to content

Commit

Permalink
Setting up pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blowekamp committed Mar 6, 2024
1 parent acef65f commit 1f34a14
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

25 changes: 13 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint with black
run: |
python -m black --check --diff .
- name: Lint with flake8
python-version: 3.11
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Linting
run: |
# stop the build for flake8 issues
python -m flake8 . --show-source --statistics
pip install pre-commit
pre-commit run --all-files
test:
needs: linting
Expand Down
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# .pre-commit-config.yaml
# for details see https://pre-commit.com
# for list of available hooks see https://pre-commit.com/hooks.html
#
# Preclude commits that do not conform to various criteria.

fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks: # check for large files, aws credentials and private key files
- id: check-added-large-files
args: ['--maxkb=200']
- id: detect-private-key
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
entry: pflake8
additional_dependencies: [pyproject-flake8]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks: # check conformance to black formatting
- id: black
args: ['--diff', '-v'] # if run without arguments, will fail and will format the files
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ junit_family="xunit2"
[tool.black]
line-length = 120
exclude = '(docs/conf\.py)|venv*'

[tools.flake8]
max-line-length = 120
extend-exclude = "docs/conf.py,venv*"

0 comments on commit 1f34a14

Please sign in to comment.