Skip to content

Commit 5d25f90

Browse files
authored
Run linter for pull requests only if python files have changed (microsoft#543)
### Motivation and Context This will run the linter on pull requests when python files have changed. ### Description - Skip linting if python files haven't changed, similar to this action https://github.com/microsoft/semantic-kernel/actions/workflows/python-test.yml
1 parent dae3baf commit 5d25f90

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

.github/workflows/lint.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1-
name: Lint
2-
on: push
3-
# concurrency:
4-
# group: lint-${{ github.ref }}
5-
# cancel-in-progress: true
1+
name: Python Lint
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: [ "main", "feature*" ]
66

77
jobs:
8+
paths-filter:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
output1: ${{ steps.filter.outputs.python}}
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: dorny/paths-filter@v2
15+
id: filter
16+
with:
17+
filters: |
18+
python:
19+
- 'python/**'
20+
# run only if 'python' files were changed
21+
- name: python tests
22+
if: steps.filter.outputs.python == 'true'
23+
run: echo "Python file"
24+
# run only if not 'python' files were changed
25+
- name: not python tests
26+
if: steps.filter.outputs.python != 'true'
27+
run: echo "NOT python file"
28+
829
ruff:
930
strategy:
1031
fail-fast: false
1132
matrix:
1233
python-version: ["3.8"]
1334
runs-on: ubuntu-latest
35+
needs: paths-filter
36+
if: needs.paths-filter.outputs.output1 == 'true'
1437
timeout-minutes: 5
1538
steps:
1639
- run: echo "/root/.local/bin" >> $GITHUB_PATH
@@ -32,6 +55,8 @@ jobs:
3255
matrix:
3356
python-version: ["3.8"]
3457
runs-on: ubuntu-latest
58+
needs: paths-filter
59+
if: needs.paths-filter.outputs.output1 == 'true'
3560
timeout-minutes: 5
3661
steps:
3762
- run: echo "/root/.local/bin" >> $GITHUB_PATH

0 commit comments

Comments
 (0)