diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc7cef564e227c48c841371f357c31dca2bd969d..6317a234801ed289b6be2dfac7f72c55d4f536f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ include: - - local: '/.gitlab-ci-runner-tests.yml' - - local: '/.gitlab-ci-docker-tests.yml' - - local: '/.gitlab-ci-checkers-tests.yml' - - local: '/.gitlab-ci-gitlab-package-registry-tests.yml' - - local: '/.gitlab-ci-r-tests.yml' + - local: '/tests/.gitlab-ci-runner-tests.yml' + - local: '/tests/.gitlab-ci-docker-tests.yml' + - local: '/tests/.gitlab-ci-checkers-tests.yml' + - local: '/tests/.gitlab-ci-gitlab-package-registry-tests.yml' + - local: '/tests/.gitlab-ci-r-tests.yml' diff --git a/.lintr b/.lintr new file mode 100644 index 0000000000000000000000000000000000000000..feae1daa03113879a2992a41ff13a6b72102080a --- /dev/null +++ b/.lintr @@ -0,0 +1,7 @@ +linters: linters_with_defaults( + line_length_linter = line_length_linter(100L), + object_name_linter = object_name_linter(styles = c("snake_case", + "CamelCase", + "camelCase")), + cyclocomp_linter = NULL + ) diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R new file mode 100644 index 0000000000000000000000000000000000000000..71ca16528fad7c317036735ef2b4040b49b19e1d --- /dev/null +++ b/R/installDepsWithErrManagement.R @@ -0,0 +1,107 @@ +#' @title devtools::install_dev_deps with error management +#' @description Add an error and warning management around +#' devtools::install_dev_deps call. +#' Useful for any R CI. +#' @param warningsAsErrors Boolean, +#' TRUE to manage warnings and errors as errors. +#' FALSE to manage only errors as errors. +#' @param printAllMessages Boolean, TRUE to print all messages +#' printed by devtools::install_dev_deps +#' @return A list with: +#' - errorOccurs: a boolean at TRUE if an error or a warning occurs +#' - allMessages: a vector containing all messages +#' generated by devtools::install_dev_deps +#' @examples +#' installDepsWithErrManagement(warningsAsErrors = TRUE, printAllMessages = TRUE) +installDepsWithErrManagement <- function(warningsAsErrors = FALSE, + printAllMessages = TRUE) { + allMessages <- vector("character") + errorOccurs <- FALSE + + # Call devtools::install_dev_deps and catch error and/or warnings + # All generated messages are catched by textConnection con and sink command + if (warningsAsErrors) { + errorOccurs <- tryCatch( + expr = { + con <- textConnection( + object = "allMessages", + open = "wr", + local = TRUE) + sink(file = con, type = "output") + sink(file = con, type = "message") + + repo <- "https://cloud.r-project.org" + + # Install devtools and stringi packages which are used here + install.packages(pkgs = "devtools", repos = repo) + install.packages(pkgs = "stringi", repos = repo) + + devtools::install_dev_deps(dependencies = TRUE, + upgrade = "always") + FALSE + }, + error = function(e) { + return(TRUE) + }, + warning = function(w) { + return(TRUE) + }, + finally = { + sink(type = "output") + sink(type = "message") + close(con) + }) + } else { + errorOccurs <- tryCatch( + expr = { + con <- textConnection( + object = "allMessages", + open = "wr", + local = TRUE) + sink(file = con, type = "output") + sink(file = con, type = "message") + + repo <- "https://cloud.r-project.org" + + # Install devtools and stringi packages which are used here + install.packages(pkgs = "devtools", repos = repo) + install.packages(pkgs = "stringi", repos = repo) + + devtools::install_dev_deps(dependencies = TRUE, + upgrade = "always") + FALSE + }, + error = function(e) { + return(TRUE) + }, + finally = { + sink(type = "output") + sink(type = "message") + close(con) + }) + } + + # Print all messages to console + if (printAllMessages) { + print(allMessages) + } + + # Check for other problems: + # - Check for unavailable packages + pbs <- stringi::stri_detect_regex( + str = allMessages, + pattern = "Skipping \\d* packages not available:", + case_insensitive = FALSE) + if (any(pbs)) { + message <- "Some packages have not been installed" + message(message) + allMessages <- paste0(allMessages, message) + errorOccurs <- TRUE + } + + if (errorOccurs) { + message("Some error occurs in devtools::install_dev_deps call") + } + + return(list(errorOccurs = errorOccurs, allMessages = allMessages)) +} diff --git a/R/optionsForCi.R b/R/optionsForCi.R new file mode 100644 index 0000000000000000000000000000000000000000..dab79d3ab97c08b9548b7ceed453989807b55e51 --- /dev/null +++ b/R/optionsForCi.R @@ -0,0 +1,15 @@ +#' @title Set options for R CI +#' @description Set some options useful for CI +#' @return A backup of options before this function call +#' @examples +#' beforeOptions <- setOptionsForCi() +#' # Restor options +#' options(beforeOptions) +setOptionsForCi <- function() { + optionsBackup <- options() + options(showWarnCalls = TRUE, # Show a call stack for warnings + showErrorCalls = TRUE, # Show a call stack for errors + show.error.messages = TRUE, # Show error message with try or error handler + warn = 2) # Warnings turned as errors + return(optionsBackup) +} diff --git a/README.md b/README.md index 3b30f926df66763c124b7ae6fc457e1c53ca052e..bd1feedde64cf3aab1f88a40262303bb5a6b153e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [](https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/-/commits/main "main branch CI pipeline status!") -This repository collect useful Gitlab CI templates files. +This repository contains useful Gitlab CI templates files. ## Template files descriptions @@ -11,6 +11,10 @@ This repository collect useful Gitlab CI templates files. | [templates-docker.yml](/templates/templates-docker.yml) | Templates for build and push docker images | | [templates-gitlab-docker-registry.yml](/templates/templates-gitlab-docker-registry.yml) | Templates for connection to the project Gitlab Docker Registry | | [templates-gitlab-package-registry.yml](/templates/templates-gitlab-package-registry.yml) | Templates for download/upload to the project Gitlab Package Registry | +| [templates-checkers.yml](/templates/templates-checkers.yml) | Templates for checking some job results, for examples: checking keywords presence in logs (errors in compile log, etc.), checking uncommitted git changes, etc. | +| [templates-r.yml](/templates/templates-r.yml) | Templates around R language | + +See detailed descriptions of each template job [here](/docs/Descriptions.md). ## Use the templates @@ -18,17 +22,17 @@ This repository collect useful Gitlab CI templates files. ```yaml include: - project: - - project: 'urep/dev_utils/gitlab-ci-templates' - file: '/templates/templates-<name>.yml' + project: + - project: 'urep/dev_utils/gitlab-ci-templates' + file: '/templates/templates-<name>.yml' ``` 2. Use template jobs in an **extends** keyword field in your .gitlab-ci.yml (or subfile) file: ```yaml jobname: - extends: - - .<template job name> + extends: + - .<template job name> ``` ## Tests diff --git a/docs/Descriptions.md b/docs/Descriptions.md new file mode 100644 index 0000000000000000000000000000000000000000..f2045eacb9ac64fa773b15246bc51a177fe76da1 --- /dev/null +++ b/docs/Descriptions.md @@ -0,0 +1,94 @@ +# Templates detailed descriptions + +## Docker + +*([templates-docker.yml](/templates/templates-docker.yml))* + +- **.docker-build-and-push** + Builds a Docker image from a Dockerfile and push it to the Gitlab Registry. + Required variables: + - `DOCKERFILE_PATH`: Path to the Dockerfile to build. Defaulted to "Dockerfile". + - `CONTAINER_TAG`: The chosen docker tag for the new image. A default value is defined here: `$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA`. + Optional variable: + - `USE_CACHE`: Empty this variable to use cache. +- **.docker-push-latest** + Tags the Docker image for "main" branch as "latest". +- **.docker-push-tag** + Tags the Docker image for any Git tag. + GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome. + +## Gitlab Docker Registry + +*([templates-gitlab-docker-registry.yml](/templates/templates-gitlab-docker-registry.yml))* + +- **.gitlab-docker-registry-login-linux** + Connects to the project registry for linux runners. +- **.gitlab-docker-registry-login-windows** + Connects to the project registry for Windows runners (powershell). + +## Gitlab Package Registry + +*([templates-gitlab-package-registry.yml](/templates/templates-gitlab-package-registry.yml))* + +- **.gitlab-generic-package-upload** + Allows uploading a new package to the "package registry" of the current Gitlab project. + The variables `PACKAGE_NAME` and `FILENAME` must be redined. The package is stored in registry in this path: `${PACKAGE_NAME}/${GITLAB_PACKAGE_VERSION}/${FILENAME}`. + By default `GITLAB_PACKAGE_VERSION` is the commit SHA tag. + Optionaliy, variables `GITLAB_PACKAGE_VERSION` and `PATH_IN_PACKAGE_REGISTRY` cand be redefined if default are not what is expected. +- **.gitlab-generic-package-download** + Allows downloading an existing package from the "package registry" of the current Gitlab project. + Same variables rules as **.gitlab-generic-package-upload** apply to this template. +- **.gitlab-generic-package-delete** + > :warning: template commented, see issue #2 + +## Checkers + +*([templates-checkers.yml](/templates/templates-checkers.yml))* + +- **.check-find-bad-keywords-in-files-linux** + Checks in files given in variable `SEARCH_FILES` if keywords given in variable `KEYWORDS` occurs (default keywords: "error ", "warning ", "remark "). + If some are found then return an error but not critical for pipeline (warning). + The lines found are printed to console. + This template is for linux runners. + > This has been primarily developped to checkers warnings in compile logs. +- **.check-find-bad-keywords-in-file-windows** + This is a version for Windows runners of the previous template. +- **.check-git-uncommitted-changes** + This job checks if the local git clone has some uncommitted changes. + > This is useful to ensure no versionned files have been changed by CI. +- **.check-git-notmanaged-changes** + This job checks if the local git clone has some unversioned files not ignored nor uncommitted changes. + > This is useful to ensure there are no files which must be ignored. + +## R language + +*([templates-r.yml](/templates/templates-r.yml))* + +- **.R-package-cache** + This template define the useful paths to the local packages libraries in an order which allow a cache creation. The path cached must be within the working project directory, so default ones doesn't work. + So this template define a cache with the key `R-installed-packages-cache`. + It is recommended to extend this template for all R CI jobs, because this allow some performance gain. + > Note: each runner has a dedicated cache, so the running job use only data in the cache of the runner is running on! +- **optionsForCi.R** + This is not a template, but an R function can be call before other R command in order to set some options useful for CI. These options force CI to stop on warnings and force showing additionnal call stack infos and errors messages. + To use this, first you need to download it in the script sectionand then the function could be called in an R command (and previous options restored at the end): + + ```yaml + - script: + - mkdir temp_gitlabTemplates + - wget https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/-/raw/dev/R/optionsForCi.R?inline=false --output-document=temp_gitlabTemplates/optionsForCi.R + - > + R -q -e ' + source("temp_gitlabTemplates/optionsForCi.R"); + + <other R commands> + + options(optionsBackup) + ' + - rm -rf temp_gitlabTemplates + ``` + +- **.R-install-package-dependencies-withCache** + This template install all required and suggest packages of a package sources project. + > The default behavior of devtools functions is not to raise errors, so if an install fails this doesn't stop the CI. This template purpose is to correct that. + > This template use the `R-installed-packages-cache` cache. diff --git a/templates/templates-checkers.yml b/templates/templates-checkers.yml index dd38f78255542452f07e3c38138a28a5f781f143..3778939ec3d81298c9f67c16c69e60ddbeedb1ac 100644 --- a/templates/templates-checkers.yml +++ b/templates/templates-checkers.yml @@ -1,7 +1,7 @@ # This job search in given files for keywords. # If some are found then return an error but not critical for pipeline (warning) -# The line found are printed to console -.check-find-bad-keyworkds-in-files-linux: +# The lines found are printed to console +.check-find-bad-keywords-in-files-linux: tags: - docker image: alpine:3.16 @@ -21,8 +21,8 @@ # This job search in given file for keywords. # If some are found then return an error but not critical for pipeline (warning) -# The line found are printed to console -.check-find-bad-keyworkds-in-file-windows: +# The lines found are printed to console +.check-find-bad-keywords-in-file-windows: tags: - windows-powershell variables: @@ -44,7 +44,7 @@ - if ($hints) { exit ${FOUND_RETURN_CODE} } else { exit ${NOTFOUND_RETURN_CODE} } allow_failure: true -# This job check if the local git clone has some uncommitted changes +# This job checks if the local git clone has some uncommitted changes # This is useful to ensure no versionned files have been changed by CI .check-git-uncommitted-changes: tags: @@ -60,8 +60,8 @@ - if [[ -z "$(git status --untracked-files=no --porcelain=v1)" ]]; then exit ${EMPTY_RETURN_CODE}; exit ${NOTEMPTY_RETURN_CODE}; fi allow_failure: true -# This job check if the local git clone has some unversioned files not ignored -# or uncommitted changes. +# This job checks if the local git clone has some unversioned files not ignored +# nor uncommitted changes. # This is useful to ensure no files which must be ignored .check-git-notmanaged-changes: tags: diff --git a/templates/templates-gitlab-package-registry.yml b/templates/templates-gitlab-package-registry.yml index 7e5a843cf885385dd9b6f11b29b5172f707ee8ac..d301bf8bc26d50b5fe804b34502adad3b020f0d8 100644 --- a/templates/templates-gitlab-package-registry.yml +++ b/templates/templates-gitlab-package-registry.yml @@ -40,7 +40,7 @@ ${CI_API_V4_URL}/projects/${TARGET_PROJECT_ID}/packages/generic/${PATH_IN_PACKAGE_REGISTRY}' - if ! test -f ${FILENAME}; then exit 1; fi -# Doesn't work! The API seems to require some ids for package, but how to get them automatically? +# Doesn't work! The API seems to require some ids for package, but how to get them automatically? (see issue #2) # .gitlab-generic-package-delete: # image: curlimages/curl:7.83.1 # tags: diff --git a/templates/templates-r.yml b/templates/templates-r.yml index b4c58e096ed052a3db8a4dff3a8a6e453ef40dd2..f769c179f41ae67bbda57e94f8fc951a09192b0f 100644 --- a/templates/templates-r.yml +++ b/templates/templates-r.yml @@ -29,51 +29,34 @@ # For tests purposes TEST_ERROR: 0 script: + # Files other than yml must be download because Gitlab include keyworkd doesn't get it + - mkdir temp_gitlabTemplates + - wget https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/-/raw/dev/R/optionsForCi.R?inline=false --output-document=temp_gitlabTemplates/optionsForCi.R + - wget https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/-/raw/dev/R/installDepsWithErrManagement.R?inline=false --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R - > R -q -e ' - options(showWarnCalls = TRUE, - showErrorCalls = TRUE, - show.error.messages = TRUE, - warn = 2); - allMessages <- vector("character"); - errorOccurs <- FALSE; - tryCatch( - { - con <- textConnection(object = "allMessages", - open = "wr", - local = TRUE); - sink(file = con, type = "output"); - sink(file = con, type = "message"); - devtools::install_dev_deps(dependencies = TRUE) - }, - error = function(e) {errorOccurs <- TRUE}, - warning = function(w) {errorOccurs <- TRUE}, - finally = { - sink(type = "output"); - sink(type = "message"); - close(con) - }); - print(allMessages); - if (errorOccurs) { - if (Sys.getenv("TEST_ERROR") == 1) { - message("Some error occurs in devtools::install_dev_deps call"); - errorOccurs <- TRUE - } else { - stop("Some error occurs in devtools::install_dev_deps call") - } - }; - pbs <- stringi::stri_detect_regex( - str = allMessages, - pattern = "Skipping \\d* packages not available:", - case_insensitive = FALSE); - if (any(pbs)) { + getwd() + source("temp_gitlabTemplates/optionsForCi.R"); + source("temp_gitlabTemplates/installDepsWithErrManagement.R"); + + optionsBackup <- setOptionsForCi(); + + resList <- installDepsWithErrManagement(warningsAsErrors = TRUE, + printAllMessages = TRUE); + + if (resList[["errorOccurs"]]) { + message <- "Some error occurs in devtools::install_dev_deps call"; if (Sys.getenv("TEST_ERROR") == 1) { - message("Some packages have not been installed"); - errorOccurs <- TRUE + message(message) } else { - stop("Some packages have not been installed") + stop(message) } - }; - if (errorOccurs == FALSE && Sys.getenv("TEST_ERROR") == 1) { + } + + if (resList[["errorOccurs"]] == FALSE && Sys.getenv("TEST_ERROR") == 1) { stop("An error is expected but none occurs") - }' + } + + options(optionsBackup) + ' + - rm -rf temp_gitlabTemplates diff --git a/.gitlab-ci-checkers-tests.yml b/tests/.gitlab-ci-checkers-tests.yml similarity index 68% rename from .gitlab-ci-checkers-tests.yml rename to tests/.gitlab-ci-checkers-tests.yml index 2f0db7612ebbdc605f84c0db050a8ebff8d0d158..37ab0589b5d9d2b1021d40a4e8704cd3a5cc34a3 100644 --- a/.gitlab-ci-checkers-tests.yml +++ b/tests/.gitlab-ci-checkers-tests.yml @@ -5,58 +5,58 @@ include: Test check-find-linux Bad: variables: - SEARCH_FILES: test/Checkers-find-test-bad.txt + SEARCH_FILES: tests/Checkers-find-test-bad.txt FOUND_RETURN_CODE: 0 NOTFOUND_RETURN_CODE: 1 extends: - - .check-find-bad-keyworkds-in-files-linux + - .check-find-bad-keywords-in-files-linux rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml - - test/Checkers-find-test-bad.txt + - tests/Checkers-find-test-bad.txt allow_failure: false Test check-find-windows Bad: variables: - SEARCH_FILE: test/Checkers-find-test-bad.txt + SEARCH_FILE: tests/Checkers-find-test-bad.txt FOUND_RETURN_CODE: 0 NOTFOUND_RETURN_CODE: 1 extends: - - .check-find-bad-keyworkds-in-file-windows + - .check-find-bad-keywords-in-file-windows rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml - - test/Checkers-find-test-bad.txt + - tests/Checkers-find-test-bad.txt allow_failure: false Test check-find-linux Good: variables: - SEARCH_FILES: test/Checkers-find-test-good.txt + SEARCH_FILES: tests/Checkers-find-test-good.txt extends: - - .check-find-bad-keyworkds-in-files-linux + - .check-find-bad-keywords-in-files-linux rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml - - test/Checkers-find-test-good.txt + - tests/Checkers-find-test-good.txt allow_failure: false Test check-find-windows Good: variables: - SEARCH_FILE: test/Checkers-find-test-good.txt + SEARCH_FILE: tests/Checkers-find-test-good.txt extends: - - .check-find-bad-keyworkds-in-file-windows + - .check-find-bad-keywords-in-file-windows rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml - - test/Checkers-find-test-good.txt + - tests/Checkers-find-test-good.txt allow_failure: false Test check-git-uncommitted-changes No: @@ -65,7 +65,7 @@ Test check-git-uncommitted-changes No: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml allow_failure: false @@ -75,7 +75,7 @@ Test check-git-notmanaged-changes No: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml allow_failure: false @@ -83,19 +83,19 @@ Before test change versioned file: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml script: - - echo "Hello, world." > test/DummyFile + - echo "Hello, world." > tests/DummyFile artifacts: paths: - - test/DummyFile + - tests/DummyFile Before test add a file: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml script: - mkdir temp @@ -112,7 +112,7 @@ Test check-git-uncommitted-changes Yes: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml variables: EMPTY_RETURN_CODE: 1 @@ -127,7 +127,7 @@ Test check-git-notmanaged-changes Yes: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-checkers-tests.yml + - tests/.gitlab-ci-checkers-tests.yml - templates/templates-checkers.yml variables: EMPTY_RETURN_CODE: 1 diff --git a/.gitlab-ci-docker-tests.yml b/tests/.gitlab-ci-docker-tests.yml similarity index 80% rename from .gitlab-ci-docker-tests.yml rename to tests/.gitlab-ci-docker-tests.yml index 6e673f01aa65720a94358bf4000b630fa83fb38e..c828beb6f74635c22c6d5340c27cf47170c804e4 100644 --- a/.gitlab-ci-docker-tests.yml +++ b/tests/.gitlab-ci-docker-tests.yml @@ -11,7 +11,7 @@ Test Docker Build and Push Linux: tags: - docker variables: - DOCKERFILE_PATH: test/Dockerfile-test-linux + DOCKERFILE_PATH: tests/Dockerfile-test-linux extends: - .gitlab-docker-registry-login-dind-vars - .gitlab-docker-registry-login-linux @@ -19,16 +19,16 @@ Test Docker Build and Push Linux: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-linux + - tests/Dockerfile-test-linux Test Docker Build and Push Windows: tags: - - windows-shell + - windows-powershell variables: - DOCKERFILE_PATH: test/Dockerfile-test-windows + DOCKERFILE_PATH: tests/Dockerfile-test-windows CONTAINER_TAG: ${BASE_CONTAINER_TAG}-windows extends: - .gitlab-docker-registry-login-windows @@ -36,10 +36,10 @@ Test Docker Build and Push Windows: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-windows + - tests/Dockerfile-test-windows Test Docker Push latest Linux: image: docker:20 @@ -55,14 +55,14 @@ Test Docker Push latest Linux: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-linux + - tests/Dockerfile-test-linux Test Docker Push latest Windows: tags: - - windows-shell + - windows-powershell needs: ["Test Docker Build and Push Windows"] extends: - .gitlab-docker-registry-login-windows @@ -73,10 +73,10 @@ Test Docker Push latest Windows: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-windows + - tests/Dockerfile-test-windows Test Docker Push tag Linux: image: docker:20 @@ -92,14 +92,14 @@ Test Docker Push tag Linux: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-linux + - tests/Dockerfile-test-linux Test Docker Push tag Windows: tags: - - windows-shell + - windows-powershell needs: ["Test Docker Build and Push Windows"] extends: - .gitlab-docker-registry-login-windows @@ -110,10 +110,10 @@ Test Docker Push tag Windows: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-docker-tests.yml + - tests/.gitlab-ci-docker-tests.yml - templates/templates-gitlab-docker-registry.yml - templates/templates-docker.yml - - test/Dockerfile-test-windows + - tests/Dockerfile-test-windows # Cleanup for generated image in the registry is done by the project cleanup policy # (see https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/-/settings/packages_and_registries). diff --git a/.gitlab-ci-gitlab-package-registry-tests.yml b/tests/.gitlab-ci-gitlab-package-registry-tests.yml similarity index 88% rename from .gitlab-ci-gitlab-package-registry-tests.yml rename to tests/.gitlab-ci-gitlab-package-registry-tests.yml index 87ca1ecc7dbc6d2d209340c13d5e31f5e8aa8890..a6c06857dd29287cfb0ceea7fd2777b71e6048f1 100644 --- a/.gitlab-ci-gitlab-package-registry-tests.yml +++ b/tests/.gitlab-ci-gitlab-package-registry-tests.yml @@ -9,7 +9,7 @@ Test Package Upload: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-gitlab-package-registry-tests.yml + - tests/.gitlab-ci-gitlab-package-registry-tests.yml - templates/templates-gitlab-package-registry.yml variables: PACKAGE_NAME: 'CiTests' @@ -25,7 +25,7 @@ Test Package Download: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-gitlab-package-registry-tests.yml + - tests/.gitlab-ci-gitlab-package-registry-tests.yml - templates/templates-gitlab-package-registry.yml variables: PACKAGE_NAME: 'CiTests' @@ -41,7 +41,7 @@ Test Package Download: # rules: # - changes: # - .gitlab-ci.yml -# - .gitlab-ci-gitlab-package-registry-tests.yml +# - tests/.gitlab-ci-gitlab-package-registry-tests.yml # - templates/templates-gitlab-package-registry.yml # when: always # variables: diff --git a/.gitlab-ci-r-tests.yml b/tests/.gitlab-ci-r-tests.yml similarity index 77% rename from .gitlab-ci-r-tests.yml rename to tests/.gitlab-ci-r-tests.yml index 2352bf6f30bc38b53943d9680592e15f4cc4d0f8..1597e447a53144f2f0ea7e1a24539b78829ec1c1 100644 --- a/.gitlab-ci-r-tests.yml +++ b/tests/.gitlab-ci-r-tests.yml @@ -9,13 +9,14 @@ Test R-install-package-dependencies-withCache Good: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-r-tests.yml + - tests/.gitlab-ci-r-tests.yml - templates/templates-r.yml - - test/r-package + - tests/r-package/* + - R/* variables: TEST_ERROR: 0 script: - - cd test/r-package + - cd tests/r-package - !reference [.R-install-package-dependencies-withCache, script] Test R-install-package-dependencies-withCache Bad: @@ -24,11 +25,12 @@ Test R-install-package-dependencies-withCache Bad: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-r-tests.yml + - tests/.gitlab-ci-r-tests.yml - templates/templates-r.yml - - test/r-package + - tests/r-package/* + - R/* variables: TEST_ERROR: 1 script: - - cd test/r-package-bad-deps + - cd tests/r-package-bad-deps - !reference [.R-install-package-dependencies-withCache, script] diff --git a/.gitlab-ci-runner-tests.yml b/tests/.gitlab-ci-runner-tests.yml similarity index 82% rename from .gitlab-ci-runner-tests.yml rename to tests/.gitlab-ci-runner-tests.yml index 6cc5f9212165c9bdf1fc2c0ab1464951d75680e3..172d64a44bcb409cb4e31836c7ea767a11b81e16 100644 --- a/.gitlab-ci-runner-tests.yml +++ b/tests/.gitlab-ci-runner-tests.yml @@ -10,7 +10,7 @@ Test Linux Docker Runner: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-runner-tests.yml + - tests/.gitlab-ci-runner-tests.yml # dind stand for "Docker-in-Docker" Test Linux Docker Runner with dind: @@ -24,17 +24,17 @@ Test Linux Docker Runner with dind: rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-runner-tests.yml + - tests/.gitlab-ci-runner-tests.yml Test Windows Shell Runner: tags: - - windows-shell + - windows-powershell script: - dir rules: - changes: - .gitlab-ci.yml - - .gitlab-ci-runner-tests.yml + - tests/.gitlab-ci-runner-tests.yml # Disabled because not working, see issue #1 # Test Windows Docker Runner: @@ -46,7 +46,7 @@ Test Windows Shell Runner: # rules: # - changes: # - .gitlab-ci.yml -# - .gitlab-ci-runner-tests.yml +# - tests/.gitlab-ci-runner-tests.yml # Disabled because not working, see issue #1 # dind stand for "Docker-in-Docker" @@ -61,4 +61,4 @@ Test Windows Shell Runner: # rules: # - changes: # - .gitlab-ci.yml -# - .gitlab-ci-runner-tests.yml +# - tests/.gitlab-ci-runner-tests.yml diff --git a/test/Checkers-find-test-bad.txt b/tests/Checkers-find-test-bad.txt similarity index 100% rename from test/Checkers-find-test-bad.txt rename to tests/Checkers-find-test-bad.txt diff --git a/test/Checkers-find-test-good.txt b/tests/Checkers-find-test-good.txt similarity index 100% rename from test/Checkers-find-test-good.txt rename to tests/Checkers-find-test-good.txt diff --git a/test/Dockerfile-test-linux b/tests/Dockerfile-test-linux similarity index 100% rename from test/Dockerfile-test-linux rename to tests/Dockerfile-test-linux diff --git a/test/Dockerfile-test-windows b/tests/Dockerfile-test-windows similarity index 100% rename from test/Dockerfile-test-windows rename to tests/Dockerfile-test-windows diff --git a/test/DummyFile b/tests/DummyFile similarity index 100% rename from test/DummyFile rename to tests/DummyFile diff --git a/test/r-package-bad-deps/.Rbuildignore b/tests/r-package-bad-deps/.Rbuildignore similarity index 100% rename from test/r-package-bad-deps/.Rbuildignore rename to tests/r-package-bad-deps/.Rbuildignore diff --git a/test/r-package-bad-deps/.gitignore b/tests/r-package-bad-deps/.gitignore similarity index 100% rename from test/r-package-bad-deps/.gitignore rename to tests/r-package-bad-deps/.gitignore diff --git a/test/r-package-bad-deps/DESCRIPTION b/tests/r-package-bad-deps/DESCRIPTION similarity index 100% rename from test/r-package-bad-deps/DESCRIPTION rename to tests/r-package-bad-deps/DESCRIPTION diff --git a/test/r-package-bad-deps/LICENSE.md b/tests/r-package-bad-deps/LICENSE.md similarity index 100% rename from test/r-package-bad-deps/LICENSE.md rename to tests/r-package-bad-deps/LICENSE.md diff --git a/test/r-package-bad-deps/NEWS.md b/tests/r-package-bad-deps/NEWS.md similarity index 100% rename from test/r-package-bad-deps/NEWS.md rename to tests/r-package-bad-deps/NEWS.md diff --git a/test/r-package-bad-deps/R/dummy.R b/tests/r-package-bad-deps/R/dummy.R similarity index 100% rename from test/r-package-bad-deps/R/dummy.R rename to tests/r-package-bad-deps/R/dummy.R diff --git a/test/r-package-bad-deps/README.Rmd b/tests/r-package-bad-deps/README.Rmd similarity index 100% rename from test/r-package-bad-deps/README.Rmd rename to tests/r-package-bad-deps/README.Rmd diff --git a/test/r-package-bad-deps/tests/spelling.R b/tests/r-package-bad-deps/tests/spelling.R similarity index 100% rename from test/r-package-bad-deps/tests/spelling.R rename to tests/r-package-bad-deps/tests/spelling.R diff --git a/test/r-package-bad-deps/tests/testthat.R b/tests/r-package-bad-deps/tests/testthat.R similarity index 100% rename from test/r-package-bad-deps/tests/testthat.R rename to tests/r-package-bad-deps/tests/testthat.R diff --git a/test/r-package-bad-deps/tests/testthat/test-dummy.R b/tests/r-package-bad-deps/tests/testthat/test-dummy.R similarity index 100% rename from test/r-package-bad-deps/tests/testthat/test-dummy.R rename to tests/r-package-bad-deps/tests/testthat/test-dummy.R diff --git a/test/r-package/.Rbuildignore b/tests/r-package/.Rbuildignore similarity index 100% rename from test/r-package/.Rbuildignore rename to tests/r-package/.Rbuildignore diff --git a/test/r-package/.gitignore b/tests/r-package/.gitignore similarity index 100% rename from test/r-package/.gitignore rename to tests/r-package/.gitignore diff --git a/test/r-package/DESCRIPTION b/tests/r-package/DESCRIPTION similarity index 100% rename from test/r-package/DESCRIPTION rename to tests/r-package/DESCRIPTION diff --git a/test/r-package/LICENSE.md b/tests/r-package/LICENSE.md similarity index 100% rename from test/r-package/LICENSE.md rename to tests/r-package/LICENSE.md diff --git a/test/r-package/NEWS.md b/tests/r-package/NEWS.md similarity index 100% rename from test/r-package/NEWS.md rename to tests/r-package/NEWS.md diff --git a/test/r-package/R/dummy.R b/tests/r-package/R/dummy.R similarity index 100% rename from test/r-package/R/dummy.R rename to tests/r-package/R/dummy.R diff --git a/test/r-package/README.Rmd b/tests/r-package/README.Rmd similarity index 100% rename from test/r-package/README.Rmd rename to tests/r-package/README.Rmd diff --git a/test/r-package/tests/spelling.R b/tests/r-package/tests/spelling.R similarity index 100% rename from test/r-package/tests/spelling.R rename to tests/r-package/tests/spelling.R diff --git a/test/r-package/tests/testthat.R b/tests/r-package/tests/testthat.R similarity index 100% rename from test/r-package/tests/testthat.R rename to tests/r-package/tests/testthat.R diff --git a/test/r-package/tests/testthat/test-dummy.R b/tests/r-package/tests/testthat/test-dummy.R similarity index 100% rename from test/r-package/tests/testthat/test-dummy.R rename to tests/r-package/tests/testthat/test-dummy.R