From 9d2507fa07adc9d78e4b6a65dbda89fa6a3e68ee Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@inrae.fr>
Date: Tue, 27 Jul 2021 16:56:26 +0200
Subject: [PATCH] ci: add check and pkgdown website generation

---
 .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++
 _pkgdown.yml   | 22 ++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 _pkgdown.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..f06560e
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,40 @@
+stages:
+    - check
+    - website
+
+default:
+  tags: [docker]
+
+image: rocker/tidyverse:4.0.5
+
+variables:
+  R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib"
+  CHECK_DIR: "$CI_PROJECT_DIR/ci/logs"
+  BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs/$CI_PROJECT_NAME.Rcheck"
+
+cache:
+  paths:
+    - $R_LIBS_USER
+
+before_script:
+  - mkdir -p $R_LIBS_USER $BUILD_LOGS_DIR
+  - echo "R_LIBS='$R_LIBS_USER'" > .Renviron
+  - R -e 'devtools::install_deps(dep = T)'
+
+check:
+  stage: check
+  script:
+    - if [[ $NOT_CRAN == "false" ]]; then sudo apt-get update && sudo apt-get install -y qpdf; fi
+    - R -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning")'
+
+website:
+  stage: website
+  only:
+    - master
+    - dev
+    - tags
+  script:
+    - R -e 'devtools::update_packages(packages = "pkgdown")'
+    - R -e 'pkgdown::build_site()'
+    - sudo apt-get update && sudo apt-get install -y sshpass rsync
+    - sshpass -p "${OVH_PASS}" rsync -a -e "ssh -o StrictHostKeyChecking=no" docs/ ${OVH_LOGIN}@${OVH_SFTP}:/home/${OVH_LOGIN}/in-wop/bnpe/
diff --git a/_pkgdown.yml b/_pkgdown.yml
new file mode 100644
index 0000000..1ac320b
--- /dev/null
+++ b/_pkgdown.yml
@@ -0,0 +1,22 @@
+url: https://in-wop.g-eau.fr/bnpe
+development:
+  mode: unreleased
+
+template:
+  params:
+    bootswatch: flatly
+
+navbar:
+  structure:
+    right: [gitlab]
+  components:
+    github: ~
+    gitlab:
+      icon: fab fa-gitlab fa-lg
+      href: https://gitlab.irstea.fr/in-wop/bnpe
+
+repo:
+  url:
+    home: https://gitlab.irstea.fr/in-wop/bnpe/
+    source: https://gitlab.irstea.fr/in-wop/bnpe/-/blob/master/
+    issue: https://gitlab.irstea.fr/in-wop/bnpe/-/issues/
-- 
GitLab