Skip to content

Commit c0cef50

Browse files
ci: use pinned package versions via pak
1 parent 59022af commit c0cef50

File tree

6 files changed

+90
-7
lines changed

6 files changed

+90
-7
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Install R + pak
2+
description: |
3+
Install R and dependencies with pak
4+
inputs:
5+
r-version:
6+
description: "The version of R to install"
7+
default: "release"
8+
http-user-agent:
9+
default: ""
10+
use-public-rspm:
11+
default: true
12+
versions-file:
13+
default: ""
14+
description: "File with content to pass to the extra-packages argument of setup-r-dependencies"
15+
extra-packages:
16+
default: ""
17+
description: "More packages to install in addition to those specified in versions-file"
18+
needs:
19+
default: ""
20+
description: "Config/Needs field from DESCRIPTION to pass along to setup-r-dependencies"
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- uses: r-lib/actions/setup-pandoc@v2
26+
27+
- uses: r-lib/actions/setup-r@v2
28+
with:
29+
r-version: ${{ inputs.r-version }}
30+
http-user-agent: ${{ inputs.http-user-agent }}
31+
use-public-rspm: ${{ inputs.use-public-rspm }}
32+
33+
34+
- name: Set package versions
35+
shell: bash
36+
run: |
37+
# get package versions from file
38+
if [ -f ${{ inputs.versions-file }} ]; then
39+
PKG_VERSIONS=$(cat ${{ inputs.versions-file }})
40+
fi
41+
42+
# get additional package versions from input
43+
if [ "${{ inputs.extra-packages }}" ]; then
44+
if [ "$PKG_VERSIONS" ]; then
45+
PKG_VERSIONS="${PKG_VERSIONS}, ${{ inputs.extra-packages }}"
46+
else
47+
PKG_VERSIONS="${{ inputs.extra-packages }}"
48+
fi
49+
fi
50+
51+
echo "PKG_VERSIONS=${PKG_VERSIONS}" >> "$GITHUB_ENV"
52+
53+
- uses: r-lib/actions/setup-r-dependencies@v2
54+
with:
55+
extra-packages: "${{ env.PKG_VERSIONS }}"
56+
needs: ${{ inputs.needs }}

.github/install-pak.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env Rscript --vanilla
2+
# Usage:
3+
# Rscript .github/install-pak.R [path/to/versions_file]
4+
5+
clargs <- commandArgs(trailingOnly = TRUE)
6+
versions_file <- if (!is.na(clargs[1])) {
7+
clargs[1]
8+
} else{
9+
'.github/package-versions.txt'
10+
}
11+
message(cat("versions_file:", versions_file, "\n"))
12+
13+
if (!require('pak', quietly = TRUE)) {
14+
install.packages('pak', repos = 'https://packagemanager.posit.co/cran/latest')
15+
}
16+
17+
18+
pkgs <- strsplit(readChar(versions_file, file.info(versions_file)$size) |> trimws(),
19+
"[[:space:],]+")[[1]]
20+
21+
pak::pkg_install(c(pkgs, "deps::.", "local::."),
22+
upgrade = FALSE,
23+
dependencies = "all")

.github/package-versions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

.github/workflows/pkgdown.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333
use-public-rspm: true
3434
r-version: 4.3
3535

36-
- uses: r-lib/actions/setup-r-dependencies@v2
36+
- uses: ./.github/actions/install-r-pak
3737
with:
38-
extra-packages: any::pkgdown, local::.
39-
needs: website
38+
versions-file: .github/package-versions.txt
39+
extra-packages: local::.
40+
needs: dev
4041

4142
- name: Build site
4243
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Imports:
4949
gdata,
5050
ggExtra,
5151
ggplot2 (>= 3.3.6),
52+
ggplot2 (< 4.0.0),
5253
ggpubr (>= 0.4.0),
5354
ggrepel,
5455
globals (>= 0.16.1),
@@ -67,7 +68,7 @@ Imports:
6768
magrittr (>= 2.0.3),
6869
markdown (>= 1.1),
6970
MAST (>= 1.20.0),
70-
Matrix (== 1.6.1),
71+
Matrix (>= 1.6.1),
7172
methods (>= 4.1.3),
7273
pheatmap,
7374
plotly (>= 4.10.0),
@@ -100,6 +101,7 @@ Suggests:
100101
rmarkdown,
101102
testthat (>= 3.0.0)
102103
biocViews:
104+
Config/Needs/dev: pkgdown, rcmdcheck
103105
Config/testthat/edition: 3
104106
Encoding: UTF-8
105107
Roxygen: list(markdown = TRUE)

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ RUN apt-get update && apt-get upgrade -y && \
123123

124124
# install R package
125125
COPY . /opt2/SCWorkflow
126-
RUN R -e 'remotes::install_version("Seurat", version="4.3.0", upgrade="never"); remotes::install_version("SeuratObject", version="4.1.3", upgrade="never"); remotes::install_version("Matrix", version="1.6.1", upgrade="never")' && \
127-
R -e "remotes::install_local('/opt2/SCWorkflow', dependencies = TRUE, upgrade='never', repos='http://cran.rstudio.com'); library(SCWorkflow)" && \
128-
R -s -e "readr::write_tsv(tibble::as_tibble(installed.packages()), '/mnt/r-packages.tsv')"
126+
RUN Rscript /opt2/SCWorkflow/.github/install-pak.R /opt2/SCWorkflow/.github/package-versions.txt && \
127+
R -e "library(SCWorkflow)" && \
128+
R -s -e "readr::write_tsv(tibble::as_tibble(installed.packages()), '/mnt/r-packages.tsv')"
129129

130130
# add scworkflow exec to the path
131131
RUN chmod -R +x /usr/local/lib/R/site-library/SCWorkflow/exec

0 commit comments

Comments
 (0)