mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 19:26:13 +01:00
gitlab pkg cache
This commit is contained in:
parent
ee76afede5
commit
b48e609afe
@ -1,5 +1,7 @@
|
|||||||
^.*\.Rproj$
|
^.*\.Rproj$
|
||||||
^\.gitlab-ci\.yml$
|
^\.gitlab-ci\.yml$
|
||||||
|
^\.gitlab-ci\.R$
|
||||||
|
^\.Renviron$
|
||||||
^\.Rprofile$
|
^\.Rprofile$
|
||||||
^\.Rproj\.user$
|
^\.Rproj\.user$
|
||||||
^\.travis\.yml$
|
^\.travis\.yml$
|
||||||
@ -7,7 +9,6 @@
|
|||||||
^_noinclude$
|
^_noinclude$
|
||||||
^_pkgdown\.yml$
|
^_pkgdown\.yml$
|
||||||
^appveyor\.yml$
|
^appveyor\.yml$
|
||||||
^ci.R$
|
|
||||||
^cran-comments\.md$
|
^cran-comments\.md$
|
||||||
^CRAN-RELEASE$
|
^CRAN-RELEASE$
|
||||||
^doc$
|
^doc$
|
||||||
@ -17,6 +18,5 @@
|
|||||||
^index\.md$
|
^index\.md$
|
||||||
^installed_deps$
|
^installed_deps$
|
||||||
^Meta$
|
^Meta$
|
||||||
^packrat/
|
|
||||||
^pkgdown$
|
^pkgdown$
|
||||||
^public$
|
^public$
|
||||||
|
56
.gitlab-ci.R
Normal file
56
.gitlab-ci.R
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# ==================================================================== #
|
||||||
|
# TITLE #
|
||||||
|
# Antimicrobial Resistance (AMR) Analysis #
|
||||||
|
# #
|
||||||
|
# AUTHORS #
|
||||||
|
# Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
|
||||||
|
# #
|
||||||
|
# LICENCE #
|
||||||
|
# This package is free software; you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License version 2.0, #
|
||||||
|
# as published by the Free Software Foundation. #
|
||||||
|
# #
|
||||||
|
# This R package is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License version 2.0 for more details. #
|
||||||
|
# ==================================================================== #
|
||||||
|
|
||||||
|
install_if_needed <- function(pkg, repos, quiet) {
|
||||||
|
package_path <- find.package(pkg, quiet = quiet)
|
||||||
|
if (length(package_path) == 0) {
|
||||||
|
message("NOTE: pkg ", pkg, " missing, installing...")
|
||||||
|
install.packages(pkg, repos = repos, quiet = quiet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_update_pkg_all <- function(repos = "https://cran.rstudio.com",
|
||||||
|
quiet = TRUE,
|
||||||
|
install_pkgdown = FALSE) {
|
||||||
|
# update existing
|
||||||
|
update.packages(ask = FALSE, repos = repos, quiet = quiet)
|
||||||
|
|
||||||
|
install_if_needed(pkg = "devtools", repos = repos, quiet = quiet)
|
||||||
|
if (install_pkgdown = TRUE) {
|
||||||
|
install_if_needed(pkg = "pkgdown", repos = repos, quiet = quiet)
|
||||||
|
}
|
||||||
|
|
||||||
|
devtools::install_dev_deps(repos = repos, quiet = quiet, upgrade = TRUE)
|
||||||
|
|
||||||
|
cat("\nINSTALLED:\n\n")
|
||||||
|
instld <- as.data.frame(installed.packages())
|
||||||
|
rownames(instld) <- NULL
|
||||||
|
print(instld[, c("Package", "Version")])
|
||||||
|
|
||||||
|
return(invisible(TRUE))
|
||||||
|
|
||||||
|
# which ones are needed now?
|
||||||
|
# pkg_needed <-
|
||||||
|
|
||||||
|
# if (length(pkg_needed) > 0) {
|
||||||
|
# # install them
|
||||||
|
# for (i %in% 1:length(pkg_needed)) {
|
||||||
|
# install_if_needed(pkg = pkg_needed[i], repos = repos, quiet = quiet)
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
}
|
@ -29,16 +29,23 @@ stages:
|
|||||||
- test
|
- test
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
image: debian:buster-slim
|
image: debian:stretch-slim
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
# install dependencies for package
|
# install dependencies for packages
|
||||||
- apt-get -y install libxml2-dev libssl-dev libcurl4-openssl-dev zlib1g-dev pandoc r-base
|
- apt-get -y install libxml2-dev libssl-dev libcurl4-openssl-dev zlib1g-dev pandoc r-base
|
||||||
- mkdir installed_deps
|
# cache R packages
|
||||||
- Rscript -e '.libPaths("installed_deps")'
|
- mkdir -p installed_deps
|
||||||
- Rscript -e 'install.packages(c("devtools", "rlang"), repos = "https://cran.rstudio.com")'
|
- echo 'R_LIBS="installed_deps"' > .Renviron
|
||||||
- Rscript -e 'devtools::install_dev_deps(repos = "https://cran.rstudio.com")'
|
- echo 'R_LIBS_USER="installed_deps"' >> .Renviron
|
||||||
|
- echo 'R_LIBS_SITE="installed_deps"' >> .Renviron
|
||||||
|
- Rscript -e '.libPaths()'
|
||||||
|
# install missing and outdated packages
|
||||||
|
- Rscript -e 'source(".gitlab-ci.R")'
|
||||||
|
- Rscript -e 'gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE)'
|
||||||
|
#- Rscript -e 'install.packages(c("devtools", "rlang"), repos = "https://cran.rstudio.com", quiet = TRUE)'
|
||||||
|
#- Rscript -e 'devtools::install_dev_deps(repos = "https://cran.rstudio.com", quiet = TRUE)'
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
key: "$CI_COMMIT_REF_SLUG"
|
key: "$CI_COMMIT_REF_SLUG"
|
||||||
@ -50,8 +57,8 @@ R 3:
|
|||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
# remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file
|
# remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file
|
||||||
- rm -rf vignettes
|
#- rm -rf vignettes
|
||||||
- Rscript -e 'd <- read.dcf("DESCRIPTION"); d[, colnames(d) == "VignetteBuilder"] <- NA; write.dcf(d, "DESCRIPTION")'
|
#- Rscript -e 'd <- read.dcf("DESCRIPTION"); d[, colnames(d) == "VignetteBuilder"] <- NA; write.dcf(d, "DESCRIPTION")'
|
||||||
# build package
|
# build package
|
||||||
- R CMD build . --no-build-vignettes --no-manual
|
- R CMD build . --no-build-vignettes --no-manual
|
||||||
- PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)
|
- PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)
|
||||||
@ -79,7 +86,7 @@ pages:
|
|||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
script:
|
script:
|
||||||
- Rscript -e "install.packages('pkgdown', repos = 'https://cran.rstudio.com')"
|
#- Rscript -e "install.packages('pkgdown', repos = 'https://cran.rstudio.com')"
|
||||||
- Rscript -e "devtools::install(build = TRUE, upgrade = FALSE)"
|
- Rscript -e "devtools::install(build = TRUE, upgrade = FALSE)"
|
||||||
- R -e "pkgdown::build_site(examples = FALSE, override = list(destination = 'public'))"
|
- R -e "pkgdown::build_site(examples = FALSE, override = list(destination = 'public'))"
|
||||||
artifacts:
|
artifacts:
|
||||||
|
Loading…
Reference in New Issue
Block a user