diff --git a/.Rbuildignore b/.Rbuildignore index 813c77f7aa8bb2ecdaa062928c318f480a408012..c8b6d784046ef1ee436add1196937632ef9c3eb3 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,7 @@ ^README\.Rmd$ ^data-raw$ ^extdata$ +^\.gitlab-ci\.yml$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.gitignore b/.gitignore index 5b6a0652566d10360493952aec6d4a4febc77083..234f0289784f91ce7588b028bd72e1de86c1beb3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .Rhistory .RData .Ruserdata +docs diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..3d09efd48674523add2bde31f752e0b26d67eee3 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,114 @@ +image: rocker/geospatial:4.0.1 + +variables: + R_LIBS_USER: "ci/lib" + +cache: + key: global-cache + paths: + - ci/lib/ + +stages: + - build + - test + - pkgdown + - pkgdown-move + - deploy + +building: + stage: build + script: + - mkdir -p -m777 $R_LIBS_USER + - Rscript -e '.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()));remotes::install_deps(dependencies = TRUE, upgrade = "never")' + - Rscript -e '.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()));remotes::install_cran(c("pkgdown", "DT"), upgrade = "never")' + - Rscript -e '.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()));devtools::check()' + +# To have the coverage percentage appear as a gitlab badge follow these +# instructions: +# https://docs.gitlab.com/ee/user/project/pipelines/settings.html#test-coverage-parsing +# The coverage parsing string is +# Coverage: \d+\.\d+ + +coverage: + stage: test + allow_failure: true + when: on_success + only: + - master + - dev + - test-ci + script: + - Rscript -e '.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()));covr::gitlab(quiet = FALSE);' + artifacts: + paths: + - public + expire_in: 30 days + + +# To produce a code coverage report as a GitLab page see +# https://about.gitlab.com/2016/11/03/publish-code-coverage-report-with-gitlab-pages/ + + + +integration: + stage: pkgdown + allow_failure: true + when: on_success + only: + - master + - dev + - test-ci + script: + - Rscript -e '.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()));remotes::install_local();pkgdown::build_site()' + artifacts: + paths: + - docs + expire_in: 30 days + + +integration-dev: + stage: pkgdown-move + dependencies: + - integration + only: + - dev + script: + - wget https://gitlab.com/rdes_dreal/propre.artificialisation/-/jobs/artifacts/master/download?job=pages + - unzip -o download?job=pages + - rm download?job=pages + - mkdir -p public/dev + - cp -r docs/* public/dev + artifacts: + paths: + - public + expire_in: 30 days + +integration-master: + stage: pkgdown-move + dependencies: + - integration + only: + - master + script: + - wget https://gitlab.com/rdes_dreal/propre.artificialisation/-/jobs/artifacts/dev/download?job=pages + - unzip -o download?job=pages + - rm download?job=pages + - mkdir -p public + - cp -r docs/* public + artifacts: + paths: + - public + expire_in: 30 days + +pages: + stage: deploy + script: + - echo "deployment with cache ?" + artifacts: + paths: + - public + only: + - master + - dev + - test-ci + diff --git a/DESCRIPTION b/DESCRIPTION index 804ec5d6c9ff1852e56cd8c4262c37e93114ccf7..8af3f3fd83e271d34d968ec8ff76d076f4eb7022 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,3 +33,6 @@ Remotes: spyrales/gouvdown Depends: R (>= 2.10) +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000000000000000000000000000000000000..c72331d3af245a4d960eb47d5ede1d69f3fa30b4 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,3 @@ +template: + params: + bootswatch: flatly diff --git a/devstuff_history.R b/devstuff_history.R index ce48669b0db254eec50071ec3412e31b0008b5fb..d423d6b179a3d98cb79d0d47f7fef17c8f32b735 100644 --- a/devstuff_history.R +++ b/devstuff_history.R @@ -13,5 +13,7 @@ usethis::use_rmarkdown_template(template_name = "publication artificialisation", template_description = "Template Rmarkdown pour la publication sur l'artificialisation des sols en Pays de la Loire") usethis::use_data_raw("dataprep") usethis::use_build_ignore("extdata") - usethis::use_r("data") +usethis::use_build_ignore(".gitlab-ci.yml") +usethis::use_testthat() +usethis::use_test(name = "data") diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000000000000000000000000000000000000..d1d8e1c16812b3f1664e6223e2f01825445d5c88 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(propre.artificialisation) + +test_check("propre.artificialisation") diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R new file mode 100644 index 0000000000000000000000000000000000000000..96a70abc85b55e3d058788e048fbe7548fff8bf7 --- /dev/null +++ b/tests/testthat/test-data.R @@ -0,0 +1,3 @@ +test_that("chargement teruti fonctionne", { + expect_equal(nrow(teruti[1,]),1) +})