From f02141778570145c0b3467aa4e5d63c4ac93934a Mon Sep 17 00:00:00 2001 From: Astre Benjamin <benjamin.astre@inrae.fr> Date: Fri, 9 Dec 2022 15:14:31 +0100 Subject: [PATCH 1/2] =?UTF-8?q?#5=20:=20Oups=20j'avais=20oubli=C3=A9=20que?= =?UTF-8?q?=20j'avais=20comment=C3=A9=20le=20cache=20pour=20des=20tests=20?= =?UTF-8?q?!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/templates-r.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/templates/templates-r.yml b/templates/templates-r.yml index 583545a..254ff5c 100644 --- a/templates/templates-r.yml +++ b/templates/templates-r.yml @@ -40,12 +40,11 @@ include: - mkdir -p $R_LIBS_USER - ${R_RUN_CODE_COMMAND} '.libPaths()' - !reference [.R-default-globals, before_script] - # TODO temporary disabled for tests - # cache: - # - key: R-installed-packages-cache - # paths: - # - "${LOCAL_R_LIBS_USER}" - # policy: pull-push + cache: + - key: R-installed-packages-cache + paths: + - "${LOCAL_R_LIBS_USER}" + policy: pull-push # Update already installed R packages # It is recommended to run this before a package installation -- GitLab From 9cdefcce6daccd46579b3261a80ef9820c7f32ec Mon Sep 17 00:00:00 2001 From: Astre Benjamin <benjamin.astre@inrae.fr> Date: Fri, 9 Dec 2022 15:17:43 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Am=C3=A9liore=20les=20checks=20git=20et=20l?= =?UTF-8?q?es=20appels=20sur=20les=20jobs=20R?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/templates-checkers.yml | 23 ++++++++++++++--------- templates/templates-r.yml | 31 +++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/templates/templates-checkers.yml b/templates/templates-checkers.yml index a6040a8..aaa1cf3 100644 --- a/templates/templates-checkers.yml +++ b/templates/templates-checkers.yml @@ -46,9 +46,19 @@ - if ($hints) { exit ${FOUND_RETURN_CODE} } else { exit ${NOTFOUND_RETURN_CODE} } allow_failure: true +.check-git-changes-status-base: + variables: + CMD_UNCOMMITTED_CHANGES: 'if [[ -z "$(git status --untracked-files=no --porcelain=v1)" ]]; then exit ${EMPTY_RETURN_CODE}; exit ${NOTEMPTY_RETURN_CODE}; fi' + CMD_NOTMANAGED_CHANGES: 'if [[ -z "$(git status --untracked-files=all --porcelain=v1)" ]]; then exit ${EMPTY_RETURN_CODE}; exit ${NOTEMPTY_RETURN_CODE}; fi' + # For tests purposes + EMPTY_RETURN_CODE: 0 + NOTEMPTY_RETURN_CODE: 1 + # 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: + extends: + - .check-git-changes-status-base tags: - docker - stable @@ -56,27 +66,22 @@ name: alpine/git:v2.36.1 entrypoint: [""] variables: - # For tests purposes - EMPTY_RETURN_CODE: 0 - NOTEMPTY_RETURN_CODE: 1 script: - - if [[ -z "$(git status --untracked-files=no --porcelain=v1)" ]]; then exit ${EMPTY_RETURN_CODE}; exit ${NOTEMPTY_RETURN_CODE}; fi + - eval "${CMD_UNCOMMITTED_CHANGES}" allow_failure: true # 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: + extends: + - .check-git-changes-status-base tags: - docker - stable image: name: alpine/git:v2.36.1 entrypoint: [""] - variables: - # For tests purposes - FOUND_RETURN_CODE: 0 - NOTFOUND_RETURN_CODE: 1 script: - - if [[ -z "$(git status --untracked-files=all --porcelain=v1)" ]]; then exit ${EMPTY_RETURN_CODE}; exit ${NOTEMPTY_RETURN_CODE}; fi + - eval "${CMD_NOTMANAGED_CHANGES}" allow_failure: true diff --git a/templates/templates-r.yml b/templates/templates-r.yml index 254ff5c..88da720 100644 --- a/templates/templates-r.yml +++ b/templates/templates-r.yml @@ -129,7 +129,7 @@ include: - .R-default-globals - .R-package-cache - .R-update-packages - - .check-git-notmanaged-changes + - .check-git-changes-status-base script: - cd ${R_PACKAGE_ROOT_ABSOLUTE_PATH} - !reference [.R-update-packages, script] @@ -146,7 +146,8 @@ include: source(file.path(Sys.getenv("CI_PROJECT_DIR"), "temp_gitlabTemplates", "optionsForCi.R")); setOptionsForCi(); devtools::document() ' - - !reference [.check-git-notmanaged-changes, script] + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" allow_failure: false # In case a README.Rmd is used, then a README.md must be manually generated. @@ -160,7 +161,7 @@ include: - .R-default-globals - .R-package-cache - .R-update-packages - - .check-git-notmanaged-changes + - .check-git-changes-status-base script: - cd ${R_PACKAGE_ROOT_ABSOLUTE_PATH} - !reference [.R-update-packages, script] @@ -177,7 +178,8 @@ include: source(file.path(Sys.getenv("CI_PROJECT_DIR"), "temp_gitlabTemplates", "optionsForCi.R")); setOptionsForCi(); devtools::build_readme() ' - - !reference [.check-git-notmanaged-changes, script] + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" allow_failure: false # Run the standard R devtools check() function @@ -190,6 +192,7 @@ include: - .R-default-globals - .R-package-cache - .R-install-package-dependencies-withCache + - .check-git-changes-status-base variables: # Set to "TRUE" check if the license is a valid standard open source license. # Set to "FALSE" to not doing anty check on the license. @@ -233,6 +236,8 @@ include: } } ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" # Run the tests .R-run-tests: @@ -244,6 +249,7 @@ include: - .R-default-globals - .R-package-cache - .R-install-package-dependencies-withCache + - .check-git-changes-status-base variables: # For tests purposes (0 or 1 (other values same as 0)) ERROR_EXPECTED: 0 @@ -278,6 +284,8 @@ include: } } ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" # Run the tests with code coverage # The code coverage results are available in three forms: @@ -293,6 +301,7 @@ include: - .R-default-globals - .R-package-cache - .R-install-package-dependencies-withCache + - .check-git-changes-status-base variables: # For tests purposes (0 or 1 (other values same as 0)) ERROR_EXPECTED: 0 @@ -345,6 +354,8 @@ include: print("End script...") ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" coverage: '/Coverage: \d+\.\d+/' artifacts: paths: @@ -367,6 +378,7 @@ include: - .R-default-globals - .R-package-cache - .R-update-packages + - .check-git-changes-status-base variables: # For tests purposes (0 or 1 (other values same as 0)) ERROR_EXPECTED: 0 @@ -398,6 +410,8 @@ include: } } ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" .R-generate-doc-website: image: rocker/tidyverse @@ -408,6 +422,7 @@ include: - .R-default-globals - .R-package-cache - .R-update-packages + - .check-git-changes-status-base variables: # For tests purposes (0 or 1 (other values same as 0)) ERROR_EXPECTED: 0 @@ -450,6 +465,8 @@ include: } } ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" artifacts: paths: - ${R_PACKAGE_ROOT_RELATIVE_PATH}/docs/* @@ -463,6 +480,7 @@ include: - .R-default-globals - .R-package-cache - .R-install-package-dependencies-withCache + - .check-git-changes-status-base script: - cd ${R_PACKAGE_ROOT_ABSOLUTE_PATH} - !reference [.R-install-package-dependencies-withCache, script] @@ -474,6 +492,8 @@ include: source(file.path(Sys.getenv("CI_PROJECT_DIR"), "temp_gitlabTemplates", "optionsForCi.R")); setOptionsForCi(); devtools::build(path = file.path(Sys.getenv("R_PACKAGE_ROOT_ABSOLUTE_PATH"), "build"), binary = FALSE) ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" when: manual artifacts: paths: @@ -488,6 +508,7 @@ include: - .R-default-globals - .R-package-cache - .R-install-package-dependencies-withCache + - .check-git-changes-status-base script: - cd ${R_PACKAGE_ROOT_ABSOLUTE_PATH} - !reference [.R-install-package-dependencies-withCache, script] @@ -499,6 +520,8 @@ include: source(file.path(Sys.getenv("CI_PROJECT_DIR"), "temp_gitlabTemplates", "optionsForCi.R")); setOptionsForCi(); devtools::build(path = file.path(Sys.getenv("R_PACKAGE_ROOT_ABSOLUTE_PATH"), "build", "bin"), binary = TRUE) ' + - echo "Checking if all is correctly managed with git (no versioned item modified, no not versioned item, etc)..." + - eval "${CMD_NOTMANAGED_CHANGES}" when: manual artifacts: paths: -- GitLab