Skip to content

Commit f142bb5

Browse files
ci(docker): check all pkgs installed
1 parent 83520d9 commit f142bb5

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,43 @@ RUN R -e "devtools::install_local('/opt2/SCWorkflow', dependencies = TRUE, upgra
119119
COPY Dockerfile /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
120120
RUN chmod a+r /opt2/Dockerfile_${REPONAME}.${BUILD_TAG}
121121

122+
# Verify all dependencies from DESCRIPTION are installed
123+
RUN cat > /tmp/check_description_deps.R << 'EOF'
124+
# Parse DESCRIPTION file and check if all dependencies are installed
125+
desc_file <- "/opt2/SCWorkflow/DESCRIPTION"
126+
if (!file.exists(desc_file)) {
127+
stop("DESCRIPTION file not found at ", desc_file)
128+
}
129+
# Read and parse DESCRIPTION
130+
desc <- read.dcf(desc_file)
131+
# Extract dependencies
132+
extract_packages <- function(str) {
133+
if (is.na(str) || str == "") return(character(0))
134+
# Split by comma and clean up whitespace and version specs
135+
pkgs <- strsplit(str, ",")[[1]]
136+
pkgs <- trimws(pkgs)
137+
pkgs <- gsub("\\s*\\(.*\\)$", "", pkgs) # Remove version specs
138+
pkgs <- pkgs[pkgs != ""]
139+
pkgs
140+
}
141+
deps <- unique(c(
142+
extract_packages(desc[1, "Depends"]),
143+
extract_packages(desc[1, "Imports"]),
144+
extract_packages(desc[1, "Suggests"]),
145+
extract_packages(desc[1, "Config/Needs/dev"])
146+
))
147+
# Remove base R
148+
deps <- deps[!grepl("^R$", deps)]
149+
# Check if each dependency is installed
150+
missing <- deps[!vapply(deps, requireNamespace, quietly = TRUE, FUN.VALUE = logical(1))]
151+
if (length(missing) > 0) {
152+
stop("The following dependencies are missing: ", paste(missing, collapse = ", "))
153+
} else {
154+
message("All dependencies are installed.")
155+
}
156+
EOF
157+
RUN R --vanilla --slave --file=/tmp/check_description_deps.R
158+
122159
# cleanup
123160
WORKDIR /data2
124161
RUN apt-get clean && apt-get purge \

0 commit comments

Comments
 (0)