Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.36 KiB
Newer Older
# helpful Links:
# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
# https://www.youtube.com/watch?v=7I6tHw68DMQ

stages:
  - test
phit0's avatar
phit0 committed
  - test-benchmarks
Johannes Boog's avatar
Johannes Boog committed

test:
  image: $CI_REGISTRY_IMAGE:latest
Johannes Boog's avatar
Johannes Boog committed
  stage: test
  tags:
    - envinf2
  variables:
    R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib/"
    RETICULATE_MINICONDA_PATH: "/root/.local/share/r-miniconda/" #default path
    RETICULATE_PYTHON_ENV: "/root/.local/share/r-miniconda/envs/r-reticulate/"
  script:
    - if [ ! -d "$R_LIBS_USER" ]; then mkdir -p "$R_LIBS_USER"; fi
    - R -e 'withr::with_libpaths(new = Sys.getenv("R_LIBS_USER"), devtools::install_deps(dependencies = T))'
phit0's avatar
phit0 committed
    # checks if the packages from the Imports, Suggests, LinkinTo field
    # are already installed in the cache
Johannes Boog's avatar
Johannes Boog committed
    - R -e '.libPaths(new = Sys.getenv("R_LIBS_USER"))'
    - R -e 'withr::with_libpaths(new = Sys.getenv("R_LIBS_USER"), {install.packages("BiocManager"); BiocManager::install("rhdf5")})'
phit0's avatar
phit0 committed
    # Build and Check r2ogs6
Johannes Boog's avatar
Johannes Boog committed
    - R CMD build . --no-build-vignettes --no-manual
    - R CMD check $(ls -1t *.tar.gz | head -n 1) --no-build-vignettes --no-manual
  after_script:
    - R -e 'covr::package_coverage(type = c("tests", "examples"), quiet = F)'
  coverage: '/Coverage: \d+\.\d+\%/'
Johannes Boog's avatar
Johannes Boog committed
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    untracked: true
    paths:
      - "$R_LIBS_USER"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "web"'
phit0's avatar
phit0 committed
    - if: '$CI_COMMIT_BRANCH == "master"'
phit0's avatar
phit0 committed
benchmark:ref:
  stage: test-benchmarks
  tags:
    - envinf1
  image: "$CI_REGISTRY_IMAGE"
  variables:
    R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib/"
    # change this as needed
    OGS_VERSION: "6.4.1"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: on_success
  script:
    - if [ ! -d "$R_LIBS_USER" ]; then mkdir -p "$R_LIBS_USER"; fi
    - R -e 'withr::with_libpaths(new = Sys.getenv("R_LIBS_USER"), devtools::install_deps(dependencies = T))'
    - R -e '.libPaths(new = Sys.getenv("R_LIBS_USER"))'
    - Rscript ./ci/test_bm_script.R "$OGS_VERSION" "ref"
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    untracked: true
    paths:
      - "$R_LIBS_USER"
  artifacts:
phit0's avatar
phit0 committed
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 4 hrs
phit0's avatar
phit0 committed
    paths:
      - ref_exit.rda
phit0's avatar
phit0 committed
      - out_ref/logfiles/
phit0's avatar
phit0 committed

benchmark:r2ogs6:
  stage: test-benchmarks
  tags:
    - envinf1
  image: "$CI_REGISTRY_IMAGE"
  variables:
    R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib/"
    # change this as needed
    OGS_VERSION: "6.4.1"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: on_success
  script:
    - if [ ! -d "$R_LIBS_USER" ]; then mkdir -p "$R_LIBS_USER"; fi
    - R -e 'withr::with_libpaths(new = Sys.getenv("R_LIBS_USER"), devtools::install_deps(dependencies = T))'
    - R -e '.libPaths(new = Sys.getenv("R_LIBS_USER"))'
    - Rscript ./ci/test_bm_script.R "$OGS_VERSION" "r2ogs6"
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    untracked: true
    paths:
      - "$R_LIBS_USER"
  artifacts:
phit0's avatar
phit0 committed
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 4 hrs
phit0's avatar
phit0 committed
    paths:
      - test_exit.rda
      - out-test/logfiles/
phit0's avatar
phit0 committed

compare-benchmarks:
  needs: ["benchmark:ref", "benchmark:r2ogs6"]
  stage: test-benchmarks
  tags:
    - envinf1
  image: "$CI_REGISTRY_IMAGE"
phit0's avatar
phit0 committed
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: on_success
phit0's avatar
phit0 committed
  dependencies:
    - benchmark:ref
    - benchmark:r2ogs6
phit0's avatar
phit0 committed
    - Rscript ./ci/test_bm_script.R "$OGS_VERSION" "test"