Skip to content

Commit 159acfa

Browse files
authored
Reusable workflow to avoid code duplication (#12)
1 parent 7e8146e commit 159acfa

File tree

2 files changed

+71
-53
lines changed

2 files changed

+71
-53
lines changed

.github/workflows/R-helloworld.yml

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,10 @@ on:
1010

1111
name: Build and check R bican.mccarroll.helloworld package
1212

13-
permissions: read-all
1413

1514
jobs:
16-
R-CMD-check:
17-
runs-on: ${{ matrix.config.os }}
18-
19-
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
20-
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
config:
25-
# The vignette requires X11, but I wasn't able to get X11 in the MacOS config, so disable for now.
26-
#- {os: macos-latest, r: 'release'}
27-
# doesn't work because we use gunzip
28-
#- {os: windows-latest, r: 'release'}
29-
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
30-
- {os: ubuntu-latest, r: 'release'}
31-
32-
env:
33-
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
34-
R_KEEP_PKG_SOURCE: yes
35-
36-
steps:
37-
- uses: actions/checkout@v4
38-
39-
# ChatGPT suggested the following macOS steps to address libXrender.1.dylib not found
40-
#- name: Install XQuartz (macOS only)
41-
# if: runner.os == 'macOS'
42-
# run: brew install --cask xquartz
43-
44-
#- name: Set Library Path (macOS only)
45-
# if: runner.os == 'macOS'
46-
# run: echo "DYLD_LIBRARY_PATH=/opt/X11/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
47-
48-
- uses: r-lib/actions/setup-pandoc@v2
49-
50-
- uses: r-lib/actions/setup-r@v2
51-
with:
52-
r-version: ${{ matrix.config.r }}
53-
http-user-agent: ${{ matrix.config.http-user-agent }}
54-
use-public-rspm: true
55-
56-
- uses: r-lib/actions/setup-r-dependencies@v2
57-
with:
58-
working-directory: R/bican.mccarroll.helloworld
59-
extra-packages: any::rcmdcheck,testthat
60-
needs: check
61-
dependencies: '"hard"'
62-
63-
- uses: r-lib/actions/check-r-package@v2
64-
with:
65-
working-directory: R/bican.mccarroll.helloworld
66-
upload-snapshots: true
67-
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
15+
call-R-reusable:
16+
uses: ./.github/workflows/R-reusable.yml
17+
with:
18+
package_name: bican.mccarroll.helloworld
19+
secrets: inherit

.github/workflows/R-reusable.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
workflow_call:
5+
inputs:
6+
package_name:
7+
required: true
8+
type: string
9+
10+
name: Build and check an R package
11+
12+
permissions: read-all
13+
14+
jobs:
15+
R-CMD-check:
16+
runs-on: ${{ matrix.config.os }}
17+
18+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
config:
24+
# The vignette requires X11, but I wasn't able to get X11 in the MacOS config, so disable for now.
25+
#- {os: macos-latest, r: 'release'}
26+
# doesn't work because we use gunzip
27+
#- {os: windows-latest, r: 'release'}
28+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
29+
- {os: ubuntu-latest, r: 'release'}
30+
31+
env:
32+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
33+
R_KEEP_PKG_SOURCE: yes
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
# ChatGPT suggested the following macOS steps to address libXrender.1.dylib not found
39+
#- name: Install XQuartz (macOS only)
40+
# if: runner.os == 'macOS'
41+
# run: brew install --cask xquartz
42+
43+
#- name: Set Library Path (macOS only)
44+
# if: runner.os == 'macOS'
45+
# run: echo "DYLD_LIBRARY_PATH=/opt/X11/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
46+
47+
- uses: r-lib/actions/setup-pandoc@v2
48+
49+
- uses: r-lib/actions/setup-r@v2
50+
with:
51+
r-version: ${{ matrix.config.r }}
52+
http-user-agent: ${{ matrix.config.http-user-agent }}
53+
use-public-rspm: true
54+
55+
- uses: r-lib/actions/setup-r-dependencies@v2
56+
with:
57+
working-directory: R/${{ inputs.package_name }}
58+
extra-packages: any::rcmdcheck,testthat
59+
needs: check
60+
dependencies: '"hard"'
61+
62+
- uses: r-lib/actions/check-r-package@v2
63+
with:
64+
working-directory: R/${{ inputs.package_name }}
65+
upload-snapshots: true
66+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

0 commit comments

Comments
 (0)