forked from user-workshop-cicd/r.package.example
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (119 loc) Β· 4.52 KB
/
simple.yaml
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
name: Simple workflow
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
push:
branches:
- main
env:
# additional flags for `R CMD CHECK`
EXTRA_CHECK_FLAGS: "--no-manual --no-vignettes"
# additional environmental vars for `R CMD CHECK`
# see manual here: https://rstudio.github.io/r-manuals/r-ints/Tools.html
_R_CHECK_TESTS_NLINES_: 0
_R_CHECK_VIGNETTES_NLINES_: 0
jobs:
# First job.
hello-world-from-r:
name: Hello, world!
runs-on: ubuntu-latest
steps:
- name: Setup R π§
uses: r-lib/actions/setup-r@v2
- name: Hello world! π¬
run: cat(paste0("Hello ", Sys.getenv("NAME"), "! π"))
shell: Rscript {0}
env:
NAME: "mattkorb"
# Second job - by default jobs will run in parallel, unless some dependencies
# are introduced between them.
build-and-check:
name: Build R package
runs-on: ubuntu-latest
steps:
- name: Checkout repo π
# We're using an official GitHub Action.
uses: actions/[email protected]
with:
# Action inputs (arguments/parameters).
# In this case we clone the repository to the directory called the same
# as the repository name.
path: ${{ github.event.repository.name }}
- name: Setup R π§
if: true
# We're using a third-party GitHub Action.
uses: r-lib/actions/setup-r@v2
- name: Hello from R! π¬
run: cat("Hello from R! π")
shell: Rscript {0}
- name: Setup R dependencies π§
# We're using a third-party GitHub Action.
uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: ${{ github.event.repository.name }}
- name: Installed packages π¦
run: rownames(installed.packages())
shell: Rscript {0}
# Get package name and version from DESCRIPTION so that we'll know
# what's the name of the tar.gz file with the built package.
# pkgbuild is set as an output which can be accessed by subsequent steps.
- name: Get package name π¦
id: package-name
run: |
PKGBUILD="$(Rscript -e 'cat(sprintf("%s_%s.tar.gz",(dcf <- read.dcf("DESCRIPTION"))[,"Package"], dcf[,"Version"]))')"
echo "PKGBUILD = $PKGBUILD"
echo "pkgbuild=$PKGBUILD" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{ github.event.repository.name }}
# Build a package stored in a directory called ${{ github.event.repository.name }}
# --no-manual --no-build-vignettes because this requires LaTeX.
- name: Build R package π
run: |
R CMD build --no-manual --no-build-vignettes ${{ github.event.repository.name }}
ls -l
shell: bash
# Check `.tar.gz` package built in previous step.
# --no-manual --no-vignettes because this requires LaTeX.
- name: Check R package π
run: |
env | grep -E '^_R'
echo "Let's run R CMD check..."
R CMD check ${EXTRA_CHECK_FLAGS} ${{ steps.package-name.outputs.pkgbuild }}
shell: bash
- name: Upload logs artifact ποΈ
uses: actions/upload-artifact@v4
with:
path: |
${{ github.event.repository.name }}.Rcheck/*00install.out
${{ github.event.repository.name }}.Rcheck/*00check.log
${{ github.event.repository.name }}.Rcheck/*00build.out
${{ github.event.repository.name }}.Rcheck/*-Ex.Rout
${{ github.event.repository.name }}.Rcheck/tests/testthat.Rout
${{ github.event.repository.name }}.Rcheck/tests/testthat.Rout.fail
name: check-logs-${{ github.event.repository.name }}
- name: Get `.tar.gz` file name
id: tar-gz
# Use our custom action.
uses: user-workshop-cicd/action-example@main
with:
filename-beginning: ${{ github.event.repository.name }}
# Upload `.tar.gz` package as an artifact so it can be downloaded.
- name: Upload package build ‴
uses: actions/upload-artifact@v4
with:
# Output of the custom action from the previous step
# are inputs of this action.
path: ${{ steps.tar-gz.outputs.full-filename }}
name: ${{ steps.tar-gz.outputs.full-filename }}
call-reusable-workflow:
name: Reusable workflow β»οΈ
uses: user-workshop-cicd/r.pkg.template/.github/workflows/sample-reusable-workflow.yaml@main
with:
name: mattkorb