Skip to content

Commit

Permalink
[docker] add docker images for local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joboog committed May 3, 2024
1 parent 3b5ab46 commit 91b41d7
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ci/ci_install.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM rocker/r-ver:4.2.3

ARG RENV_CONFIG_EXTERNAL_LIBRARIES="/usr/local/lib/R/library"
ARG RUN_PYTHON_CONFIG_TESTS=true
ENV RUN_PYTHON_CONFIG_TESTS=$RUN_PYTHON_CONFIG_TESTS

# before script
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git
# Required for building python and rhdf5
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git
RUN apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
libharfbuzz-dev libfribidi-dev libcurl4-openssl-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
RUN apt-get install -y python3.10-venv python3-pip

#RUN git clone --branch 90-add_fun_install_ogs https://gitlab.opengeosys.org/ogs/tools/r2ogs6.git /root/r2ogs6
COPY .. /root/r2ogs6
RUN rm /root/r2ogs6/.Renviron
RUN rm /root/r2ogs6/.Rprofile
RUN mkdir /root/test_r2ogs6
WORKDIR /root/test_r2ogs6

# script
RUN R -e 'install.packages(c("remotes", "BiocManager"))'
RUN R -e 'remotes::install_local(path="/root/r2ogs6", dependencies="Imports", repos=BiocManager::repositories())'
RUN R -e 'reticulate::virtualenv_create(envname="r2ogs6", python="/usr/bin/python3")'
RUN R -e 'r2ogs6::install_ogs(ogs_version = "6.4.4", envname = "r2ogs6")'


45 changes: 45 additions & 0 deletions ci/ci_test.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM rocker/r-ver:4.2.3


ARG RUN_PYTHON_CONFIG_TESTS=true
ENV RUN_PYTHON_CONFIG_TESTS=$RUN_PYTHON_CONFIG_TESTS

# Set RENV_CONFIG_EXTERNAL_LIBRARIES to consider to R system lib
ARG RENV_CONFIG_EXTERNAL_LIBRARIES="/usr/local/lib/R/library"
# Define renv lib
ARG RENV_PATHS_LIBRARY=/root/.cache/R/renv/library
ENV RENV_PATHS_LIBRARY=$RENV_PATHS_LIBRARY
ARG RENV_PATHS_CACHE=/root/.cache/R/renv/cache
ENV RENV_PATHS_CACHE=$RENV_PATHS_CACHE

# before script
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git
RUN apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev \
libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
libharfbuzz-dev libfribidi-dev libcurl4-openssl-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
RUN apt-get install -y python3.10-venv python3-pip

#RUN rm .Rprofile
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"
COPY .. /root/r2ogs6
RUN rm /root/r2ogs6/.Renviron
WORKDIR /root/r2ogs6
RUN ls -ahl .
RUN echo $R_LIBS
RUN R -e "renv::restore()"

ENV R_LIBS=/usr/local/lib/R/site-library:/usr/local/lib/R/library:$RENV_PATHS_LIBRARY

# # script
RUN R -e "devtools::test()"
RUN R -e "devtools::check(vignettes=F)"
# using of devtools as R CMD could not access renv library, dunno why
# RUN R CMD build . --no-manual --no-build-vignettes
# RUN R CMD check $(ls -1t *.tar.gz | head -n 1) --no-manual --no-build-vignettes

# # after script
RUN R -e 'renv::install("covr")'
RUN R -e 'covr::package_coverage(type = c("tests", "examples"), quiet = F)'

0 comments on commit 91b41d7

Please sign in to comment.