ci: Use pre-commit to run linters

Now that pre-commit is added, replace the manual commands for mypy,
isort, and black with equivalent pre-commit commands. This allows us to
avoid duplicating linter arguments. It also allows us to pin the linters
used in CI by way of the .pre-commit-config.yaml file, ensuring
reproducible lint errors.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
This commit is contained in:
Stephen Brennan 2021-12-22 14:48:55 -08:00 committed by Omar Sandoval
parent 52b96aed88
commit fb99f6dbe6

View File

@ -23,11 +23,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install busybox-static libelf-dev libdw-dev qemu-kvm zstd ${{ matrix.cc == 'clang' && 'libomp-$(clang --version | sed -rn "s/.*clang version ([0-9]+).*/\\1/p")-dev' || '' }}
pip install mypy pyroute2
pip install pyroute2 pre-commit
- name: Generate version.py
run: python setup.py --version
- name: Check with mypy
run: mypy --strict --no-warn-return-any --no-warn-unused-ignores drgn _drgn.pyi
run: pre-commit run --all-files mypy
- name: Build and test with ${{ matrix.cc }}
run: python setup.py test -K
@ -38,8 +38,6 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
- name: Install dependencies
run: pip install black isort
- name: Check with black
run: black --check --diff .
- name: Check with isort
run: isort --check --diff .
run: pip install pre-commit
- name: Run pre-commit hooks
run: SKIP=mypy pre-commit run --all-files --show-diff-on-failure