Skip to content

Commit 089b957

Browse files
authored
run linters only when respective files are changed (#7387)
* run linters only when respective files are changed * also run on manual triggers
1 parent 8ab0b2b commit 089b957

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/code-quality.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,39 @@ on:
77
name: code-quality
88

99
jobs:
10+
changes:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
r: ${{ steps.filter.outputs.r }}
14+
c: ${{ steps.filter.outputs.c }}
15+
po: ${{ steps.filter.outputs.po }}
16+
md: ${{ steps.filter.outputs.md }}
17+
rd: ${{ steps.filter.outputs.rd }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # ensure diff against base is available for PRs
22+
- uses: dorny/paths-filter@v3
23+
id: filter
24+
with:
25+
filters: |
26+
r:
27+
- '**/*.R'
28+
- '**/*.Rmd'
29+
c:
30+
- '**/*.c'
31+
- '**/*.h'
32+
po:
33+
- 'po/**/*.po'
34+
md:
35+
- '**/*.md'
36+
- '**/*.Rmd'
37+
rd:
38+
- 'man/**/*.Rd'
39+
1040
lint-r:
41+
needs: changes
42+
if: needs.changes.outputs.r == 'true' || github.event_name == 'workflow_dispatch'
1143
runs-on: ubuntu-latest
1244
env:
1345
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -32,6 +64,8 @@ jobs:
3264
LINTR_ERROR_ON_LINT: true
3365
R_LINTR_LINTER_FILE: .ci/.lintr
3466
lint-c:
67+
needs: changes
68+
if: needs.changes.outputs.c == 'true' || github.event_name == 'workflow_dispatch'
3569
runs-on: ubuntu-latest
3670
steps:
3771
- uses: actions/checkout@v4
@@ -43,6 +77,8 @@ jobs:
4377
run: |
4478
Rscript .ci/lint.R .ci/linters/c src '[.][ch]$'
4579
lint-po:
80+
needs: changes
81+
if: needs.changes.outputs.po == 'true' || github.event_name == 'workflow_dispatch'
4682
runs-on: ubuntu-latest
4783
steps:
4884
- uses: actions/checkout@v4
@@ -56,13 +92,17 @@ jobs:
5692
run: |
5793
Rscript .ci/lint.R .ci/linters/po po '[.]po$'
5894
lint-md:
95+
needs: changes
96+
if: needs.changes.outputs.md == 'true' || github.event_name == 'workflow_dispatch'
5997
runs-on: ubuntu-latest
6098
steps:
6199
- uses: actions/checkout@v4
62100
- uses: r-lib/actions/setup-r@v2
63101
- name: Lint
64102
run: Rscript .ci/lint.R .ci/linters/md . '[.]R?md$'
65103
lint-rd:
104+
needs: changes
105+
if: needs.changes.outputs.rd == 'true' || github.event_name == 'workflow_dispatch'
66106
runs-on: ubuntu-latest
67107
steps:
68108
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)