Skip to content

Commit

Permalink
add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyunchao committed Sep 26, 2023
1 parent 0b9b229 commit 4ede22a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
max-line-length = 120
extend-exclude =
docs/*,
setup.py
extend-ignore = E203
per-file-ignores =
*/__init__.py:F401,F403
examples/*,tests/*:E402
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

Expand All @@ -21,6 +19,9 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
# requites to grab the history of the PR
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand All @@ -29,12 +30,13 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements/ci_requirements.txt
- name: Analysing the code with pylint
run: |
pylint mindpet --rcfile=.github/pylint.conf
- name: Lint with pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
- name: Test with unit test (UT) pytest
run: |
pytest test/unit_test
- name: Test with system test (ST) pytest
run: |
pytest test/developer_test
pytest test/developer_test
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
# list of supported hooks: https://pre-commit.com/hooks.html
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.11.5
hooks:
- id: isort
args: ['--profile', 'black']

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/pylint-dev/pylint
rev: v2.14.5
hooks:
- id: pylint
args: [ "-rn", "-sn", "--rcfile=pylintrc", "--fail-on=I" ]
exclude: tests(/\w*)*/functional/|tests/input|tests(/\w*)*data/|doc/

0 comments on commit 4ede22a

Please sign in to comment.