From 7410d5d87deb09cf1a9d2bd44d82ee1d967ea9d3 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 15:44:06 +0200
Subject: [PATCH 01/29] Add a TODO related to warning catched management...

---
 templates/templates-r.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index b4c58e0..c190190 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -37,6 +37,7 @@
                 warn = 2);
         allMessages <- vector("character");
         errorOccurs <- FALSE;
+        # TODO Attention le catch warning arrête le code sous-jacent !
         tryCatch(
           {
             con <- textConnection(object = "allMessages",
-- 
GitLab


From a67e3140c11919fc8d2cad4bf84b88dd2cecdf6f Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 15:50:21 +0200
Subject: [PATCH 02/29] Rearrange tests related data

---
 .gitlab-ci.yml                                | 10 +++++-----
 .../.gitlab-ci-checkers-tests.yml             | 20 +++++++++----------
 .../.gitlab-ci-docker-tests.yml               | 16 +++++++--------
 ...itlab-ci-gitlab-package-registry-tests.yml |  0
 .../.gitlab-ci-r-tests.yml                    |  8 ++++----
 .../.gitlab-ci-runner-tests.yml               |  0
 {test => tests}/Checkers-find-test-bad.txt    |  0
 {test => tests}/Checkers-find-test-good.txt   |  0
 {test => tests}/Dockerfile-test-linux         |  0
 {test => tests}/Dockerfile-test-windows       |  0
 {test => tests}/DummyFile                     |  0
 .../r-package-bad-deps/.Rbuildignore          |  0
 {test => tests}/r-package-bad-deps/.gitignore |  0
 .../r-package-bad-deps/DESCRIPTION            |  0
 {test => tests}/r-package-bad-deps/LICENSE.md |  0
 {test => tests}/r-package-bad-deps/NEWS.md    |  0
 {test => tests}/r-package-bad-deps/R/dummy.R  |  0
 {test => tests}/r-package-bad-deps/README.Rmd |  0
 .../r-package-bad-deps/tests/spelling.R       |  0
 .../r-package-bad-deps/tests/testthat.R       |  0
 .../tests/testthat/test-dummy.R               |  0
 {test => tests}/r-package/.Rbuildignore       |  0
 {test => tests}/r-package/.gitignore          |  0
 {test => tests}/r-package/DESCRIPTION         |  0
 {test => tests}/r-package/LICENSE.md          |  0
 {test => tests}/r-package/NEWS.md             |  0
 {test => tests}/r-package/R/dummy.R           |  0
 {test => tests}/r-package/README.Rmd          |  0
 {test => tests}/r-package/tests/spelling.R    |  0
 {test => tests}/r-package/tests/testthat.R    |  0
 .../r-package/tests/testthat/test-dummy.R     |  0
 31 files changed, 27 insertions(+), 27 deletions(-)
 rename .gitlab-ci-checkers-tests.yml => tests/.gitlab-ci-checkers-tests.yml (86%)
 rename .gitlab-ci-docker-tests.yml => tests/.gitlab-ci-docker-tests.yml (90%)
 rename .gitlab-ci-gitlab-package-registry-tests.yml => tests/.gitlab-ci-gitlab-package-registry-tests.yml (100%)
 rename .gitlab-ci-r-tests.yml => tests/.gitlab-ci-r-tests.yml (88%)
 rename .gitlab-ci-runner-tests.yml => tests/.gitlab-ci-runner-tests.yml (100%)
 rename {test => tests}/Checkers-find-test-bad.txt (100%)
 rename {test => tests}/Checkers-find-test-good.txt (100%)
 rename {test => tests}/Dockerfile-test-linux (100%)
 rename {test => tests}/Dockerfile-test-windows (100%)
 rename {test => tests}/DummyFile (100%)
 rename {test => tests}/r-package-bad-deps/.Rbuildignore (100%)
 rename {test => tests}/r-package-bad-deps/.gitignore (100%)
 rename {test => tests}/r-package-bad-deps/DESCRIPTION (100%)
 rename {test => tests}/r-package-bad-deps/LICENSE.md (100%)
 rename {test => tests}/r-package-bad-deps/NEWS.md (100%)
 rename {test => tests}/r-package-bad-deps/R/dummy.R (100%)
 rename {test => tests}/r-package-bad-deps/README.Rmd (100%)
 rename {test => tests}/r-package-bad-deps/tests/spelling.R (100%)
 rename {test => tests}/r-package-bad-deps/tests/testthat.R (100%)
 rename {test => tests}/r-package-bad-deps/tests/testthat/test-dummy.R (100%)
 rename {test => tests}/r-package/.Rbuildignore (100%)
 rename {test => tests}/r-package/.gitignore (100%)
 rename {test => tests}/r-package/DESCRIPTION (100%)
 rename {test => tests}/r-package/LICENSE.md (100%)
 rename {test => tests}/r-package/NEWS.md (100%)
 rename {test => tests}/r-package/R/dummy.R (100%)
 rename {test => tests}/r-package/README.Rmd (100%)
 rename {test => tests}/r-package/tests/spelling.R (100%)
 rename {test => tests}/r-package/tests/testthat.R (100%)
 rename {test => tests}/r-package/tests/testthat/test-dummy.R (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cc7cef5..6317a23 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/.gitlab-ci-checkers-tests.yml b/tests/.gitlab-ci-checkers-tests.yml
similarity index 86%
rename from .gitlab-ci-checkers-tests.yml
rename to tests/.gitlab-ci-checkers-tests.yml
index 2f0db76..e1d4ae1 100644
--- a/.gitlab-ci-checkers-tests.yml
+++ b/tests/.gitlab-ci-checkers-tests.yml
@@ -5,7 +5,7 @@ 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:
@@ -15,12 +15,12 @@ Test check-find-linux Bad:
       - .gitlab-ci.yml
       - .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:
@@ -30,12 +30,12 @@ Test check-find-windows Bad:
       - .gitlab-ci.yml
       - .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
   rules:
@@ -43,12 +43,12 @@ Test check-find-linux Good:
       - .gitlab-ci.yml
       - .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
   rules:
@@ -56,7 +56,7 @@ Test check-find-windows Good:
       - .gitlab-ci.yml
       - .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:
@@ -86,10 +86,10 @@ Before test change versioned file:
       - .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:
diff --git a/.gitlab-ci-docker-tests.yml b/tests/.gitlab-ci-docker-tests.yml
similarity index 90%
rename from .gitlab-ci-docker-tests.yml
rename to tests/.gitlab-ci-docker-tests.yml
index 6e673f0..cd8eaa6 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
@@ -22,13 +22,13 @@ Test Docker Build and Push Linux:
       - .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
   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
@@ -39,7 +39,7 @@ Test Docker Build and Push Windows:
       - .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
@@ -58,7 +58,7 @@ Test Docker Push latest Linux:
       - .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:
@@ -76,7 +76,7 @@ Test Docker Push latest Windows:
       - .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
@@ -95,7 +95,7 @@ Test Docker Push tag Linux:
       - .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:
@@ -113,7 +113,7 @@ Test Docker Push tag Windows:
       - .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 100%
rename from .gitlab-ci-gitlab-package-registry-tests.yml
rename to tests/.gitlab-ci-gitlab-package-registry-tests.yml
diff --git a/.gitlab-ci-r-tests.yml b/tests/.gitlab-ci-r-tests.yml
similarity index 88%
rename from .gitlab-ci-r-tests.yml
rename to tests/.gitlab-ci-r-tests.yml
index 2352bf6..0bdc9db 100644
--- a/.gitlab-ci-r-tests.yml
+++ b/tests/.gitlab-ci-r-tests.yml
@@ -11,11 +11,11 @@ Test R-install-package-dependencies-withCache Good:
       - .gitlab-ci.yml
       - .gitlab-ci-r-tests.yml
       - templates/templates-r.yml
-      - test/r-package
+      - tests/r-package
   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:
@@ -26,9 +26,9 @@ Test R-install-package-dependencies-withCache Bad:
       - .gitlab-ci.yml
       - .gitlab-ci-r-tests.yml
       - templates/templates-r.yml
-      - test/r-package
+      - tests/r-package
   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 100%
rename from .gitlab-ci-runner-tests.yml
rename to 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
-- 
GitLab


From 28e7a1eadaa6825eb0de1593ed872a428685a1a2 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:25:52 +0200
Subject: [PATCH 03/29] Reorganize code

---
 .lintr                           |   7 ++
 R/installDepsWithErrManagement.R | 108 +++++++++++++++++++++++++++++++
 R/optionsForCi.R                 |  15 +++++
 templates/templates-r.yml        |  66 +++++++------------
 4 files changed, 154 insertions(+), 42 deletions(-)
 create mode 100644 .lintr
 create mode 100644 R/installDepsWithErrManagement.R
 create mode 100644 R/optionsForCi.R

diff --git a/.lintr b/.lintr
new file mode 100644
index 0000000..feae1da
--- /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 0000000..965fc6f
--- /dev/null
+++ b/R/installDepsWithErrManagement.R
@@ -0,0 +1,108 @@
+#' @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"
+                update.packages(ask = FALSE, repos = repo)
+
+                # 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"
+                update.packages(ask = FALSE, repos = repo)
+
+                # 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)
+                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"
+        warning(message)
+        allMessages <- paste0(allMessages, message)
+        errorOccurs <- TRUE
+    }
+
+    if (errorOccurs) {
+        warning("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 0000000..dab79d3
--- /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/templates/templates-r.yml b/templates/templates-r.yml
index c190190..2236d91 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -29,52 +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
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=main --output "temp_gitlabTemplates/optionsForCi.R"
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=main --output "temp_gitlabTemplates/installDepsWithErrManagement.R"
     - >
       R -q -e '
-        options(showWarnCalls = TRUE,
-                showErrorCalls = TRUE,
-                show.error.messages = TRUE,
-                warn = 2);
-        allMessages <- vector("character");
-        errorOccurs <- FALSE;
-        # TODO Attention le catch warning arrête le code sous-jacent !
-        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)) {
+        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) {
           stop("An error is expected but none occurs")
-        }'
+        }
+
+        # Restore options
+        options(optionsBackup)
+        '
+    - rm -rf temp_gitlabTemplates
-- 
GitLab


From 64be1c20fb11e508cc10ff41f229add59f114744 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:32:57 +0200
Subject: [PATCH 04/29] Change link to dev branch + install curl in CI when
 needed

---
 templates/templates-r.yml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 2236d91..bd644b6 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,9 +30,11 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
+    - apt update
+    - apt install curl
     - mkdir temp_gitlabTemplates
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=main --output "temp_gitlabTemplates/optionsForCi.R"
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=main --output "temp_gitlabTemplates/installDepsWithErrManagement.R"
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev --output "temp_gitlabTemplates/optionsForCi.R"
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev --output "temp_gitlabTemplates/installDepsWithErrManagement.R"
     - >
       R -q -e '
         source("temp_gitlabTemplates/optionsForCi.R");
-- 
GitLab


From 8dedba65c25b0ae675ad6b25c82d8637d2a8879d Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:35:24 +0200
Subject: [PATCH 05/29] Add a getwd() to help debug

---
 templates/templates-r.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index bd644b6..d43a6ff 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -37,6 +37,7 @@
     - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev --output "temp_gitlabTemplates/installDepsWithErrManagement.R"
     - >
       R -q -e '
+        getwd()
         source("temp_gitlabTemplates/optionsForCi.R");
         source("temp_gitlabTemplates/installDepsWithErrManagement.R");
 
-- 
GitLab


From af1931cd8b6ad9f5ef48c33080ee8eca532d5f57 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:42:06 +0200
Subject: [PATCH 06/29] Try correct paths...

---
 templates/templates-r.yml | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index d43a6ff..c8e260f 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -32,14 +32,15 @@
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
     - apt update
     - apt install curl
-    - mkdir temp_gitlabTemplates
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev --output "temp_gitlabTemplates/optionsForCi.R"
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev --output "temp_gitlabTemplates/installDepsWithErrManagement.R"
+    - mkdir $CI_PROJECT_DIR/temp_gitlabTemplates
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev --output "$CI_PROJECT_DIR/temp_gitlabTemplates/optionsForCi.R"
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev --output "$CI_PROJECT_DIR/temp_gitlabTemplates/installDepsWithErrManagement.R"
     - >
       R -q -e '
         getwd()
-        source("temp_gitlabTemplates/optionsForCi.R");
-        source("temp_gitlabTemplates/installDepsWithErrManagement.R");
+        projDir <- Sys.getenv("CI_PROJECT_DIR")
+        source(file.path(projDir, "temp_gitlabTemplates/optionsForCi.R"));
+        source(file.path(projDir, "temp_gitlabTemplates/installDepsWithErrManagement.R"));
 
         optionsBackup <- setOptionsForCi();
 
-- 
GitLab


From ec07bd3c060ee7719acd7c5d0a44ae2b165674a1 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:45:16 +0200
Subject: [PATCH 07/29] Try force always artifacts for debug

---
 templates/templates-r.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index c8e260f..ef5c877 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -64,3 +64,7 @@
         options(optionsBackup)
         '
     - rm -rf temp_gitlabTemplates
+  artifacts:
+    paths:
+      - .
+    when: always
-- 
GitLab


From cf76b4806ed713d70a644922bd4993d3bd8e2395 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:47:56 +0200
Subject: [PATCH 08/29] Another try...

---
 templates/templates-r.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index ef5c877..3333b08 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -65,6 +65,4 @@
         '
     - rm -rf temp_gitlabTemplates
   artifacts:
-    paths:
-      - .
     when: always
-- 
GitLab


From f70df1b99f01b7298a4a5c3755fcc3205ffb2862 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Tue, 4 Oct 2022 18:50:22 +0200
Subject: [PATCH 09/29] Another try...

---
 templates/templates-r.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 3333b08..77dc0b0 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -39,6 +39,7 @@
       R -q -e '
         getwd()
         projDir <- Sys.getenv("CI_PROJECT_DIR")
+        print(projDir)
         source(file.path(projDir, "temp_gitlabTemplates/optionsForCi.R"));
         source(file.path(projDir, "temp_gitlabTemplates/installDepsWithErrManagement.R"));
 
@@ -65,4 +66,6 @@
         '
     - rm -rf temp_gitlabTemplates
   artifacts:
+    paths:
+      - temp_gitlabTemplates/
     when: always
-- 
GitLab


From 9928bcf4ca66b8ccca6c81be4bd348cb95039b40 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:22:00 +0200
Subject: [PATCH 10/29] Adjust paths

---
 templates/templates-r.yml | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 77dc0b0..4312763 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -32,16 +32,16 @@
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
     - apt update
     - apt install curl
-    - mkdir $CI_PROJECT_DIR/temp_gitlabTemplates
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev --output "$CI_PROJECT_DIR/temp_gitlabTemplates/optionsForCi.R"
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev --output "$CI_PROJECT_DIR/temp_gitlabTemplates/installDepsWithErrManagement.R"
+    - mkdir temp_gitlabTemplates
+    - cd temp_gitlabTemplates
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
+    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    - cd ..
     - >
       R -q -e '
         getwd()
-        projDir <- Sys.getenv("CI_PROJECT_DIR")
-        print(projDir)
-        source(file.path(projDir, "temp_gitlabTemplates/optionsForCi.R"));
-        source(file.path(projDir, "temp_gitlabTemplates/installDepsWithErrManagement.R"));
+        source("temp_gitlabTemplates/optionsForCi.R");
+        source("temp_gitlabTemplates/installDepsWithErrManagement.R");
 
         optionsBackup <- setOptionsForCi();
 
@@ -67,5 +67,5 @@
     - rm -rf temp_gitlabTemplates
   artifacts:
     paths:
-      - temp_gitlabTemplates/
+      - tests/
     when: always
-- 
GitLab


From 9dfd84270f8490395d8f41e058a359708db136b6 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:29:38 +0200
Subject: [PATCH 11/29] Try wget instead of curl (curl is bad for CI because it
 doesn't return an error code)

---
 templates/templates-r.yml | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 4312763..f50768c 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,12 +30,14 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
-    - apt update
-    - apt install curl
+    #- apt update
+    #- apt install curl
     - mkdir temp_gitlabTemplates
     - cd temp_gitlabTemplates
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
-    - curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    #- curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
+    #- curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
     - cd ..
     - >
       R -q -e '
-- 
GitLab


From e975e676ff9c4e35030a808b1f479fc03bed71a2 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:33:35 +0200
Subject: [PATCH 12/29] Correct web paths

---
 templates/templates-r.yml | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index f50768c..f6c3a4c 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,14 +30,10 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
-    #- apt update
-    #- apt install curl
     - mkdir temp_gitlabTemplates
     - cd temp_gitlabTemplates
-    #- curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
-    #- curl https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev
     - cd ..
     - >
       R -q -e '
-- 
GitLab


From 48a95f0f787e9122fb20a871dee5ec0592a07cff Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:38:38 +0200
Subject: [PATCH 13/29] Correct again paths!

---
 templates/templates-r.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index f6c3a4c..73a4ec8 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -31,10 +31,8 @@
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
     - mkdir temp_gitlabTemplates
-    - cd temp_gitlabTemplates
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev
-    - cd ..
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
+    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R
     - >
       R -q -e '
         getwd()
-- 
GitLab


From c393b0b8bc7d51e0e3937410423c756f2c110250 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:44:43 +0200
Subject: [PATCH 14/29] Retry with curl

---
 templates/templates-r.yml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 73a4ec8..e05a285 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,9 +30,16 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
+    - apt update
+    - apt install curl
     - mkdir temp_gitlabTemplates
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
-    - wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R
+    - cd temp_gitlabTemplates
+    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
+    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    - cd ..
+    #- mkdir temp_gitlabTemplates
+    #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
+    #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R
     - >
       R -q -e '
         getwd()
-- 
GitLab


From e2e628b1b7bd5e9a25693921e26057e13e8d0ebe Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 10:45:38 +0200
Subject: [PATCH 15/29] Retry with curl

---
 templates/templates-r.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index e05a285..9874188 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -34,8 +34,8 @@
     - apt install curl
     - mkdir temp_gitlabTemplates
     - cd temp_gitlabTemplates
-    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/optionsForCi.R?ref=dev
-    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R/installDepsWithErrManagement.R?ref=dev
+    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev
+    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev
     - cd ..
     #- mkdir temp_gitlabTemplates
     #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
-- 
GitLab


From 137e4fb6f1d988ac6083c9433a03a9647edeffef Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 11:13:03 +0200
Subject: [PATCH 16/29] Another try with wget, new web address to download
 files (not using bad Gitlab API !!!)

---
 templates/templates-r.yml | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 9874188..e29ea82 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,16 +30,17 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
-    - apt update
-    - apt install curl
+    #- apt update
+    #- apt install curl
     - mkdir temp_gitlabTemplates
-    - cd temp_gitlabTemplates
-    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev
-    - curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev
-    - cd ..
-    #- mkdir temp_gitlabTemplates
+    #- cd temp_gitlabTemplates
+    #- curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output temp_gitlabTemplates/optionsForCi.R
+    #- curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output temp_gitlabTemplates/installDepsWithErrManagement.R
+    #- cd ..
     #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
     #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R
+    - 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 '
         getwd()
-- 
GitLab


From bb0c68499d7bc3a7e6084a62829a8c012b4118bd Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 11:17:20 +0200
Subject: [PATCH 17/29] Use install_deps instead of install_dev_deps
 install_dev_deps seems to install "source" versions of packages and not the
 packages useful for dev!

---
 R/installDepsWithErrManagement.R | 4 ++--
 templates/templates-r.yml        | 8 --------
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index 965fc6f..9690f51 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -37,8 +37,8 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 install.packages(pkgs = "devtools", repos = repo)
                 install.packages(pkgs = "stringi", repos = repo)
 
-                devtools::install_dev_deps(dependencies = TRUE,
-                                           upgrade = "always")
+                devtools::install_deps(dependencies = TRUE,
+                                       upgrade = "always")
                 FALSE
             },
             error = function(e) {
diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index e29ea82..2430560 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -30,15 +30,7 @@
     TEST_ERROR: 0
   script:
     # Files other than yml must be download because Gitlab include keyworkd doesn't get it
-    #- apt update
-    #- apt install curl
     - mkdir temp_gitlabTemplates
-    #- cd temp_gitlabTemplates
-    #- curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output temp_gitlabTemplates/optionsForCi.R
-    #- curl --fail https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output temp_gitlabTemplates/installDepsWithErrManagement.R
-    #- cd ..
-    #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FoptionsForCi.R?ref=dev --output-document=temp_gitlabTemplates/optionsForCi.R
-    #- wget https://forgemia.inra.fr/api/v4/projects/6031/repository/files/R%2FinstallDepsWithErrManagement.R?ref=dev --output-document=temp_gitlabTemplates/installDepsWithErrManagement.R
     - 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
     - >
-- 
GitLab


From 27ccd14e5b402151a2e055fc48545eae0aaa392b Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 11:50:49 +0200
Subject: [PATCH 18/29] Revert previous commit + correct code error

---
 R/installDepsWithErrManagement.R | 4 ++--
 templates/templates-r.yml        | 6 +-----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index 9690f51..965fc6f 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -37,8 +37,8 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 install.packages(pkgs = "devtools", repos = repo)
                 install.packages(pkgs = "stringi", repos = repo)
 
-                devtools::install_deps(dependencies = TRUE,
-                                       upgrade = "always")
+                devtools::install_dev_deps(dependencies = TRUE,
+                                           upgrade = "always")
                 FALSE
             },
             error = function(e) {
diff --git a/templates/templates-r.yml b/templates/templates-r.yml
index 2430560..0bc1fe0 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -53,7 +53,7 @@
           }
         }
 
-        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")
         }
 
@@ -61,7 +61,3 @@
         options(optionsBackup)
         '
     - rm -rf temp_gitlabTemplates
-  artifacts:
-    paths:
-      - tests/
-    when: always
-- 
GitLab


From 2be8e30956222035f507f4d68e0fe5f28cd23a45 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 12:18:37 +0200
Subject: [PATCH 19/29] Remove warnings (which will be converted to errors and
 then stop execution, which is not expected)

---
 R/installDepsWithErrManagement.R | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index 965fc6f..20cd8d8 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -95,13 +95,13 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
         case_insensitive = FALSE)
     if (any(pbs)) {
         message <- "Some packages have not been installed"
-        warning(message)
+        message(message)
         allMessages <- paste0(allMessages, message)
         errorOccurs <- TRUE
     }
 
     if (errorOccurs) {
-        warning("Some error occurs in devtools::install_dev_deps call")
+        message("Some error occurs in devtools::install_dev_deps call")
     }
 
     return(list(errorOccurs = errorOccurs, allMessages = allMessages))
-- 
GitLab


From 21c158126d5d971c2df45d5bf82bc8736b85c9e8 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 13:27:43 +0200
Subject: [PATCH 20/29] Forgot some jobs' rules

---
 tests/.gitlab-ci-r-tests.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/.gitlab-ci-r-tests.yml b/tests/.gitlab-ci-r-tests.yml
index 0bdc9db..e15ea7b 100644
--- a/tests/.gitlab-ci-r-tests.yml
+++ b/tests/.gitlab-ci-r-tests.yml
@@ -12,6 +12,7 @@ Test R-install-package-dependencies-withCache Good:
       - .gitlab-ci-r-tests.yml
       - templates/templates-r.yml
       - tests/r-package
+      - R
   variables:
     TEST_ERROR: 0
   script:
@@ -27,6 +28,7 @@ Test R-install-package-dependencies-withCache Bad:
       - .gitlab-ci-r-tests.yml
       - templates/templates-r.yml
       - tests/r-package
+      - R
   variables:
     TEST_ERROR: 1
   script:
-- 
GitLab


From 3f9da6a66dd8f8ede6ae0263d1010025570c4863 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 13:32:38 +0200
Subject: [PATCH 21/29] Forgot change of some paths after moved tests files in
 subfolder

---
 tests/.gitlab-ci-checkers-tests.yml           | 20 +++++++++----------
 tests/.gitlab-ci-docker-tests.yml             | 12 +++++------
 ...itlab-ci-gitlab-package-registry-tests.yml |  6 +++---
 tests/.gitlab-ci-r-tests.yml                  |  4 ++--
 tests/.gitlab-ci-runner-tests.yml             | 10 +++++-----
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tests/.gitlab-ci-checkers-tests.yml b/tests/.gitlab-ci-checkers-tests.yml
index e1d4ae1..1dcf10b 100644
--- a/tests/.gitlab-ci-checkers-tests.yml
+++ b/tests/.gitlab-ci-checkers-tests.yml
@@ -13,7 +13,7 @@ Test check-find-linux Bad:
   rules:
     - changes:
       - .gitlab-ci.yml
-      - .gitlab-ci-checkers-tests.yml
+      - tests/.gitlab-ci-checkers-tests.yml
       - templates/templates-checkers.yml
       - tests/Checkers-find-test-bad.txt
   allow_failure: false
@@ -28,7 +28,7 @@ Test check-find-windows Bad:
   rules:
     - changes:
       - .gitlab-ci.yml
-      - .gitlab-ci-checkers-tests.yml
+      - tests/.gitlab-ci-checkers-tests.yml
       - templates/templates-checkers.yml
       - tests/Checkers-find-test-bad.txt
   allow_failure: false
@@ -41,7 +41,7 @@ Test check-find-linux Good:
   rules:
     - changes:
       - .gitlab-ci.yml
-      - .gitlab-ci-checkers-tests.yml
+      - tests/.gitlab-ci-checkers-tests.yml
       - templates/templates-checkers.yml
       - tests/Checkers-find-test-good.txt
   allow_failure: false
@@ -54,7 +54,7 @@ Test check-find-windows Good:
   rules:
     - changes:
       - .gitlab-ci.yml
-      - .gitlab-ci-checkers-tests.yml
+      - tests/.gitlab-ci-checkers-tests.yml
       - templates/templates-checkers.yml
       - tests/Checkers-find-test-good.txt
   allow_failure: false
@@ -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,7 +83,7 @@ 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." > tests/DummyFile
@@ -95,7 +95,7 @@ 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/tests/.gitlab-ci-docker-tests.yml b/tests/.gitlab-ci-docker-tests.yml
index cd8eaa6..d068374 100644
--- a/tests/.gitlab-ci-docker-tests.yml
+++ b/tests/.gitlab-ci-docker-tests.yml
@@ -19,7 +19,7 @@ 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
       - tests/Dockerfile-test-linux
@@ -36,7 +36,7 @@ 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
       - tests/Dockerfile-test-windows
@@ -55,7 +55,7 @@ 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
       - tests/Dockerfile-test-linux
@@ -73,7 +73,7 @@ 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
       - tests/Dockerfile-test-windows
@@ -92,7 +92,7 @@ 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
       - tests/Dockerfile-test-linux
@@ -110,7 +110,7 @@ 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
       - tests/Dockerfile-test-windows
diff --git a/tests/.gitlab-ci-gitlab-package-registry-tests.yml b/tests/.gitlab-ci-gitlab-package-registry-tests.yml
index 87ca1ec..a6c0685 100644
--- a/tests/.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/tests/.gitlab-ci-r-tests.yml b/tests/.gitlab-ci-r-tests.yml
index e15ea7b..1251607 100644
--- a/tests/.gitlab-ci-r-tests.yml
+++ b/tests/.gitlab-ci-r-tests.yml
@@ -9,7 +9,7 @@ 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
       - tests/r-package
       - R
@@ -25,7 +25,7 @@ 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
       - tests/r-package
       - R
diff --git a/tests/.gitlab-ci-runner-tests.yml b/tests/.gitlab-ci-runner-tests.yml
index 6cc5f92..05d002e 100644
--- a/tests/.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,7 +24,7 @@ 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:
@@ -34,7 +34,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
 # 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
-- 
GitLab


From 2450d6388d1f76b74d5d5f72d188f46562c28c2d Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 14:26:28 +0200
Subject: [PATCH 22/29] Adjust some runner tags (tags have changed on my
 Windows runners)

---
 tests/.gitlab-ci-docker-tests.yml | 6 +++---
 tests/.gitlab-ci-runner-tests.yml | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/.gitlab-ci-docker-tests.yml b/tests/.gitlab-ci-docker-tests.yml
index d068374..cc40e74 100644
--- a/tests/.gitlab-ci-docker-tests.yml
+++ b/tests/.gitlab-ci-docker-tests.yml
@@ -26,7 +26,7 @@ Test Docker Build and Push Linux:
 
 Test Docker Build and Push Windows:
   tags:
-    - windows-shell
+    - windows-cmd-shell
   variables:
     DOCKERFILE_PATH: tests/Dockerfile-test-windows
     CONTAINER_TAG: ${BASE_CONTAINER_TAG}-windows
@@ -62,7 +62,7 @@ Test Docker Push latest Linux:
 
 Test Docker Push latest Windows:
   tags:
-    - windows-shell
+    - windows-cmd-shell
   needs: ["Test Docker Build and Push Windows"]
   extends:
     - .gitlab-docker-registry-login-windows
@@ -99,7 +99,7 @@ Test Docker Push tag Linux:
 
 Test Docker Push tag Windows:
   tags:
-    - windows-shell
+    - windows-cmd-shell
   needs: ["Test Docker Build and Push Windows"]
   extends:
     - .gitlab-docker-registry-login-windows
diff --git a/tests/.gitlab-ci-runner-tests.yml b/tests/.gitlab-ci-runner-tests.yml
index 05d002e..ec20c70 100644
--- a/tests/.gitlab-ci-runner-tests.yml
+++ b/tests/.gitlab-ci-runner-tests.yml
@@ -28,7 +28,7 @@ Test Linux Docker Runner with dind:
 
 Test Windows Shell Runner:
   tags:
-    - windows-shell
+    - windows-cmd-shell
   script:
     - dir
   rules:
-- 
GitLab


From c2738935fc596697e439722b9c1a7a08d3107fa1 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 15:10:41 +0200
Subject: [PATCH 23/29] Change runners for windows-powershell (instead of
 windows-cmd-shell)

---
 tests/.gitlab-ci-docker-tests.yml | 6 +++---
 tests/.gitlab-ci-runner-tests.yml | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/.gitlab-ci-docker-tests.yml b/tests/.gitlab-ci-docker-tests.yml
index cc40e74..c828beb 100644
--- a/tests/.gitlab-ci-docker-tests.yml
+++ b/tests/.gitlab-ci-docker-tests.yml
@@ -26,7 +26,7 @@ Test Docker Build and Push Linux:
 
 Test Docker Build and Push Windows:
   tags:
-    - windows-cmd-shell
+    - windows-powershell
   variables:
     DOCKERFILE_PATH: tests/Dockerfile-test-windows
     CONTAINER_TAG: ${BASE_CONTAINER_TAG}-windows
@@ -62,7 +62,7 @@ Test Docker Push latest Linux:
 
 Test Docker Push latest Windows:
   tags:
-    - windows-cmd-shell
+    - windows-powershell
   needs: ["Test Docker Build and Push Windows"]
   extends:
     - .gitlab-docker-registry-login-windows
@@ -99,7 +99,7 @@ Test Docker Push tag Linux:
 
 Test Docker Push tag Windows:
   tags:
-    - windows-cmd-shell
+    - windows-powershell
   needs: ["Test Docker Build and Push Windows"]
   extends:
     - .gitlab-docker-registry-login-windows
diff --git a/tests/.gitlab-ci-runner-tests.yml b/tests/.gitlab-ci-runner-tests.yml
index ec20c70..172d64a 100644
--- a/tests/.gitlab-ci-runner-tests.yml
+++ b/tests/.gitlab-ci-runner-tests.yml
@@ -28,7 +28,7 @@ Test Linux Docker Runner with dind:
 
 Test Windows Shell Runner:
   tags:
-    - windows-cmd-shell
+    - windows-powershell
   script:
     - dir
   rules:
-- 
GitLab


From 8ebfecc28c5d51170fa596f95d6e6b6dbcc28425 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 16:20:34 +0200
Subject: [PATCH 24/29] Update README

---
 README.md | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 3b30f92..9dae1a2 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![main CI](https://forgemia.inra.fr/urep/dev_utils/gitlab-ci-templates/badges/main/pipeline.svg)](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,8 @@ 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 |
 
 ## Use the templates
 
@@ -18,17 +20,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
-- 
GitLab


From bc8fc52942dc56d6ef7f696861e529af68894cd4 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 17:38:43 +0200
Subject: [PATCH 25/29] Add some detailed documentation

---
 README.md                                     |  2 +
 docs/Descriptions.md                          | 94 +++++++++++++++++++
 templates/templates-checkers.yml              | 14 +--
 .../templates-gitlab-package-registry.yml     |  2 +-
 templates/templates-r.yml                     |  1 -
 tests/.gitlab-ci-checkers-tests.yml           |  8 +-
 6 files changed, 108 insertions(+), 13 deletions(-)
 create mode 100644 docs/Descriptions.md

diff --git a/README.md b/README.md
index 9dae1a2..bd1feed 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,8 @@ This repository contains useful Gitlab CI templates files.
 | [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
 
 1. Include the template file you want to use in you .gitlab-ci.yml (or subfile):
diff --git a/docs/Descriptions.md b/docs/Descriptions.md
new file mode 100644
index 0000000..f2045ea
--- /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 dd38f78..3778939 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 7e5a843..d301bf8 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 0bc1fe0..f769c17 100644
--- a/templates/templates-r.yml
+++ b/templates/templates-r.yml
@@ -57,7 +57,6 @@
           stop("An error is expected but none occurs")
         }
 
-        # Restore options
         options(optionsBackup)
         '
     - rm -rf temp_gitlabTemplates
diff --git a/tests/.gitlab-ci-checkers-tests.yml b/tests/.gitlab-ci-checkers-tests.yml
index 1dcf10b..37ab058 100644
--- a/tests/.gitlab-ci-checkers-tests.yml
+++ b/tests/.gitlab-ci-checkers-tests.yml
@@ -9,7 +9,7 @@ Test check-find-linux Bad:
     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
@@ -24,7 +24,7 @@ Test check-find-windows Bad:
     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
@@ -37,7 +37,7 @@ Test check-find-linux Good:
   variables:
     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
@@ -50,7 +50,7 @@ Test check-find-windows Good:
   variables:
     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


From 0e687f2a955edb82af974e3122d7a410053d2949 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 18:14:47 +0200
Subject: [PATCH 26/29] test...

---
 R/installDepsWithErrManagement.R | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index 20cd8d8..1229646 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -32,6 +32,7 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
 
                 repo <- "https://cloud.r-project.org"
                 update.packages(ask = FALSE, repos = repo)
+                stop("essai pour voir...")
 
                 # Install devtools and stringi packages which are used here
                 install.packages(pkgs = "devtools", repos = repo)
@@ -69,7 +70,8 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 install.packages(pkgs = "devtools", repos = repo)
                 install.packages(pkgs = "stringi", repos = repo)
 
-                devtools::install_dev_deps(dependencies = TRUE)
+                devtools::install_dev_deps(dependencies = TRUE,
+                                           upgrade = "always")
                 FALSE
             },
             error = function(e) {
-- 
GitLab


From 7be26b92a5ad9169abf7830cfd69657051818ee7 Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 18:18:59 +0200
Subject: [PATCH 27/29] Correct R tests rules

---
 tests/.gitlab-ci-r-tests.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/.gitlab-ci-r-tests.yml b/tests/.gitlab-ci-r-tests.yml
index 1251607..1597e44 100644
--- a/tests/.gitlab-ci-r-tests.yml
+++ b/tests/.gitlab-ci-r-tests.yml
@@ -11,8 +11,8 @@ Test R-install-package-dependencies-withCache Good:
       - .gitlab-ci.yml
       - tests/.gitlab-ci-r-tests.yml
       - templates/templates-r.yml
-      - tests/r-package
-      - R
+      - tests/r-package/*
+      - R/*
   variables:
     TEST_ERROR: 0
   script:
@@ -27,8 +27,8 @@ Test R-install-package-dependencies-withCache Bad:
       - .gitlab-ci.yml
       - tests/.gitlab-ci-r-tests.yml
       - templates/templates-r.yml
-      - tests/r-package
-      - R
+      - tests/r-package/*
+      - R/*
   variables:
     TEST_ERROR: 1
   script:
-- 
GitLab


From 5ea60923c00db7c84bb6bcbedc498803f21adb6a Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 18:28:26 +0200
Subject: [PATCH 28/29] test...

---
 R/installDepsWithErrManagement.R | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index 1229646..ae8786d 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -31,8 +31,7 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 sink(file = con, type = "message")
 
                 repo <- "https://cloud.r-project.org"
-                update.packages(ask = FALSE, repos = repo)
-                stop("essai pour voir...")
+                #update.packages(ask = FALSE, repos = repo)
 
                 # Install devtools and stringi packages which are used here
                 install.packages(pkgs = "devtools", repos = repo)
@@ -64,7 +63,7 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 sink(file = con, type = "message")
 
                 repo <- "https://cloud.r-project.org"
-                update.packages(ask = FALSE, repos = repo)
+                #update.packages(ask = FALSE, repos = repo)
 
                 # Install devtools and stringi packages which are used here
                 install.packages(pkgs = "devtools", repos = repo)
-- 
GitLab


From 16a4a72f725a74458949d1838ff529c291e44aee Mon Sep 17 00:00:00 2001
From: Astre Benjamin <benjamin.astre@inrae.fr>
Date: Wed, 5 Oct 2022 18:32:36 +0200
Subject: [PATCH 29/29] Remove force update of R packages Because this cost too
 many time with no current reason

---
 R/installDepsWithErrManagement.R | 2 --
 1 file changed, 2 deletions(-)

diff --git a/R/installDepsWithErrManagement.R b/R/installDepsWithErrManagement.R
index ae8786d..71ca165 100644
--- a/R/installDepsWithErrManagement.R
+++ b/R/installDepsWithErrManagement.R
@@ -31,7 +31,6 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 sink(file = con, type = "message")
 
                 repo <- "https://cloud.r-project.org"
-                #update.packages(ask = FALSE, repos = repo)
 
                 # Install devtools and stringi packages which are used here
                 install.packages(pkgs = "devtools", repos = repo)
@@ -63,7 +62,6 @@ installDepsWithErrManagement <- function(warningsAsErrors = FALSE,
                 sink(file = con, type = "message")
 
                 repo <- "https://cloud.r-project.org"
-                #update.packages(ask = FALSE, repos = repo)
 
                 # Install devtools and stringi packages which are used here
                 install.packages(pkgs = "devtools", repos = repo)
-- 
GitLab