Skip to content

Commit 0b223a3

Browse files
committed
chore: setup CI to run all lint tests, add matching Makefile target
Uses pre-commit to run all lint tests.
1 parent 0c54209 commit 0b223a3

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

.github/workflows/test-lint.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ jobs:
2020
uses: actions/setup-python@v1
2121
with:
2222
python-version: 3.9
23+
2324
- name: Install dependencies
2425
run: |
2526
python -m pip install --upgrade pip
26-
python -m pip install --upgrade pipenv==2022.10.4
27-
pipenv install --dev --system --skip-lock
28-
- name: Lint with flake8
29-
run: |
30-
pipenv run flake8
31-
- name: Lint with black
32-
run: |
33-
pipenv run black .
27+
python -m pip install --upgrade pipenv==2022.10.4 pre-commit
28+
pipenv install --system --skip-lock
29+
30+
- uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pre-commit
33+
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
34+
35+
- name: Install pre-commit hooks
36+
run: pre-commit install --install-hooks
37+
38+
- name: Run pre-commit checks
39+
run: pre-commit run --show-diff-on-failure --all-files
40+
env:
41+
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
3442

3543
build:
3644
runs-on: ${{ matrix.os }}

Makefile

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,16 @@ SHELL :=/bin/bash
55
test ?= tests
66

77
all:
8-
echo "Usage :"
9-
echo " make test" # Run tests
10-
echo " make coverage" # Run tests and coverage
11-
echo " make black" # Run black formatter on python code
12-
echo " make flake8" # Run flake8 linter on python code
13-
echo " make isort" # Run isort linter on python code
8+
echo "Targets:"
9+
echo " test Run tests"
10+
echo " coverage Run tests with coverage"
11+
echo " lint Run all linters"
1412

1513
test:
1614
pipenv run pytest --disable-pytest-warnings -vvv $(test)
1715

1816
coverage:
1917
pipenv run coverage run --source pygitguardian -m pytest --disable-pytest-warnings && pipenv run coverage report --fail-under=80
2018

21-
black:
22-
pipenv run black .
23-
24-
flake8:
25-
pipenv run flake8
26-
27-
isort:
28-
pipenv run isort **/*.py
19+
lint:
20+
pre-commit run --all

0 commit comments

Comments
 (0)