forked from intel/scikit-learn-intelex
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (35 loc) · 1.34 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Lint
on: [pull_request, push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changedfiles
name: Get list of changed .py files
run: |
set -x
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .py$ | xargs)" >> "$GITHUB_OUTPUT"
if [[ $(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep .py$ | wc -l) -eq 0 ]]; then
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-python@v4
name: Setup python for isort
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
with:
python-version: "3.10"
- name: Run isort on changed files
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
run: |
set -x
python -m pip install isort
isort --check ${{ steps.changedfiles.outputs.CHANGED_FILES }}
- uses: psf/black@stable
name: Run black on changed files
if: steps.changedfiles.outputs.HAS_CHANGES == 'true'
with:
src: ${{ steps.changedfiles.outputs.CHANGED_FILES }}