mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 13:41:19 -05:00
fix: fail if r package installation fails (#4994)
- Fail if the installation of a R package fails. - Install the remotes package once during the image build, and not when we scan files at runtime. - Reuse the default R library directory instead of moving it to /home/r-library
This commit is contained in:
parent
a2cf1807a7
commit
60983d395f
5 changed files with 15 additions and 10 deletions
|
@ -219,8 +219,8 @@ RUN --mount=type=secret,id=GITHUB_TOKEN /install-glibc.sh && rm -rf /install-gli
|
|||
#################
|
||||
# Install Lintr #
|
||||
#################
|
||||
COPY scripts/install-lintr.sh /
|
||||
RUN /install-lintr.sh && rm -rf /install-lintr.sh
|
||||
COPY scripts/install-lintr.sh scripts/install-r-package-or-fail.R /
|
||||
RUN /install-lintr.sh && rm -rf /install-lintr.sh /install-r-package-or-fail.R
|
||||
|
||||
#################################
|
||||
# Install luacheck and luarocks #
|
||||
|
|
|
@ -479,7 +479,6 @@ function RunAdditionalInstalls() {
|
|||
##############################
|
||||
INSTALL_CMD=$(
|
||||
cd "${WORKSPACE_PATH}" || exit 0
|
||||
R -e "install.packages('remotes', repos = 'https://cloud.r-project.org/')" 2>&1
|
||||
R -e "remotes::install_local('.', dependencies=T)" 2>&1
|
||||
)
|
||||
|
||||
|
|
|
@ -2,8 +2,4 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p /home/r-library
|
||||
cp -r /usr/lib/R/library/ /home/r-library/
|
||||
Rscript -e "install.packages(c('lintr','purrr'), repos = 'https://cloud.r-project.org/')"
|
||||
R -e "install.packages(list.dirs('/home/r-library',recursive = FALSE), repos = NULL, type = 'source')"
|
||||
mv /etc/R/* /usr/lib/R/etc/
|
||||
Rscript --no-save /install-r-package-or-fail.R lintr purrr remotes
|
||||
|
|
12
scripts/install-r-package-or-fail.R
Executable file
12
scripts/install-r-package-or-fail.R
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env Rscript
|
||||
|
||||
# Based on: https://stackoverflow.com/questions/26244530/how-do-i-make-install-packages-return-an-error-if-an-r-package-cannot-be-install
|
||||
|
||||
packages = commandArgs(trailingOnly=TRUE)
|
||||
|
||||
for (l in packages) {
|
||||
install.packages(l, repos='https://cloud.r-project.org/');
|
||||
if ( ! library(l, character.only=TRUE, logical.return=TRUE) ) {
|
||||
quit(status=1, save='no')
|
||||
}
|
||||
}
|
|
@ -402,7 +402,6 @@ control "super-linter-validate-directories" do
|
|||
desc "Check that directories that Super-Linter needs are installed."
|
||||
|
||||
dirs = [
|
||||
"/home/r-library",
|
||||
"/node_modules",
|
||||
"/action/lib",
|
||||
"/action/lib/functions",
|
||||
|
@ -413,7 +412,6 @@ control "super-linter-validate-directories" do
|
|||
|
||||
# Removed linters from slim image
|
||||
SLIM_IMAGE_REMOVED_DIRS=%w(
|
||||
/home/r-library
|
||||
)
|
||||
|
||||
dirs.each do |item|
|
||||
|
|
Loading…
Reference in a new issue