Skip to content

Commit

Permalink
use pre-commit for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Sep 11, 2023
1 parent 0261690 commit 41f43ad
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
fetch-depth: 0

- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only --diff-filter=ACMR -r HEAD^1 HEAD | grep -E '\.py$|\/pyproject.toml$' | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only --diff-filter=ACMR ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.py$|\/pyproject.toml$' | xargs)" >> $GITHUB_OUTPUT
fi
- uses: actions/setup-python@v4
python-version: "3.11"
with:
cache: "pip"

- uses: psf/black@stable
- run: pip install --upgrade pre-commit

- uses: chartboost/ruff-action@v1
if: steps.changed-files.outputs.changed_files != ''
- uses: actions/cache@v3
with:
src: ${{ steps.changed-files.outputs.changed_files }}
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Lint
run: pre-commit run --files $(git diff --name-only master...HEAD)

0 comments on commit 41f43ad

Please sign in to comment.