-
Notifications
You must be signed in to change notification settings - Fork 13
151 lines (125 loc) · 5.5 KB
/
r-renv-lock.yml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
on:
pull_request:
branches:
- main
paths:
- .github/workflows/r-renv-lock.yml
- DESCRIPTION
name: Generate renv.lock
concurrency:
group: r-renv-lock-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
r-renv-lock-gen:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
max-parallel: 1
fail-fast: false
matrix:
config:
- {os: ubuntu-20.04, r: '4.1', repos: 'https://packagemanager.posit.co/cran/2022-03-10/'}
- {os: ubuntu-20.04, r: '4.2', repos: 'https://packagemanager.posit.co/cran/2023-03-15/'}
- {os: ubuntu-20.04, r: '4.3', repos: 'https://packagemanager.posit.co/cran/2023-04-20/'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: true
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
R_CRAN_REPO: ${{ matrix.config.repos }}
RENV_PROFILE_NAME: ${{ matrix.config.r }}
R_RELEASE_LAGACY: ${{ matrix.config.legacy || false }}
steps:
- name: Get branch names
id: branch-name
uses: tj-actions/[email protected]
- name: Checkout repo (PR) 🛎
uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- name: Install system dependencies
run: sudo apt update && sudo apt install libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev libgit2-dev -y
- name: Collect dependencies
run: |
Sys.setenv("RENV_CONFIG_SANDBOX_ENABLED" = FALSE)
Sys.setenv("RENV_CONFIG_AUTO_SNAPSHOT" = FALSE)
source("renv/activate.R")
lock_gen_version <- "0.1.0"
legacy <- identical(Sys.getenv("R_RELEASE_LAGACY"), "true")
renv_profile <- Sys.getenv("RENV_PROFILE_NAME", "dev")
if (legacy) renv_profile <- paste0(renv_profile, "_legacy")
cran_r_release <- Sys.getenv("R_CRAN_REPO", "https://packagemanager.posit.co/cran/2023-03-15/")
cran_latest <- Sys.getenv("CRAN_R_LATEST", "https://packagemanager.posit.co/cran/latest")
unlink(file.path("renv", "profiles", renv_profile), recursive = TRUE)
cat("\n==================================\n")
cat("Create renv.lock files\n")
cat(paste("renv_profile: \"", renv_profile, "\"\n", sep = ""))
cat(paste("cran_r_release: \"", cran_r_release, "\"\n", sep = ""))
cat(paste("cran_latest: \"", cran_latest, "\"\n", sep = ""))
cat("==================================\n")
renv::activate(profile = renv_profile)
renv::settings$snapshot.type("custom")
.get_dependencies <- function(project_dir) {
dependencies <- renv::dependencies("DESCRIPTION", dev = TRUE)$Package
c(
project_dir,
dependencies
) |>
unique() |>
renv:::renv_package_dependencies() |>
names()
}
options(renv.snapshot.filter = .get_dependencies)
# CRAN repo from R release
options("repos" = c("RSPM" = cran_r_release))
renv::install("openpharma/staged.dependencies", repos = options("repos"))
renv::install("devtools", repos = options("repos"))
# Packages from stage dependencies to ignore
renv::settings$ignored.packages(c("admiraldev"))
# Install dependencies
renv::settings$snapshot.type("explicit")
renv::install(repos = options("repos"))
# Set newest CRAN for few packages upgrade
options("repos" = c(
"CRAN" = cran_latest,
"RSPM" = cran_r_release
))
# Install latest remotes version
renv::install("remotes", repos = cran_latest)
install_min_version <- function(pkg, version) {
upgrade <- try(packageVersion(pkg) >= version, silent = TRUE)
if (!isTRUE(upgrade)) {
message("Upgrade `", pkg, "` to `", version, "`")
renv::install(paste0(pkg, "@", version), dependencies = "none")
}
}
renv::install("R.cache", dependencies = "Imports")
install_min_version("vctrs", "0.4.1")
renv::install("[email protected]", dependencies = "none")
renv::install("[email protected]", dependencies = "none")
renv::settings$snapshot.type("custom")
renv::snapshot(force = TRUE, prompt = FALSE)
renv::record("[email protected]")
renv::record("devtools")
renv::record("[email protected]")
renv::record("openpharma/staged.dependencies")
if (identical(renv_profile, "4.3")) {
file.copy(renv::paths$lockfile(), "renv.lock", overwrite = TRUE)
}
shell: Rscript --vanilla {0}
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automatic renv profile update.
file_pattern: 'renv.lock renv/profiles/*'
commit_user_name: pharmaverse-bot
commit_user_email: [email protected]
create_branch: true