Skip to content

Commit 730904b

Browse files
committed
Run checks on update_datasets change, but report success early.
1 parent ee2abfd commit 730904b

File tree

3 files changed

+79
-20
lines changed

3 files changed

+79
-20
lines changed

.github/workflows/check-standard.yaml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
on:
44
push:
55
branches: [main]
6-
paths-ignore:
7-
- .github/workflows/update_datasets.yaml
86
pull_request:
97
branches: [main]
10-
paths-ignore:
11-
- .github/workflows/update_datasets.yaml
128

139
name: R-CMD-check
1410

1511
jobs:
12+
check-files:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Check if only workflow file has changed
17+
id: file-check
18+
run: |
19+
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
20+
echo "other-files-changed=true" >> $GITHUB_ENV
21+
else
22+
echo "other-files-changed=false" >> $GITHUB_ENV
23+
fi
24+
1625
R-CMD-check:
26+
needs: check-files
1727
runs-on: ${{ matrix.config.os }}
1828

1929
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
@@ -33,21 +43,30 @@ jobs:
3343
R_KEEP_PKG_SOURCE: yes
3444

3545
steps:
46+
- name: Skip workflow if only workflow file has changed
47+
if: env.other-files-changed == 'false'
48+
run: echo "Only workflow file has changed. Reporting success."
49+
3650
- uses: actions/checkout@v4
51+
if: env.other-files-changed == 'true'
3752

3853
- uses: r-lib/actions/setup-pandoc@v2
54+
if: env.other-files-changed == 'true'
3955

4056
- uses: r-lib/actions/setup-r@v2
57+
if: env.other-files-changed == 'true'
4158
with:
4259
r-version: ${{ matrix.config.r }}
4360
http-user-agent: ${{ matrix.config.http-user-agent }}
4461
use-public-rspm: true
4562

4663
- uses: r-lib/actions/setup-r-dependencies@v2
64+
if: env.other-files-changed == 'true'
4765
with:
4866
extra-packages: any::rcmdcheck
4967
needs: check
5068

5169
- uses: r-lib/actions/check-r-package@v2
70+
if: env.other-files-changed == 'true'
5271
with:
5372
upload-snapshots: true

.github/workflows/pkgdown.yaml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@
33
on:
44
push:
55
branches: [main]
6-
paths-ignore:
7-
- .github/workflows/update_datasets.yaml
86
pull_request:
97
branches: [main]
10-
paths-ignore:
11-
- .github/workflows/update_datasets.yaml
128
release:
139
types: [published]
1410
workflow_dispatch:
1511

1612
name: pkgdown
1713

1814
jobs:
15+
check-files:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Check if only workflow file has changed
20+
id: file-check
21+
run: |
22+
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
23+
echo "other-files-changed=true" >> $GITHUB_ENV
24+
else
25+
echo "other-files-changed=false" >> $GITHUB_ENV
26+
fi
27+
1928
pkgdown:
29+
needs: check-files
2030
runs-on: ubuntu-latest
2131
# Only restrict concurrency for non-PR jobs
2232
concurrency:
@@ -26,25 +36,38 @@ jobs:
2636
permissions:
2737
contents: write
2838
steps:
29-
- uses: actions/checkout@v4
39+
- name: Skip workflow if only workflow file has changed
40+
if: env.other-files-changed == 'false'
41+
run: echo "Only workflow file has changed. Reporting success."
42+
43+
- name: Checkout code
44+
if: env.other-files-changed == 'true'
45+
uses: actions/checkout@v4
3046

31-
- uses: r-lib/actions/setup-pandoc@v2
47+
- name: Setup Pandoc
48+
if: env.other-files-changed == 'true'
49+
uses: r-lib/actions/setup-pandoc@v2
3250

33-
- uses: r-lib/actions/setup-r@v2
51+
- name: Setup R
52+
if: env.other-files-changed == 'true'
53+
uses: r-lib/actions/setup-r@v2
3454
with:
3555
use-public-rspm: true
3656

37-
- uses: r-lib/actions/setup-r-dependencies@v2
57+
- name: Setup R dependencies
58+
if: env.other-files-changed == 'true'
59+
uses: r-lib/actions/setup-r-dependencies@v2
3860
with:
3961
extra-packages: any::pkgdown, local::.
4062
needs: website
4163

4264
- name: Build site
65+
if: env.other-files-changed == 'true'
4366
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
4467
shell: Rscript {0}
4568

4669
- name: Deploy to GitHub pages 🚀
47-
if: github.event_name != 'pull_request'
70+
if: env.other-files-changed == 'true' && github.event_name != 'pull_request'
4871
uses: JamesIves/[email protected]
4972
with:
5073
clean: false

.github/workflows/test-coverage.yaml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,52 @@
33
on:
44
push:
55
branches: [main]
6-
paths-ignore:
7-
- .github/workflows/update_datasets.yaml
86
pull_request:
97
branches: [main]
10-
paths-ignore:
11-
- .github/workflows/update_datasets.yaml
128
workflow_dispatch:
139

1410
name: test-coverage
1511

1612
jobs:
13+
check-files:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Check if only workflow file has changed
18+
id: file-check
19+
run: |
20+
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
21+
echo "other-files-changed=true" >> $GITHUB_ENV
22+
else
23+
echo "other-files-changed=false" >> $GITHUB_ENV
24+
fi
25+
1726
test-coverage:
27+
needs: check-files
1828
runs-on: ubuntu-latest
1929
env:
2030
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21-
2231
steps:
32+
- name: Skip workflow if only workflow file has changed
33+
if: env.other-files-changed == 'false'
34+
run: echo "Only workflow file has changed. Reporting success."
35+
2336
- uses: actions/checkout@v4
37+
if: env.other-files-changed == 'true'
2438

2539
- uses: r-lib/actions/setup-r@v2
40+
if: env.other-files-changed == 'true'
2641
with:
2742
use-public-rspm: true
2843

2944
- uses: r-lib/actions/setup-r-dependencies@v2
45+
if: env.other-files-changed == 'true'
3046
with:
3147
extra-packages: any::covr
3248
needs: coverage
3349

3450
- name: Test coverage
51+
if: env.other-files-changed == 'true'
3552
run: |
3653
covr::codecov(
3754
quiet = FALSE,
@@ -41,14 +58,14 @@ jobs:
4158
shell: Rscript {0}
4259

4360
- name: Show testthat output
44-
if: always()
61+
if: always() && env.other-files-changed == 'true'
4562
run: |
4663
## --------------------------------------------------------------------
4764
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
4865
shell: bash
4966

5067
- name: Upload test results
51-
if: failure()
68+
if: failure() && env.other-files-changed == 'true'
5269
uses: actions/upload-artifact@v4
5370
with:
5471
name: coverage-test-failures

0 commit comments

Comments
 (0)