From a3e6c49ae4d57daaf69e92520f66fdc006163f08 Mon Sep 17 00:00:00 2001 From: Els Lommelen Date: Fri, 18 Mar 2022 16:50:35 +0100 Subject: [PATCH 01/64] first test setup docker --- .dockerignore | 5 ++ Dockerfile | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 44 ++++++++++++++++ render.R | 1 + 4 files changed, 193 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 entrypoint.sh create mode 100755 render.R diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9cd7a9ca --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.Rproj.user +publish +src +renv/library diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..40291b88 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,143 @@ +FROM ubuntu:20.04 + +ARG BUILD_DATE +ARG VCS_REF +LABEL org.label-schema.build-date=$BUILD_DATE \ +org.label-schema.name="RStable" \ +org.label-schema.description="A docker image with stable versions of R and a bunch of packages used to calculate indicators." \ +org.label-schema.license="MIT" \ +org.label-schema.url="e.g. https://www.inbo.be/" \ +org.label-schema.vcs-ref=$VCS_REF \ +org.label-schema.vcs-url="https://github.com/inbo/protocolsource" \ +org.label-schema.vendor="Research Institute for Nature and Forest" \ +maintainer="Hans Van Calster " + +## for apt to be noninteractive +ENV DEBIAN_FRONTEND noninteractive +ENV DEBCONF_NONINTERACTIVE_SEEN true + +## Set a default user. Available via runtime flag `--user docker` +## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library +## User should also have & own a home directory (for rstudio or linked volumes to work properly). +RUN useradd docker \ + && mkdir /home/docker \ + && chown docker:docker /home/docker \ + && addgroup docker staff + +## Configure default locale, see https://github.com/rocker-org/rocker/issues/19 +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + locales \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen nl_BE.utf8 \ + && /usr/sbin/update-locale LANG=nl_BE.UTF-8 + +ENV LC_ALL nl_BE.UTF-8 +ENV LANG nl_BE.UTF-8 + +## Add apt-get repositories for R +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gnupg \ + ca-certificates \ + && sh -c 'echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" >> /etc/apt/sources.list' \ + && gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \ + && gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - + +## Install R base +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + r-base-core=4.1.0-1.2004.0 \ + r-base-dev=4.1.0-1.2004.0 \ + r-cran-boot=1.3-28-1cran1.2004.0 \ + r-cran-class=7.3-19-1.2004.0 \ + r-cran-cluster=2.1.2-1.2004.0 \ + r-cran-codetools=0.2-18-1cran1.2004.0 \ + r-cran-foreign=0.8.81-1.2004.0 \ + r-cran-kernsmooth=2.23-20-1cran1.2004.0 \ + r-cran-lattice=0.20-44-1cran2~ubuntu20.04.1~ppa1 \ + r-cran-mass=7.3-54-1.2004.0 \ + r-cran-matrix=1.3-3-1.2004.0 \ + r-cran-mgcv=1.8-35-1cran1.2004.0 \ + r-cran-nlme=3.1.152-1.2004.0 \ + r-cran-nnet=7.3-16-1.2004.0 \ + r-cran-rpart=4.1-15-2focal0 \ + r-cran-spatial=7.3-11-2focal0 \ + r-cran-survival=3.2-11-1cran1.2004.0 \ + r-recommended=4.1.0-1.2004.0 + +## Install wget +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + wget + +## Install pandoc +RUN wget https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb \ + && dpkg -i pandoc-2.7.3-1-amd64.deb \ + && rm pandoc-2.7.3-1-amd64.deb + +## Install git +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + git \ + openssh-client + +## Install curl dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev + +## Install ggplot2 dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libfreetype6-dev + +## Install rgdal dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gdal-bin \ + libgdal-dev \ + libproj-dev \ + proj-bin + +## Install openssl dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libssl-dev + +## Install systemfonts dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libfontconfig1-dev + +## Install textshaping dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libharfbuzz-dev libfribidi-dev + +## Install utils dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libudunits2-dev + +## Install V8 dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libv8-dev + +## Install xml2 dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libxml2-dev + +WORKDIR /github/workspace + +RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" +RUN R -e "renv::consent(provided = TRUE)" +COPY renv.lock renv.lock +RUN R -e "renv::restore()" +RUN R -e "renv::isolate()" + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..a4c64876 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,44 @@ +#!/bin/sh -l + +echo '\nGetting the code...\n' +git clone --quiet https://$2@github.com/$1 /render +cd /render +git config advice.detachedHead false +if [ $3 -eq 0 ] ; then + echo 'Checking out '$GITHUB_SHA'...\n' + git checkout $GITHUB_SHA +else + echo 'Checking out main...\n' + git checkout main +fi +cp -r /render/. $GITHUB_WORKSPACE +cd $GITHUB_WORKSPACE +echo 'Rendering the Rmarkdown files...\n' +rm .Rprofile +Rscript "render.R" +if [ $? -ne 0 ]; then + echo '\nRendering failed. Please check the error message above.\n'; + exit 1 +fi +echo '\nAll Rmarkdown files rendered successfully\n' + +if [ $3 -eq 0 ]; then + echo 'Done.\n' + exit 0 +fi + +echo 'Publishing the rendered files...\n' +git clone --branch=publish https://$2@github.com/$1 /publish +git config --global user.email "info@inbo.be" +git config --global user.name "INBO" +cd /publish +git rm -r . +cp -R $GITHUB_WORKSPACE/publish/. . +if ! git diff-index --quiet HEAD --; then + git add --all + git commit --amend --message="Te publiceren versie van de NARA-2020 achtergronddocumenten" + git push -f + echo '\nNew version published...' +else + echo '\nNothing to update...' +fi diff --git a/render.R b/render.R new file mode 100755 index 00000000..6661b3bd --- /dev/null +++ b/render.R @@ -0,0 +1 @@ +protocolhelper::render_release() From f9f2276fa4f36ce6273be2cb9f880ded6162f8ac Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Fri, 1 Apr 2022 17:53:58 +0200 Subject: [PATCH 02/64] operational docker workflow (locally) --- entrypoint.sh | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a4c64876..d2f86a88 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,10 @@ #!/bin/sh -l echo '\nGetting the code...\n' -git clone --quiet https://$2@github.com/$1 /render +git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_SOURCE /render cd /render -git config advice.detachedHead false -if [ $3 -eq 0 ] ; then - echo 'Checking out '$GITHUB_SHA'...\n' - git checkout $GITHUB_SHA -else - echo 'Checking out main...\n' - git checkout main -fi -cp -r /render/. $GITHUB_WORKSPACE -cd $GITHUB_WORKSPACE +git checkout $BRANCH_SOURCE + echo 'Rendering the Rmarkdown files...\n' rm .Rprofile Rscript "render.R" @@ -22,23 +14,19 @@ if [ $? -ne 0 ]; then fi echo '\nAll Rmarkdown files rendered successfully\n' -if [ $3 -eq 0 ]; then - echo 'Done.\n' - exit 0 -fi - echo 'Publishing the rendered files...\n' -git clone --branch=publish https://$2@github.com/$1 /publish +git clone --quiet --depth=1 --single-branch --branch=main https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST /destiny git config --global user.email "info@inbo.be" git config --global user.name "INBO" -cd /publish -git rm -r . -cp -R $GITHUB_WORKSPACE/publish/. . -if ! git diff-index --quiet HEAD --; then - git add --all - git commit --amend --message="Te publiceren versie van de NARA-2020 achtergronddocumenten" - git push -f - echo '\nNew version published...' -else - echo '\nNothing to update...' -fi + +cp -R /render/publish/. /destiny/. +cd /destiny +ls -a + +git config user.name +git config user.email +git add --all +git commit --message="Nieuwe protocollen toegevoegd" +git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST + +echo '\nNew version published...' From 54591b15e15d71c55041f10253ad323d664a35b5 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 5 Apr 2022 17:13:21 +0200 Subject: [PATCH 03/64] rename entrypoint.sh to allow a 2nd docker to be added --- Dockerfile | 4 +-- docker/entrypoint_check.sh | 31 +++++++++++++++++++ entrypoint.sh => docker/entrypoint_website.sh | 0 render.R => docker/render.R | 0 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100755 docker/entrypoint_check.sh rename entrypoint.sh => docker/entrypoint_website.sh (100%) rename render.R => docker/render.R (100%) diff --git a/Dockerfile b/Dockerfile index 40291b88..64f4af2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -138,6 +138,6 @@ COPY renv.lock renv.lock RUN R -e "renv::restore()" RUN R -e "renv::isolate()" -COPY entrypoint.sh /entrypoint.sh +COPY docker/entrypoint_website.sh /entrypoint_website.sh -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/entrypoint_website.sh"] diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh new file mode 100755 index 00000000..8e4074bf --- /dev/null +++ b/docker/entrypoint_check.sh @@ -0,0 +1,31 @@ +#!/bin/sh -l + +echo '\nGetting the code...\n' +git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check +cd check +git checkout $BRANCH_SOURCE +ls -a +rm .Rprofile + +echo '\nDoing checklist tests...\n' +Rscript --no-save --no-restore -e 'checklist::check_source(protocolhelper:::get_path_to_protocol("'$PROTOCOL_CODE'"))' +if [ $? -ne 0 ]; then + echo '\nThe source code failed some checklist checks. Please check the error message above.\n'; +fi + +echo '\nChecking frontmatter...\n' +Rscript "docker\check_all.R" +Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' +if [ $? -ne 0 ]; then + echo '\nThe source code failed some checks. Please check the error message above.\n'; + exit 1 +fi + +echo '\nChecking document structure...\n' +#Rscript --no-save --no-restore -e 'protocolhelper::check_structure("'$PROTOCOL_CODE'"")' +if [ $? -ne 0 ]; then + echo '\nThe source code failed some structure checks. Please check the error message above.\n'; + exit 1 +fi + +#nog aanpass diff --git a/entrypoint.sh b/docker/entrypoint_website.sh similarity index 100% rename from entrypoint.sh rename to docker/entrypoint_website.sh diff --git a/render.R b/docker/render.R similarity index 100% rename from render.R rename to docker/render.R From f5d52b84eef4ad4bf41530a0921eea9a13569323 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 5 Apr 2022 17:17:15 +0200 Subject: [PATCH 04/64] add docker with checks --- Dockerfile | 1 + docker/check_all.R | 7 +++++++ docker/entrypoint_check.sh | 17 +---------------- 3 files changed, 9 insertions(+), 16 deletions(-) create mode 100644 docker/check_all.R diff --git a/Dockerfile b/Dockerfile index 64f4af2e..8f64493b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -139,5 +139,6 @@ RUN R -e "renv::restore()" RUN R -e "renv::isolate()" COPY docker/entrypoint_website.sh /entrypoint_website.sh +COPY docker/entrypoint_check.sh /entrypoint_check.sh ENTRYPOINT ["/entrypoint_website.sh"] diff --git a/docker/check_all.R b/docker/check_all.R new file mode 100644 index 00000000..e1de5307 --- /dev/null +++ b/docker/check_all.R @@ -0,0 +1,7 @@ +# bundled checks for protocols + +check_all <- function(protocol_code) { + sapply(protocol_code, protocolhelper::check_frontmatter) + #sapply(protocolcode, protocolhelper::check_structure) + return(invisible(protocol_code)) +} diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 8e4074bf..e20aab43 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -7,25 +7,10 @@ git checkout $BRANCH_SOURCE ls -a rm .Rprofile -echo '\nDoing checklist tests...\n' -Rscript --no-save --no-restore -e 'checklist::check_source(protocolhelper:::get_path_to_protocol("'$PROTOCOL_CODE'"))' -if [ $? -ne 0 ]; then - echo '\nThe source code failed some checklist checks. Please check the error message above.\n'; -fi - -echo '\nChecking frontmatter...\n' +echo '\nChecking protocols specific tests...\n' Rscript "docker\check_all.R" Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; exit 1 fi - -echo '\nChecking document structure...\n' -#Rscript --no-save --no-restore -e 'protocolhelper::check_structure("'$PROTOCOL_CODE'"")' -if [ $? -ne 0 ]; then - echo '\nThe source code failed some structure checks. Please check the error message above.\n'; - exit 1 -fi - -#nog aanpass From 7407dafce367ce834cc5c28376c6524c990cdb82 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 5 Apr 2022 17:19:39 +0200 Subject: [PATCH 05/64] correct path to render.R --- docker/entrypoint_website.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint_website.sh b/docker/entrypoint_website.sh index d2f86a88..c01e75b5 100755 --- a/docker/entrypoint_website.sh +++ b/docker/entrypoint_website.sh @@ -7,7 +7,7 @@ git checkout $BRANCH_SOURCE echo 'Rendering the Rmarkdown files...\n' rm .Rprofile -Rscript "render.R" +Rscript "docker/render.R" if [ $? -ne 0 ]; then echo '\nRendering failed. Please check the error message above.\n'; exit 1 From 06efd534ac17ae437275496c25aaf26d34a7d29f Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 5 Apr 2022 17:22:53 +0200 Subject: [PATCH 06/64] point Dockerfile to new docker --- Dockerfile | 2 +- docker/entrypoint_check.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f64493b..ae1dc300 100644 --- a/Dockerfile +++ b/Dockerfile @@ -141,4 +141,4 @@ RUN R -e "renv::isolate()" COPY docker/entrypoint_website.sh /entrypoint_website.sh COPY docker/entrypoint_check.sh /entrypoint_check.sh -ENTRYPOINT ["/entrypoint_website.sh"] +ENTRYPOINT ["/entrypoint_check.sh"] diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index e20aab43..66eedc4a 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -8,7 +8,7 @@ ls -a rm .Rprofile echo '\nChecking protocols specific tests...\n' -Rscript "docker\check_all.R" +Rscript "docker/check_all.R" Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; From 0d7622127004a1c9fa6d2fdc3f98115620206c21 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 5 Apr 2022 17:28:58 +0200 Subject: [PATCH 07/64] move function from .sh to .R --- docker/check_all.R | 1 + docker/entrypoint_check.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index e1de5307..b4eea5ac 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -5,3 +5,4 @@ check_all <- function(protocol_code) { #sapply(protocolcode, protocolhelper::check_structure) return(invisible(protocol_code)) } +check_all(Sys.getenv("PROTOCOL_CODE")) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 66eedc4a..bcaa757a 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -9,7 +9,6 @@ rm .Rprofile echo '\nChecking protocols specific tests...\n' Rscript "docker/check_all.R" -Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; exit 1 From 239b41d0497eb2fc3d4907a5605056ed3ba013a0 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 6 Apr 2022 10:56:48 +0200 Subject: [PATCH 08/64] try solving loadnamespace problem --- docker/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index b4eea5ac..21600d56 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,5 +1,5 @@ # bundled checks for protocols - +library(protocolhelper) check_all <- function(protocol_code) { sapply(protocol_code, protocolhelper::check_frontmatter) #sapply(protocolcode, protocolhelper::check_structure) From 9aada041fa27412936421cf02808c25d4ea6d6b1 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 6 Apr 2022 16:59:59 +0200 Subject: [PATCH 09/64] .Rprofile gives problems with loadNamespace --- docker/entrypoint_check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index bcaa757a..7746a45c 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -8,6 +8,7 @@ ls -a rm .Rprofile echo '\nChecking protocols specific tests...\n' +rm .Rprofile Rscript "docker/check_all.R" if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; From 420a7f65f3f99adee6b3b721e3400ff5ab6b58e6 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 6 Apr 2022 17:00:33 +0200 Subject: [PATCH 10/64] check if branch is up to date with main --- docker/entrypoint_check.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 7746a45c..dbc2b894 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -7,7 +7,20 @@ git checkout $BRANCH_SOURCE ls -a rm .Rprofile +echo '\nChecking if branch is up to date with main...\n' +main_in_branch=$(git merge-base $BRANCH_SOURCE main) +echo $main_in_branch +git checkout main +git pull +head_main=$(git rev-parse HEAD) +echo $head_main +if [ $main_in_branch != $head_main ]; then + echo '\nThis branch does not contain the latest version of the main branch. Please merge the main branch into this branch first\n'; + exit 1 +fi + echo '\nChecking protocols specific tests...\n' +git checkout $BRANCH_SOURCE rm .Rprofile Rscript "docker/check_all.R" if [ $? -ne 0 ]; then From c3fbb34dbe14c3753a275b72ef56e52d0865c09e Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 13:38:44 +0200 Subject: [PATCH 11/64] correct date in testprotocol --- .../4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd index 716649a5..6be92f0d 100644 --- a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd +++ b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd @@ -4,7 +4,7 @@ subtitle: author: - name: Els De Bie orcid: 0000-0001-7679-743X -date: "`r Sys.Date()`" +date: "2022-07-18" reviewers: [Hans Van Calster,Lieve Vriens,Jan Wouters,Wouter Van Gompel,Els Lommelen] file_manager: Hans Van Calster protocol_code: sfp-401-nl From 9e8ad681a307691d983e8f6b4e01f96de510a198 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 14:17:40 +0200 Subject: [PATCH 12/64] test check_structure() instead of check_frontmatter() --- docker/check_all.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 21600d56..d6ae1cdc 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,8 +1,9 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - sapply(protocol_code, protocolhelper::check_frontmatter) - #sapply(protocolcode, protocolhelper::check_structure) - return(invisible(protocol_code)) + stop("Test-error") + #sapply(protocol_code, protocolhelper::check_frontmatter) + #sapply(protocol_code, protocolhelper::check_structure) + #return(invisible(protocol_code)) } check_all(Sys.getenv("PROTOCOL_CODE")) From cb63ddbcae4cccef3a70bedc23e4a30b96fbfc89 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 15:04:04 +0200 Subject: [PATCH 13/64] new test check_structure() --- docker/check_all.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index d6ae1cdc..8d7d41bb 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,9 +1,8 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - stop("Test-error") #sapply(protocol_code, protocolhelper::check_frontmatter) - #sapply(protocol_code, protocolhelper::check_structure) + sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) } check_all(Sys.getenv("PROTOCOL_CODE")) From 97fe1aa6874295dd49e20e3386b83e75a8ef0505 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 17:05:19 +0200 Subject: [PATCH 14/64] check_frontmatter terug toevoegen --- docker/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index 8d7d41bb..b6f45ef4 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,7 +1,7 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - #sapply(protocol_code, protocolhelper::check_frontmatter) + sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) } From a92f284c950dbf3ddee7e486f6ba150c7435bf12 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 17:05:48 +0200 Subject: [PATCH 15/64] overbodige code in commentaar zetten --- docker/entrypoint_check.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index dbc2b894..a3fece60 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -7,21 +7,21 @@ git checkout $BRANCH_SOURCE ls -a rm .Rprofile -echo '\nChecking if branch is up to date with main...\n' -main_in_branch=$(git merge-base $BRANCH_SOURCE main) -echo $main_in_branch -git checkout main -git pull -head_main=$(git rev-parse HEAD) -echo $head_main -if [ $main_in_branch != $head_main ]; then - echo '\nThis branch does not contain the latest version of the main branch. Please merge the main branch into this branch first\n'; - exit 1 -fi +#echo '\nChecking if branch is up to date with main...\n' +#main_in_branch=$(git merge-base $BRANCH_SOURCE main) +#echo $main_in_branch +#git checkout main +#git pull +#head_main=$(git rev-parse HEAD) +#echo $head_main +#if [ $main_in_branch != $head_main ]; then +# echo '\nThis branch does not contain the latest version of the main branch. Please merge the main branch into this branch first\n'; +# exit 1 +#fi echo '\nChecking protocols specific tests...\n' -git checkout $BRANCH_SOURCE -rm .Rprofile +#git checkout $BRANCH_SOURCE +#rm .Rprofile Rscript "docker/check_all.R" if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; From bdf28e218f01bf2dd923e2596fc96b8c37bacc3f Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 17:06:40 +0200 Subject: [PATCH 16/64] rename message protocol website to English --- docker/entrypoint_website.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint_website.sh b/docker/entrypoint_website.sh index c01e75b5..edb1c643 100755 --- a/docker/entrypoint_website.sh +++ b/docker/entrypoint_website.sh @@ -26,7 +26,7 @@ ls -a git config user.name git config user.email git add --all -git commit --message="Nieuwe protocollen toegevoegd" +git commit --message="Add new protocol" git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST echo '\nNew version published...' From 78ddebe94aac9f05ef6b5f5b368f82e9fa63efd9 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 17:15:48 +0200 Subject: [PATCH 17/64] voorlopige versies pushen om lege wd te hebben --- .github/workflows/check_branch.yml | 19 ++++++++++++++++++ .github/workflows/release.yml | 30 ++++++++++++++++++++++++++++ .github/workflows/update-website.yml | 18 +++++++++++++++++ Dockerfile | 1 + build_push.sh | 21 +++++++++++++++++++ docker/entrypoint_update.sh | 24 ++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 .github/workflows/check_branch.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update-website.yml create mode 100644 build_push.sh create mode 100644 docker/entrypoint_update.sh diff --git a/.github/workflows/check_branch.yml b/.github/workflows/check_branch.yml new file mode 100644 index 00000000..5ca6b3d8 --- /dev/null +++ b/.github/workflows/check_branch.yml @@ -0,0 +1,19 @@ +name: Check the protocol on pull request + +on: + pull_request: + types: [synchronize, opened, reopened, edited] #en zie https://github.community/t/rerun-on-base-branch-change/115594 + branches: + - main + +jobs: + check-protocol: + runs-on: ubuntu-latest + name: "check protocol" + env: + GITHUB_PAT: ${{ secrets.PAT }} + steps: + - name: Check protocol + uses: inbo/actions/xxx@xxx + with: + token: ${{ secrets.PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7724c860 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +on: + push: + tags: + - 'protocols-****.**' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Get tag message + run: | + TAG_BODY=$(git tag --contains ${{ github.sha }} -n100 | awk '(NR>1)') + echo "::set-output name=TAG_BODY::$TAG_BODY" + id: tag-body + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: ${{ steps.tag-body.outputs.TAG_BODY }} + draft: false + prerelease: false diff --git a/.github/workflows/update-website.yml b/.github/workflows/update-website.yml new file mode 100644 index 00000000..cca2e923 --- /dev/null +++ b/.github/workflows/update-website.yml @@ -0,0 +1,18 @@ +name: On merge to main, build the protocol and add it to the website + +on: + push: + branches: + - main + +jobs: + build-website: + runs-on: ubuntu-latest + name: "add protocol to website" + env: + GITHUB_PAT: ${{ secrets.PAT }} + steps: + - name: Checkout repo + uses: inbo/actions/xxx@xxx + with: + token: ${{ secrets.PAT }} diff --git a/Dockerfile b/Dockerfile index ae1dc300..26bc3dfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -139,6 +139,7 @@ RUN R -e "renv::restore()" RUN R -e "renv::isolate()" COPY docker/entrypoint_website.sh /entrypoint_website.sh +COPY docker/entrypoint_update.sh /entrypoint_update.sh COPY docker/entrypoint_check.sh /entrypoint_check.sh ENTRYPOINT ["/entrypoint_check.sh"] diff --git a/build_push.sh b/build_push.sh new file mode 100644 index 00000000..8e3cc2f4 --- /dev/null +++ b/build_push.sh @@ -0,0 +1,21 @@ +docker build --no-cache --tag=inbobmk/checklist . + +docker build --tag=inbobmk/checklist . + +docker push inbobmk/checklist + +# run on branch +docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git rev-parse HEAD) --env INPUT_TOKEN=$GITHUB_PAT --env INPUT_PATH="." --env ORCID_TOKEN=$ORCID_TOKEN --env CODECOV_TOKEN=$CODECOV_TOKEN inbobmk/checklist +docker run --rm -it --entrypoint=/bin/bash --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git rev-parse HEAD) --env INPUT_TOKEN=$GITHUB_PAT --env INPUT_PATH="." --env ORCID_TOKEN=$ORCID_TOKEN --env CODECOV_TOKEN=$CODECOV_TOKEN inbobmk/checklist + +# run on main +docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git rev-parse HEAD) --env GITHUB_PAT=$GITHUB_PAT --env INPUT_PATH="." --env ORCID_TOKEN=$ORCID_TOKEN --env CODECOV_TOKEN=$CODECOV_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main inbobmk/checklist + + +docker build --tag=inbo/protocols . + +#entrypoint_website +docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols + +#entrypoint_check +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh new file mode 100644 index 00000000..b8625697 --- /dev/null +++ b/docker/entrypoint_update.sh @@ -0,0 +1,24 @@ +#!/bin/sh -l + +echo '\nGetting the code...\n' +git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check +cd check +git checkout $BRANCH_SOURCE +ls -a +rm .Rprofile + +echo '\nUpdating zenodo...\n' +Rscript "protocolhelper:::update_zenodo()" +git config user.name +git config user.email +git add --all +git commit --message="update .zenodo.json" +git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY + +echo '\nUpdating general NEWS.md...\n' +Rscript "protocolhelper:::update_news_release(Sys.getenv("PROTOCOL_CODE"))" +git config user.name +git config user.email +git add --all +git commit --message="update general NEWS.md" +git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY From e4cf9f6ef7b9d90c91bde00e7f499ebae676c41f Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 18 Jul 2022 17:37:27 +0200 Subject: [PATCH 18/64] test checklist::clean_git() --- docker/check_all.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index b6f45ef4..c42b1f2e 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,7 +1,8 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - sapply(protocol_code, protocolhelper::check_frontmatter) + checklist::clean_git() + #sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) } From 46ddfbfed53fa354155a233a27c6142b94fb93c6 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 10:30:05 +0200 Subject: [PATCH 19/64] test of interactive() de zaak oplost --- docker/check_all.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index c42b1f2e..d0857209 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,7 +1,9 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - checklist::clean_git() + if (interactive()) { + checklist::clean_git() + } #sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) From d741c914910a2cc8265a328f435ececf12909f89 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 11:16:47 +0200 Subject: [PATCH 20/64] testen of 2 checks na mekaar werkt --- docker/check_all.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index d0857209..5e5d5f24 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,11 +1,9 @@ # bundled checks for protocols library(protocolhelper) check_all <- function(protocol_code) { - if (interactive()) { - checklist::clean_git() - } #sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) + sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) } check_all(Sys.getenv("PROTOCOL_CODE")) From 6c74577b38d3bd6288c74dd56222b936aa0a3493 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 11:19:46 +0200 Subject: [PATCH 21/64] nieuwe test --- docker/check_all.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 5e5d5f24..a395a416 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,9 +1,7 @@ # bundled checks for protocols library(protocolhelper) -check_all <- function(protocol_code) { +protocol_code <- Sys.getenv("PROTOCOL_CODE") #sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) -} -check_all(Sys.getenv("PROTOCOL_CODE")) From 30052ac61b6cc3f01d48b8f7ad020efdef091867 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 11:27:54 +0200 Subject: [PATCH 22/64] check_frontmatter() testen i.p.v. tweemaal check_structure() --- docker/check_all.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index a395a416..b15ea870 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,7 +1,6 @@ # bundled checks for protocols library(protocolhelper) protocol_code <- Sys.getenv("PROTOCOL_CODE") - #sapply(protocol_code, protocolhelper::check_frontmatter) - sapply(protocol_code, protocolhelper::check_structure) + sapply(protocol_code, protocolhelper::check_frontmatter) sapply(protocol_code, protocolhelper::check_structure) #return(invisible(protocol_code)) From ca066359bbcc77bcb9b8d6c89002f889ef064c1d Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 15:45:13 +0200 Subject: [PATCH 23/64] trycatch in check_all.R --- docker/check_all.R | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index b15ea870..8fe45f0f 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,6 +1,17 @@ # bundled checks for protocols library(protocolhelper) protocol_code <- Sys.getenv("PROTOCOL_CODE") - sapply(protocol_code, protocolhelper::check_frontmatter) - sapply(protocol_code, protocolhelper::check_structure) - #return(invisible(protocol_code)) +fail <- FALSE +tryCatch( + protocolhelper::check_frontmatter(protocol_code), + error = function(e) e, + fail = TRUE +) +tryCatch( + protocolhelper::check_structure(protocol_code), + error = function(e) e, + fail = TRUE +) +if (fail) { + stop("\nThe source code failed some checks. Please check the error message above.\n") +} From 522eb00d31610e992e8cf94ef31de5da628b3dec Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:02:38 +0200 Subject: [PATCH 24/64] check_all.R: output layout issue --- docker/check_all.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 8fe45f0f..bcee7977 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,10 +1,9 @@ # bundled checks for protocols -library(protocolhelper) protocol_code <- Sys.getenv("PROTOCOL_CODE") fail <- FALSE tryCatch( protocolhelper::check_frontmatter(protocol_code), - error = function(e) e, + error = function(e) paste0(e, "\n\n"), fail = TRUE ) tryCatch( From 92bfb478f25a0d3194b4925303013050ac268470 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:09:56 +0200 Subject: [PATCH 25/64] rewrite check_all as function --- docker/check_all.R | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index bcee7977..330de3fb 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,16 +1,19 @@ # bundled checks for protocols -protocol_code <- Sys.getenv("PROTOCOL_CODE") -fail <- FALSE -tryCatch( - protocolhelper::check_frontmatter(protocol_code), - error = function(e) paste0(e, "\n\n"), - fail = TRUE -) -tryCatch( - protocolhelper::check_structure(protocol_code), - error = function(e) e, - fail = TRUE -) -if (fail) { - stop("\nThe source code failed some checks. Please check the error message above.\n") +check_all <- function(protocol_code) { + #protocol_code <- Sys.getenv("PROTOCOL_CODE") + fail <- FALSE + tryCatch( + protocolhelper::check_frontmatter(protocol_code), + error = function(e) paste0(e, "\n\n"), + fail = TRUE + ) + tryCatch( + protocolhelper::check_structure(protocol_code), + error = function(e) e, + fail = TRUE + ) + if (fail) { + stop("\nThe source code failed some checks. Please check the error message above.\n") + } } + From 34a9e36f8a1b4b6b03faccb599554e2f1b392ddf Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:26:17 +0200 Subject: [PATCH 26/64] add function check_all() to file check_all --- docker/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index 330de3fb..547bb760 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -16,4 +16,4 @@ check_all <- function(protocol_code) { stop("\nThe source code failed some checks. Please check the error message above.\n") } } - +check_all(Sys.getenv("PROTOCOL_CODE")) From 829165ca98a13b7c2064beb5acd6809528a91ae1 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:35:20 +0200 Subject: [PATCH 27/64] correct drop of error message --- docker/check_all.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 547bb760..3c0da32a 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -4,13 +4,17 @@ check_all <- function(protocol_code) { fail <- FALSE tryCatch( protocolhelper::check_frontmatter(protocol_code), - error = function(e) paste0(e, "\n\n"), - fail = TRUE + error = function(e) { + e + fail = TRUE + } ) tryCatch( protocolhelper::check_structure(protocol_code), - error = function(e) e, - fail = TRUE + error = function(e) { + paste0("\n\n", e) + fail = TRUE + } ) if (fail) { stop("\nThe source code failed some checks. Please check the error message above.\n") From 58adefcf0ace9f5b66b7dd0d58230446b0a78616 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:47:40 +0200 Subject: [PATCH 28/64] eventjes imiteren dat we niet interactief bezig zijn --- docker/check_all.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 3c0da32a..708160e2 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -3,14 +3,14 @@ check_all <- function(protocol_code) { #protocol_code <- Sys.getenv("PROTOCOL_CODE") fail <- FALSE tryCatch( - protocolhelper::check_frontmatter(protocol_code), + protocolhelper::check_frontmatter(protocol_code, fail = TRUE), error = function(e) { e fail = TRUE } ) tryCatch( - protocolhelper::check_structure(protocol_code), + protocolhelper::check_structure(protocol_code, fail = TRUE), error = function(e) { paste0("\n\n", e) fail = TRUE From 5406827752f7b4c945267133d3c012f8fcd95caf Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 19 Jul 2022 16:55:41 +0200 Subject: [PATCH 29/64] en hu is het hopelijk echt in orde... --- docker/check_all.R | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/docker/check_all.R b/docker/check_all.R index 708160e2..1a2b8c25 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -3,18 +3,14 @@ check_all <- function(protocol_code) { #protocol_code <- Sys.getenv("PROTOCOL_CODE") fail <- FALSE tryCatch( - protocolhelper::check_frontmatter(protocol_code, fail = TRUE), - error = function(e) { - e - fail = TRUE - } + protocolhelper::check_frontmatter(protocol_code), + error = function(e) e, + finally = fail <- TRUE ) tryCatch( - protocolhelper::check_structure(protocol_code, fail = TRUE), - error = function(e) { - paste0("\n\n", e) - fail = TRUE - } + protocolhelper::check_structure(protocol_code), + error = function(e) paste0("\n\n", e), + finally = fail <- TRUE ) if (fail) { stop("\nThe source code failed some checks. Please check the error message above.\n") From 34a3f6e4964b7f9797dc6bb3827b6af3aaadabff Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 20 Jul 2022 12:05:01 +0200 Subject: [PATCH 30/64] verwijder enter die toch niet werkt --- docker/check_all.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/check_all.R b/docker/check_all.R index 1a2b8c25..7618f9b3 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -9,7 +9,7 @@ check_all <- function(protocol_code) { ) tryCatch( protocolhelper::check_structure(protocol_code), - error = function(e) paste0("\n\n", e), + error = function(e) e, finally = fail <- TRUE ) if (fail) { From dd2329b180b064a4085fac35fe4cc294aeeb5b90 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 20 Jul 2022 12:06:16 +0200 Subject: [PATCH 31/64] verwijder weergave inhoud map --- docker/entrypoint_check.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index a3fece60..50d1e341 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -4,7 +4,6 @@ echo '\nGetting the code...\n' git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check cd check git checkout $BRANCH_SOURCE -ls -a rm .Rprofile #echo '\nChecking if branch is up to date with main...\n' From 8ddb2734d342be77af8364d027fc882502779670 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 20 Jul 2022 12:19:48 +0200 Subject: [PATCH 32/64] nu entrypoint_update testen --- Dockerfile | 2 +- build_push.sh | 8 ++++++-- docker/entrypoint_check.sh | 14 ++++++++++++++ docker/entrypoint_update.sh | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26bc3dfe..7c031b88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -142,4 +142,4 @@ COPY docker/entrypoint_website.sh /entrypoint_website.sh COPY docker/entrypoint_update.sh /entrypoint_update.sh COPY docker/entrypoint_check.sh /entrypoint_check.sh -ENTRYPOINT ["/entrypoint_check.sh"] +ENTRYPOINT ["/entrypoint_update.sh"] diff --git a/build_push.sh b/build_push.sh index 8e3cc2f4..3ce46514 100644 --- a/build_push.sh +++ b/build_push.sh @@ -14,8 +14,12 @@ docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git docker build --tag=inbo/protocols . +#entrypoint_check +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols + +#entrypoint_update +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols + #entrypoint_website docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols -#entrypoint_check -docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 50d1e341..a9357098 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -4,6 +4,7 @@ echo '\nGetting the code...\n' git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check cd check git checkout $BRANCH_SOURCE +#ls -a rm .Rprofile #echo '\nChecking if branch is up to date with main...\n' @@ -21,8 +22,21 @@ rm .Rprofile echo '\nChecking protocols specific tests...\n' #git checkout $BRANCH_SOURCE #rm .Rprofile + Rscript "docker/check_all.R" +#Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' if [ $? -ne 0 ]; then echo '\nThe source code failed some checks. Please check the error message above.\n'; exit 1 fi + +# Rscript 'protocolhelper::check_frontmatter("'$PROTOCOL_CODE'")' +# test1=$? +# Rscript -e 'protocolhelper::check_structure("'$PROTOCOL_CODE'")' +# test2=$? +# +# if [ $test1 -ne 0 ] || [ $test2 -ne 0 ]; then +# #echo $error1 +# echo '\nThe source code failed some checks. Please check the error message above.\n'; +# exit 1 +# fi diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh index b8625697..1a21ce04 100644 --- a/docker/entrypoint_update.sh +++ b/docker/entrypoint_update.sh @@ -16,7 +16,7 @@ git commit --message="update .zenodo.json" git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY echo '\nUpdating general NEWS.md...\n' -Rscript "protocolhelper:::update_news_release(Sys.getenv("PROTOCOL_CODE"))" +Rscript -e 'protocolhelper:::update_news_release("'$PROTOCOL_CODE'")' git config user.name git config user.email git add --all From 80a66b39909ecc52898aa845b31fd1b3d0c0cec2 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 20 Jul 2022 16:53:35 +0200 Subject: [PATCH 33/64] render_release is interne functie geworden --- docker/entrypoint_update.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh index 1a21ce04..29e634d0 100644 --- a/docker/entrypoint_update.sh +++ b/docker/entrypoint_update.sh @@ -1,24 +1,34 @@ #!/bin/sh -l echo '\nGetting the code...\n' -git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check -cd check -git checkout $BRANCH_SOURCE +git clone --branch=$BRANCH_SOURCE https://$INPUT_TOKEN_INBO@github.com/$GITHUB_REPOSITORY /update +git config --global user.email "info@inbo.be" +git config --global user.name "INBO" +cd /update +#git checkout $BRANCH_SOURCE ls -a rm .Rprofile echo '\nUpdating zenodo...\n' -Rscript "protocolhelper:::update_zenodo()" -git config user.name -git config user.email +Rscript --no-save --no-restore -e 'protocolhelper:::update_zenodo()' git add --all git commit --message="update .zenodo.json" -git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY echo '\nUpdating general NEWS.md...\n' -Rscript -e 'protocolhelper:::update_news_release("'$PROTOCOL_CODE'")' -git config user.name -git config user.email +Rscript --no-save --no-restore -e 'protocolhelper:::update_news_release("'$PROTOCOL_CODE'")' +#git config user.name +#git config user.email git add --all git commit --message="update general NEWS.md" -git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY + +echo 'git config --list:' +git config --list + +echo 'git branch' +git branch + +echo 'git remote -v show origin' +git remote -v show origin + +echo 'git push' +git push -f From 87be7bc5bccd2eab89c3763c6b80056ae33f3d39 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 20 Jul 2022 17:01:41 +0200 Subject: [PATCH 34/64] oeps, verkeerde file gecommit... hier de juiste --- docker/render.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/render.R b/docker/render.R index 6661b3bd..7577d710 100755 --- a/docker/render.R +++ b/docker/render.R @@ -1 +1 @@ -protocolhelper::render_release() +protocolhelper:::render_release() From 0943329bb7ce49ee640d63f6b5b9a6d763fdb054 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 26 Jul 2022 14:59:08 +0200 Subject: [PATCH 35/64] gebruik rocker/verse voor installatie van R (nieuwere versie nodig) --- Dockerfile | 58 ++++---------------------------------------- docker/Rprofile.site | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-) create mode 100644 docker/Rprofile.site diff --git a/Dockerfile b/Dockerfile index 7c031b88..487fc9bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM rocker/verse ARG BUILD_DATE ARG VCS_REF @@ -16,55 +16,12 @@ maintainer="Hans Van Calster " ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NONINTERACTIVE_SEEN true -## Set a default user. Available via runtime flag `--user docker` -## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library -## User should also have & own a home directory (for rstudio or linked volumes to work properly). -RUN useradd docker \ - && mkdir /home/docker \ - && chown docker:docker /home/docker \ - && addgroup docker staff - -## Configure default locale, see https://github.com/rocker-org/rocker/issues/19 -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - locales \ - && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ - && locale-gen nl_BE.utf8 \ - && /usr/sbin/update-locale LANG=nl_BE.UTF-8 - -ENV LC_ALL nl_BE.UTF-8 -ENV LANG nl_BE.UTF-8 - -## Add apt-get repositories for R -RUN apt-get update \ +## Install nano +RUN apt-get update \ && apt-get install -y --no-install-recommends \ - gnupg \ - ca-certificates \ - && sh -c 'echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" >> /etc/apt/sources.list' \ - && gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \ - && gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - + nano -## Install R base -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - r-base-core=4.1.0-1.2004.0 \ - r-base-dev=4.1.0-1.2004.0 \ - r-cran-boot=1.3-28-1cran1.2004.0 \ - r-cran-class=7.3-19-1.2004.0 \ - r-cran-cluster=2.1.2-1.2004.0 \ - r-cran-codetools=0.2-18-1cran1.2004.0 \ - r-cran-foreign=0.8.81-1.2004.0 \ - r-cran-kernsmooth=2.23-20-1cran1.2004.0 \ - r-cran-lattice=0.20-44-1cran2~ubuntu20.04.1~ppa1 \ - r-cran-mass=7.3-54-1.2004.0 \ - r-cran-matrix=1.3-3-1.2004.0 \ - r-cran-mgcv=1.8-35-1cran1.2004.0 \ - r-cran-nlme=3.1.152-1.2004.0 \ - r-cran-nnet=7.3-16-1.2004.0 \ - r-cran-rpart=4.1-15-2focal0 \ - r-cran-spatial=7.3-11-2focal0 \ - r-cran-survival=3.2-11-1cran1.2004.0 \ - r-recommended=4.1.0-1.2004.0 +COPY docker/Rprofile.site $R_HOME/etc/Rprofile.site ## Install wget RUN apt-get update \ @@ -115,11 +72,6 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ libharfbuzz-dev libfribidi-dev -## Install utils dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libudunits2-dev - ## Install V8 dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/docker/Rprofile.site b/docker/Rprofile.site new file mode 100644 index 00000000..69f17930 --- /dev/null +++ b/docker/Rprofile.site @@ -0,0 +1,48 @@ +options( + papersize = "a4", + tab.width = 2, + width = 80, + help_type = "html", + keep.source.pkgs = TRUE, + xpinch = 300, + ypinch = 300, + yaml.eval.expr = TRUE, + repos = c( + CRAN = "https://cloud.r-project.org/", + INLA = "https://inla.r-inla-download.org/R/stable", + inbo = "https://inbo.r-universe.dev" + ), + install.packages.check.source = "yes", + install.packages.compile.from.source = "always", + inbo_required = c("checklist", "fortunes", "remotes", "INBOmd", "INBOtheme") +) + +if ("checklist" %in% rownames(utils::installed.packages())) { + options( + lintr.linter_file = system.file("lintr", package = "checklist") + ) +} + +if ( + interactive() && + !all(getOption("inbo_required") %in% rownames(utils::installed.packages())) +) { + warning( + c( + "\n", + rep("^", getOption("width")), + "\nThis R installation lacks some required INBO packages.", + "\nPlease install them using the code below:\n", + "\ninstall.packages(c(", + paste0( + "\"", + getOption("inbo_required")[ + !getOption("inbo_required") %in% rownames(utils::installed.packages()) + ], + "\"", collapse = ", " + ), + "))\n\n", + rep("^", getOption("width")) + ) + ) +} From 4285032f07087f38255792019698cee1a3d491ee Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 26 Jul 2022 15:51:26 +0200 Subject: [PATCH 36/64] verwijder overbodige (test)code --- docker/entrypoint_update.sh | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh index 29e634d0..e0760553 100644 --- a/docker/entrypoint_update.sh +++ b/docker/entrypoint_update.sh @@ -1,13 +1,10 @@ #!/bin/sh -l echo '\nGetting the code...\n' -git clone --branch=$BRANCH_SOURCE https://$INPUT_TOKEN_INBO@github.com/$GITHUB_REPOSITORY /update +git clone --branch=$BRANCH_SOURCE https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY /update git config --global user.email "info@inbo.be" git config --global user.name "INBO" cd /update -#git checkout $BRANCH_SOURCE -ls -a -rm .Rprofile echo '\nUpdating zenodo...\n' Rscript --no-save --no-restore -e 'protocolhelper:::update_zenodo()' @@ -16,19 +13,9 @@ git commit --message="update .zenodo.json" echo '\nUpdating general NEWS.md...\n' Rscript --no-save --no-restore -e 'protocolhelper:::update_news_release("'$PROTOCOL_CODE'")' -#git config user.name -#git config user.email git add --all git commit --message="update general NEWS.md" -echo 'git config --list:' -git config --list - -echo 'git branch' -git branch - -echo 'git remote -v show origin' -git remote -v show origin echo 'git push' git push -f From ba9dd9618067f65334ce1f87c19810e09fa2d801 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 26 Jul 2022 15:52:05 +0200 Subject: [PATCH 37/64] gebruik methode aangeraden door renv --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 487fc9bd..e51e68f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,9 +84,13 @@ RUN apt-get update \ WORKDIR /github/workspace -RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" +RUN R -e "remotes::install_github('rstudio/renv@0.15.5')" RUN R -e "renv::consent(provided = TRUE)" COPY renv.lock renv.lock +RUN mkdir -p renv +COPY .Rprofile .Rprofile +COPY renv/activate.R renv/activate.R +COPY renv/settings.dcf renv/settings.dcf RUN R -e "renv::restore()" RUN R -e "renv::isolate()" From 592faa8a33d415ecbc0ac6af3bb14fa878c98ca4 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 26 Jul 2022 15:53:03 +0200 Subject: [PATCH 38/64] =?UTF-8?q?packages=20zijn=20niet=20ge=C3=AFnstallee?= =?UTF-8?q?rd=20in=20container=20als=20renv::restore()=20hier=20niet=20opn?= =?UTF-8?q?ieuw=20gerund=20wordt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/entrypoint_update.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh index e0760553..cfee1334 100644 --- a/docker/entrypoint_update.sh +++ b/docker/entrypoint_update.sh @@ -6,6 +6,10 @@ git config --global user.email "info@inbo.be" git config --global user.name "INBO" cd /update +echo '\nSession info\n' +Rscript -e "renv::restore()" +Rscript -e 'sessioninfo::session_info()' + echo '\nUpdating zenodo...\n' Rscript --no-save --no-restore -e 'protocolhelper:::update_zenodo()' git add --all From e33420f2c534957f049619c1e95074140fdd1d4b Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Tue, 26 Jul 2022 15:53:13 +0200 Subject: [PATCH 39/64] ter info --- build_push.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build_push.sh b/build_push.sh index 3ce46514..481ee319 100644 --- a/build_push.sh +++ b/build_push.sh @@ -15,11 +15,12 @@ docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git docker build --tag=inbo/protocols . #entrypoint_check -docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols +#INPUT_TOKEN is als omgevingsvariabele toegevoegd op laptop #entrypoint_update -docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols #entrypoint_website -docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN=$GITHUB_PAT inbo/protocols +docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN inbo/protocols From 7504f212b01b8fa86a5118c79a7c5678b2542773 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 15:00:58 +0200 Subject: [PATCH 40/64] renv_restore() ook toevoegen aan check docker --- docker/entrypoint_check.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index a9357098..7418bdef 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -5,7 +5,11 @@ git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check cd check git checkout $BRANCH_SOURCE #ls -a -rm .Rprofile +#rm .Rprofile + +echo '\nSession info\n' +Rscript -e "renv::restore()" +Rscript -e 'sessioninfo::session_info()' #echo '\nChecking if branch is up to date with main...\n' #main_in_branch=$(git merge-base $BRANCH_SOURCE main) From 46891fa23cbefe598a59bbbaa97c76c4a51a08a6 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 15:04:32 +0200 Subject: [PATCH 41/64] add function update_version_number() to check docker --- docker/entrypoint_check.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 7418bdef..0b03be78 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -23,6 +23,16 @@ Rscript -e 'sessioninfo::session_info()' # exit 1 #fi +echo '\nUpdate version number...\n' +git config --global user.email "info@inbo.be" +git config --global user.name "INBO" +UPDATED=$(Rscript -e 'protocolhelper::update_version_number("'$PROTOCOL_CODE'")') +echo 'output updated:' $UPDATED +if [ "$UPDATED" = "[1] TRUE" ]; then + git push -f + echo '\ncommit with new version pushed\n' +fi + echo '\nChecking protocols specific tests...\n' #git checkout $BRANCH_SOURCE #rm .Rprofile From a32d9d75cf03a5abb911bbe9681147d121b04c22 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 15:28:48 +0200 Subject: [PATCH 42/64] testje voor merge naar main --- .github/workflows/update-website-test.yml | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/update-website-test.yml diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml new file mode 100644 index 00000000..fd43b335 --- /dev/null +++ b/.github/workflows/update-website-test.yml @@ -0,0 +1,24 @@ +name: On merge to main, build the protocol and add it to the website + +on: + push: + branches: + - main + +jobs: + build-website: + runs-on: ubuntu-latest + name: "add protocol to website" + env: + GITHUB_PAT: ${{ secrets.PAT }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + token: ${{ secrets.PAT }} + - name: test + run: | + echo 'GitHub actions:' $GITHUB_ACTIONS + echo 'Event name:' $GITHUB_EVENT_NAME + echo 'ref:' $GITHUB_REF + echo 'branch:' $BRANCH_SOURCE From 7b6665af28da7be50c3cc78729f1390808b3f54b Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 15:36:08 +0200 Subject: [PATCH 43/64] onafgewerkte yamls voorlopig even wegdoen --- .github/workflows/check_branch.yml | 19 ------------------ .github/workflows/release.yml | 30 ---------------------------- .github/workflows/update-website.yml | 18 ----------------- 3 files changed, 67 deletions(-) delete mode 100644 .github/workflows/check_branch.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/update-website.yml diff --git a/.github/workflows/check_branch.yml b/.github/workflows/check_branch.yml deleted file mode 100644 index 5ca6b3d8..00000000 --- a/.github/workflows/check_branch.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Check the protocol on pull request - -on: - pull_request: - types: [synchronize, opened, reopened, edited] #en zie https://github.community/t/rerun-on-base-branch-change/115594 - branches: - - main - -jobs: - check-protocol: - runs-on: ubuntu-latest - name: "check protocol" - env: - GITHUB_PAT: ${{ secrets.PAT }} - steps: - - name: Check protocol - uses: inbo/actions/xxx@xxx - with: - token: ${{ secrets.PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7724c860..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -on: - push: - tags: - - 'protocols-****.**' - -name: Create Release - -jobs: - build: - name: Create Release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Get tag message - run: | - TAG_BODY=$(git tag --contains ${{ github.sha }} -n100 | awk '(NR>1)') - echo "::set-output name=TAG_BODY::$TAG_BODY" - id: tag-body - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: ${{ steps.tag-body.outputs.TAG_BODY }} - draft: false - prerelease: false diff --git a/.github/workflows/update-website.yml b/.github/workflows/update-website.yml deleted file mode 100644 index cca2e923..00000000 --- a/.github/workflows/update-website.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: On merge to main, build the protocol and add it to the website - -on: - push: - branches: - - main - -jobs: - build-website: - runs-on: ubuntu-latest - name: "add protocol to website" - env: - GITHUB_PAT: ${{ secrets.PAT }} - steps: - - name: Checkout repo - uses: inbo/actions/xxx@xxx - with: - token: ${{ secrets.PAT }} From 4322f8fe8dd4a333c958f48abb1cbf0931026c0e Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 15:55:44 +0200 Subject: [PATCH 44/64] yaml wat aanpassen --- .github/workflows/update-website-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index fd43b335..f00f0eb0 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -10,12 +10,10 @@ jobs: runs-on: ubuntu-latest name: "add protocol to website" env: - GITHUB_PAT: ${{ secrets.PAT }} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} steps: - name: Checkout repo uses: actions/checkout@v2 - with: - token: ${{ secrets.PAT }} - name: test run: | echo 'GitHub actions:' $GITHUB_ACTIONS From 6ceae5c5cc0ac84fd8da5ad56729146dba3d218e Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 16:50:11 +0200 Subject: [PATCH 45/64] extra testjes om branchnaam te achterhalen --- .github/workflows/update-website-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index f00f0eb0..04d367fc 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -1,4 +1,5 @@ name: On merge to main, build the protocol and add it to the website +"Log RECENT_MERGED_BRANCH_NAME" on: push: @@ -15,8 +16,11 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: test + uses: tonynguyenit18/github-action-custom-vars@v1 run: | echo 'GitHub actions:' $GITHUB_ACTIONS echo 'Event name:' $GITHUB_EVENT_NAME echo 'ref:' $GITHUB_REF echo 'branch:' $BRANCH_SOURCE + echo 'event ref:' "${{ github.event.base_ref }}" + echo 'event ref2:' $GITHUB_EVENT_BASE_REF From e2dddf33462431868495560aac1a4d32e0e26a09 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 16:54:07 +0200 Subject: [PATCH 46/64] nieuwe test --- .github/workflows/update-website-test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index f00f0eb0..584052db 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -1,4 +1,4 @@ -name: On merge to main, build the protocol and add it to the website +name: "Log RECENT_MERGED_BRANCH_NAME" on: push: @@ -15,8 +15,12 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: test + uses: tonynguyenit18/github-action-custom-vars@v1 run: | echo 'GitHub actions:' $GITHUB_ACTIONS echo 'Event name:' $GITHUB_EVENT_NAME echo 'ref:' $GITHUB_REF echo 'branch:' $BRANCH_SOURCE + echo 'event ref:' "${{ github.event.base_ref }}" + echo 'event ref2:' $GITHUB_EVENT_BASE_REF + echo 'recent merged branch:' $RECENT_MERGED_BRANCH_NAME From 5a2aeecede7a058fde61f722e3e82df43674daa2 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 16:58:08 +0200 Subject: [PATCH 47/64] correctie --- .github/workflows/update-website-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index 584052db..a6f867c0 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -14,8 +14,8 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v2 - - name: test uses: tonynguyenit18/github-action-custom-vars@v1 + - name: test run: | echo 'GitHub actions:' $GITHUB_ACTIONS echo 'Event name:' $GITHUB_EVENT_NAME From c8ee0570ece0aa5e71d37354b7c41cc92fb04da6 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 17:05:32 +0200 Subject: [PATCH 48/64] correcties --- .github/workflows/update-website-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index b0ae63b0..4cfaad22 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -14,9 +14,8 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v2 - uses: tonynguyenit18/github-action-custom-vars@v1 + - uses: tonynguyenit18/github-action-custom-vars@v1 - name: test - uses: tonynguyenit18/github-action-custom-vars@v1 run: | echo 'GitHub actions:' $GITHUB_ACTIONS echo 'Event name:' $GITHUB_EVENT_NAME From e842679f35d6822fc85845d81a09c32f1722b76b Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Wed, 27 Jul 2022 17:17:45 +0200 Subject: [PATCH 49/64] titeltest en overbodige rommel weg --- .github/workflows/update-website-test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/update-website-test.yml b/.github/workflows/update-website-test.yml index 4cfaad22..c7ac762f 100644 --- a/.github/workflows/update-website-test.yml +++ b/.github/workflows/update-website-test.yml @@ -1,4 +1,4 @@ -name: "Log RECENT_MERGED_BRANCH_NAME" +name: On merge to main, build the protocol and add it to the website "Log RECENT_MERGED_BRANCH_NAME" on: push: @@ -20,7 +20,4 @@ jobs: echo 'GitHub actions:' $GITHUB_ACTIONS echo 'Event name:' $GITHUB_EVENT_NAME echo 'ref:' $GITHUB_REF - echo 'branch:' $BRANCH_SOURCE - echo 'event ref:' "${{ github.event.base_ref }}" - echo 'event ref2:' $GITHUB_EVENT_BASE_REF echo 'recent merged branch:' $RECENT_MERGED_BRANCH_NAME From e8860b088d9d54b302dd02a2ec34db73b9830365 Mon Sep 17 00:00:00 2001 From: INBO Date: Fri, 29 Jul 2022 13:12:51 +0200 Subject: [PATCH 50/64] undo handleiding door renv -> renv::restore() niet meer nodig voor entrypoint_update() --- Dockerfile | 6 +----- docker/entrypoint_update.sh | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e51e68f4..487fc9bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,13 +84,9 @@ RUN apt-get update \ WORKDIR /github/workspace -RUN R -e "remotes::install_github('rstudio/renv@0.15.5')" +RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" RUN R -e "renv::consent(provided = TRUE)" COPY renv.lock renv.lock -RUN mkdir -p renv -COPY .Rprofile .Rprofile -COPY renv/activate.R renv/activate.R -COPY renv/settings.dcf renv/settings.dcf RUN R -e "renv::restore()" RUN R -e "renv::isolate()" diff --git a/docker/entrypoint_update.sh b/docker/entrypoint_update.sh index cfee1334..229cebbd 100644 --- a/docker/entrypoint_update.sh +++ b/docker/entrypoint_update.sh @@ -6,20 +6,20 @@ git config --global user.email "info@inbo.be" git config --global user.name "INBO" cd /update +rm .Rprofile + echo '\nSession info\n' -Rscript -e "renv::restore()" Rscript -e 'sessioninfo::session_info()' echo '\nUpdating zenodo...\n' Rscript --no-save --no-restore -e 'protocolhelper:::update_zenodo()' -git add --all +git add .zenodo.json git commit --message="update .zenodo.json" echo '\nUpdating general NEWS.md...\n' Rscript --no-save --no-restore -e 'protocolhelper:::update_news_release("'$PROTOCOL_CODE'")' -git add --all +git add NEWS.md git commit --message="update general NEWS.md" - echo 'git push' git push -f From 4dd57c4bde9464f7e923f420292f2f2e6b2b922b Mon Sep 17 00:00:00 2001 From: INBO Date: Fri, 29 Jul 2022 15:07:11 +0200 Subject: [PATCH 51/64] renv::restore() verwijderen in entrypoint_check, inclusief aanpassing aan commit --- docker/entrypoint_check.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 0b03be78..5395def1 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -5,10 +5,9 @@ git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY check cd check git checkout $BRANCH_SOURCE #ls -a -#rm .Rprofile +rm .Rprofile echo '\nSession info\n' -Rscript -e "renv::restore()" Rscript -e 'sessioninfo::session_info()' #echo '\nChecking if branch is up to date with main...\n' @@ -29,6 +28,12 @@ git config --global user.name "INBO" UPDATED=$(Rscript -e 'protocolhelper::update_version_number("'$PROTOCOL_CODE'")') echo 'output updated:' $UPDATED if [ "$UPDATED" = "[1] TRUE" ]; then + # remake the last commit without deletion of .Rprofile + MESSAGE=$(git log -1 --pretty=%B) + git reset --soft HEAD^ + git reset HEAD .Rprofile + git commit --message="$MESSAGE" + git push -f echo '\ncommit with new version pushed\n' fi From c14c790e393ae3afaf8f50f853686c524ad87f62 Mon Sep 17 00:00:00 2001 From: INBO Date: Fri, 29 Jul 2022 16:50:27 +0200 Subject: [PATCH 52/64] current version of entrypoint_website.sh --- Dockerfile | 2 +- build_push.sh | 2 +- docker/entrypoint_website.sh | 28 +++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 487fc9bd..c215c3e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,4 +94,4 @@ COPY docker/entrypoint_website.sh /entrypoint_website.sh COPY docker/entrypoint_update.sh /entrypoint_update.sh COPY docker/entrypoint_check.sh /entrypoint_check.sh -ENTRYPOINT ["/entrypoint_update.sh"] +ENTRYPOINT ["/entrypoint_website.sh"] diff --git a/build_push.sh b/build_push.sh index 481ee319..c8ff8e90 100644 --- a/build_push.sh +++ b/build_push.sh @@ -22,5 +22,5 @@ docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANC docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols #entrypoint_website -docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN inbo/protocols +docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main --env PROTOCOL_CODE="sfp-401-nl" inbo/protocols diff --git a/docker/entrypoint_website.sh b/docker/entrypoint_website.sh index edb1c643..2e85bd4a 100755 --- a/docker/entrypoint_website.sh +++ b/docker/entrypoint_website.sh @@ -4,20 +4,37 @@ echo '\nGetting the code...\n' git clone --quiet https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_SOURCE /render cd /render git checkout $BRANCH_SOURCE +git config --global user.email "info@inbo.be" +git config --global user.name "INBO" -echo 'Rendering the Rmarkdown files...\n' rm .Rprofile -Rscript "docker/render.R" + +echo '\nSession info\n' +#Rscript -e "renv::restore()" +Rscript -e 'sessioninfo::session_info()' + +echo '\nAdd tag to merge commit protocolsource...\n' +echo 'GitHub actions:' $GITHUB_ACTIONS +echo 'Event name:' $GITHUB_EVENT_NAME +echo 'ref:' $GITHUB_REF +git rev-parse --abbrev-ref origin/HEAD | sed 's/origin\///' | xargs git checkout +Rscript --no-save --no-restore -e 'protocolhelper:::set_tags("'$PROTOCOL_CODE'")' +git push --follow-tags + +echo 'Rendering the Rmarkdown files...\n' +#rm .Rprofile +Rscript -e "protocolhelper:::render_release()" if [ $? -ne 0 ]; then echo '\nRendering failed. Please check the error message above.\n'; exit 1 +else + echo '\nAll Rmarkdown files rendered successfully\n' fi -echo '\nAll Rmarkdown files rendered successfully\n' echo 'Publishing the rendered files...\n' git clone --quiet --depth=1 --single-branch --branch=main https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST /destiny -git config --global user.email "info@inbo.be" -git config --global user.name "INBO" +#git config --global user.email "info@inbo.be" +#git config --global user.name "INBO" cp -R /render/publish/. /destiny/. cd /destiny @@ -27,6 +44,7 @@ git config user.name git config user.email git add --all git commit --message="Add new protocol" +Rscript --no-save --no-restore -e 'protocolhelper:::set_tags("'$PROTOCOL_CODE'")' git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST echo '\nNew version published...' From 491157ef5ee2f089b249e4e3f2a69f3fcd682e80 Mon Sep 17 00:00:00 2001 From: INBO Date: Thu, 4 Aug 2022 10:05:28 +0200 Subject: [PATCH 53/64] entrypoint_website: neem tag van protocols over van protocolsource --- docker/entrypoint_website.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docker/entrypoint_website.sh b/docker/entrypoint_website.sh index 2e85bd4a..3acbf70b 100755 --- a/docker/entrypoint_website.sh +++ b/docker/entrypoint_website.sh @@ -21,6 +21,18 @@ git rev-parse --abbrev-ref origin/HEAD | sed 's/origin\///' | xargs git checkout Rscript --no-save --no-restore -e 'protocolhelper:::set_tags("'$PROTOCOL_CODE'")' git push --follow-tags +# look up tag names and tag messages to push to repo protocols later +# (not possible to run set_tags() when not in protocolsource anymore) +TAGNAME_GENERAL=$(git tag -l protocols-* --points-at) +TAGNAME_SPECIFIC=$(git tag -l s*p* --points-at) +TAGMESSAGE_GENERAL=$(git for-each-ref refs/tags/$TAGNAME_GENERAL --format='%(contents)') +TAGMESSAGE_SPECIFIC=$(git for-each-ref refs/tags/$TAGNAME_SPECIFIC --format='%(contents)') + +echo 'tagname general:' $TAGNAME_GENERAL +echo 'tag message general:' $TAGMESSAGE_GENERAL +echo 'tagname specific:' $TAGNAME_SPECIFIC +echo 'tag message specific:' $TAGMESSAGE_SPECIFIC + echo 'Rendering the Rmarkdown files...\n' #rm .Rprofile Rscript -e "protocolhelper:::render_release()" @@ -44,7 +56,11 @@ git config user.name git config user.email git add --all git commit --message="Add new protocol" -Rscript --no-save --no-restore -e 'protocolhelper:::set_tags("'$PROTOCOL_CODE'")' git push -f https://$INPUT_TOKEN@github.com/$GITHUB_REPOSITORY_DEST +git rev-parse --abbrev-ref origin/HEAD | sed 's/origin\///' | xargs git checkout +git tag -a $TAGNAME_GENERAL -m "$TAGMESSAGE_GENERAL" +git tag -a $TAGNAME_SPECIFIC -m "$TAGMESSAGE_SPECIFIC" +git push --follow-tags + echo '\nNew version published...' From d0ad6bdb37a1fe7e188873834c3a0a6c7aa910e2 Mon Sep 17 00:00:00 2001 From: INBO Date: Thu, 4 Aug 2022 16:50:21 +0200 Subject: [PATCH 54/64] load library to get error in docker if loading fails --- docker/check_all.R | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/check_all.R b/docker/check_all.R index 7618f9b3..49861050 100644 --- a/docker/check_all.R +++ b/docker/check_all.R @@ -1,4 +1,5 @@ # bundled checks for protocols +library(protocolhelper) check_all <- function(protocol_code) { #protocol_code <- Sys.getenv("PROTOCOL_CODE") fail <- FALSE From 4a1cc18b9012082e283c6d64061dd31bb8d7c8a7 Mon Sep 17 00:00:00 2001 From: INBO Date: Thu, 4 Aug 2022 14:53:30 +0000 Subject: [PATCH 55/64] Bumped 2021.01 to 2022.01 in index.Rmd --- .../sfp-401-nl_vegopname-terrest/index.Rmd | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd index 6be92f0d..8cf03301 100644 --- a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd +++ b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd @@ -1,14 +1,20 @@ --- -title: Klassieke vegetatieopname in een proefvlak aan de hand van visuele inschattingen van bedekking van soorten in (semi-)terrestrische vegetatie -subtitle: +title: Klassieke vegetatieopname in een proefvlak aan de hand van visuele inschattingen + van bedekking van soorten in (semi-)terrestrische vegetatie +subtitle: null author: - - name: Els De Bie - orcid: 0000-0001-7679-743X -date: "2022-07-18" -reviewers: [Hans Van Calster,Lieve Vriens,Jan Wouters,Wouter Van Gompel,Els Lommelen] +- name: Els De Bie + orcid: 0000-0001-7679-743X +date: '2022-07-18' +reviewers: +- Hans Van Calster +- Lieve Vriens +- Jan Wouters +- Wouter Van Gompel +- Els Lommelen file_manager: Hans Van Calster protocol_code: sfp-401-nl -version_number: "2021.01" +version_number: '2022.01' language: nl theme: vegetation params: @@ -16,28 +22,31 @@ params: plot_length_openveg_m: 3 plot_width_forest_m: 16 plot_length_forest_m: 16 - plot_shape: "vierkant" + plot_shape: vierkant height_herbshrublayer_openveg_m: 0.8 height_herbshrublayer_forest_m: 2 height_shrubtreelayer_openveg_m: 6 height_shrubtreelayer_forest_m: 8 - species_list: ["vaatplanten", "mossen", "lichenen"] - phenology_values: "standaard inbo-fenologiecodes" - coverscale_species: "Londo origineel" - coverscale_structure: "inbo-structuur-schaal" + species_list: + - vaatplanten + - mossen + - lichenen + phenology_values: standaard inbo-fenologiecodes + coverscale_species: Londo origineel + coverscale_structure: inbo-structuur-schaal site: bookdown::bookdown_site -output: +output: bookdown::gitbook: split_by: none - split_bib: FALSE - template: !expr protocolhelper::protocol_css() + split_bib: false + template: css/gitbook.html css: css/inbo_rapport.css config: - toc: - before: | - - after: | -
  • + toc: + before: | + + after:
  • --- ```{=html} From ac839e542aecd39c6dd5410168d9bb84ffbfd5f3 Mon Sep 17 00:00:00 2001 From: INBO Date: Thu, 4 Aug 2022 15:29:36 +0000 Subject: [PATCH 56/64] update .zenodo.json --- .zenodo.json | 76 ++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index fe70320d..2e3d4299 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,40 +1,40 @@ { - "title": "Source code of protocols of the Research Institute for Nature and Forest (INBO)", - "description": "This archive provides the source code of protocols used at the Research Institute for Nature and Forest (INBO), Brussels, Belgium (www.inbo.be). The protocols are written in R markdown and are compiled as html using the bookdown package. The website with the compiled protocols (including older versions) is at https://protocols.inbo.be.", - "license": "cc-by", - "upload_type": "other", - "access_right": "open", - "creators": [ - { - "name": "Van Calster, Hans", - "affiliation": "Research Institute for Nature and Forest", - "orcid": "0000-0001-8595-8426" - }, - { - "name": "De Bie, Els", - "affiliation": "Research Institute for Nature and Forest", - "orcid": "0000-0001-7679-743X" - }, - { - "name": "Onkelinx, Thierry", - "affiliation": "Research Institute for Nature and Forest", - "orcid": "0000-0001-8804-4216" - }, - { - "name": "Vanderhaeghe, Floris", - "affiliation": "Research Institute for Nature and Forest", - "orcid": "0000-0002-6378-6229" - } - ], - "keywords": [ - "open protocol", - "open science", - "research institute", - "nature", - "forest", - "environment", - "markdown", - "Flanders", - "Belgium" - ] + "title": "Source code of protocols of the Research Institute for Nature and Forest (INBO)", + "description": "This archive provides the source code of protocols used at the Research Institute for Nature and Forest (INBO), Brussels, Belgium (www.inbo.be<\/a>). The protocols are written in R markdown and are compiled as html using the bookdown package. The website with the compiled protocols (including older versions) is at https://protocols.inbo.be<\/a>.", + "license": "cc-by", + "upload_type": "other", + "access_right": "open", + "creators": [ + { + "name": "Van Calster, Hans", + "affiliation": "Research Institute for Nature and Forest", + "orcid": "0000-0001-8595-8426" + }, + { + "name": "De Bie, Els", + "affiliation": "Research Institute for Nature and Forest", + "orcid": "0000-0001-7679-743X" + }, + { + "name": "Onkelinx, Thierry", + "affiliation": "Research Institute for Nature and Forest", + "orcid": "0000-0001-8804-4216" + }, + { + "name": "Vanderhaeghe, Floris", + "affiliation": "Research Institute for Nature and Forest", + "orcid": "0000-0002-6378-6229" + } + ], + "keywords": [ + "open protocol", + "open science", + "research institute", + "nature", + "forest", + "environment", + "markdown", + "Flanders", + "Belgium" + ] } From 4e28ac6d3788926b0a7403502b413839d700adc5 Mon Sep 17 00:00:00 2001 From: INBO Date: Thu, 4 Aug 2022 15:29:37 +0000 Subject: [PATCH 57/64] update general NEWS.md --- NEWS.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 39b76bfb..db99893a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +## Version 2022.01 + +- Protocol code: sfp-401-nl +- Title: Klassieke vegetatieopname in een proefvlak aan de hand van visuele inschattingen van bedekking van soorten in (semi-)terrestrische vegetatie + \ No newline at end of file +--> From 5b5595af8a0225bad124f5d4cf7c08d9fefcb382 Mon Sep 17 00:00:00 2001 From: INBO Date: Mon, 22 Aug 2022 13:43:19 +0200 Subject: [PATCH 58/64] verduidelijking in build_push.sh --- build_push.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/build_push.sh b/build_push.sh index c8ff8e90..2f86e2fe 100644 --- a/build_push.sh +++ b/build_push.sh @@ -1,3 +1,20 @@ +#to be used on protocolsource (change entrypoint below in Dockerfile to run other parts) + +docker build --tag=inbo/protocols . + +#entrypoint_check +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="dockertests" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols +#INPUT_TOKEN is als omgevingsvariabele toegevoegd op laptop + +#entrypoint_update +docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="dockertests" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols + +#entrypoint_website +docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="dockertests" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main --env PROTOCOL_CODE="sfp-401-nl" inbo/protocols + + + +#examples docker build --no-cache --tag=inbobmk/checklist . docker build --tag=inbobmk/checklist . @@ -11,16 +28,3 @@ docker run --rm -it --entrypoint=/bin/bash --env GITHUB_REPOSITORY="inbo/checkli # run on main docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git rev-parse HEAD) --env GITHUB_PAT=$GITHUB_PAT --env INPUT_PATH="." --env ORCID_TOKEN=$ORCID_TOKEN --env CODECOV_TOKEN=$CODECOV_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main inbobmk/checklist - -docker build --tag=inbo/protocols . - -#entrypoint_check -docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols -#INPUT_TOKEN is als omgevingsvariabele toegevoegd op laptop - -#entrypoint_update -docker run --rm --env GITHUB_REPOSITORY="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env PROTOCOL_CODE="sfp-401-nl" --env INPUT_TOKEN inbo/protocols - -#entrypoint_website -docker run --rm --env GITHUB_REPOSITORY_SOURCE="ElsLommelen/protocolsource" --env BRANCH_SOURCE="docker-setup" --env GITHUB_REPOSITORY_DEST="ElsLommelen/protocols" --env INPUT_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main --env PROTOCOL_CODE="sfp-401-nl" inbo/protocols - From 3890ec4df1b5e780124478ada9df10a9bc92bfe7 Mon Sep 17 00:00:00 2001 From: INBO Date: Mon, 22 Aug 2022 13:49:11 +0200 Subject: [PATCH 59/64] correction --- docker/entrypoint_check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index 5395def1..aff96a76 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -40,7 +40,7 @@ fi echo '\nChecking protocols specific tests...\n' #git checkout $BRANCH_SOURCE -#rm .Rprofile +rm .Rprofile Rscript "docker/check_all.R" #Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' From 672fb3f7a487d4227dab400da3ddfd50d635d5a1 Mon Sep 17 00:00:00 2001 From: INBO Date: Mon, 22 Aug 2022 13:50:14 +0200 Subject: [PATCH 60/64] change and clean dockerfile --- Dockerfile | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index c215c3e2..347286c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="RStable" \ -org.label-schema.description="A docker image with stable versions of R and a bunch of packages used to calculate indicators." \ +org.label-schema.description="A docker image with stable versions of R and a bunch of packages used to check and publish protocols." \ org.label-schema.license="MIT" \ org.label-schema.url="e.g. https://www.inbo.be/" \ org.label-schema.vcs-ref=$VCS_REF \ @@ -24,30 +24,30 @@ RUN apt-get update \ COPY docker/Rprofile.site $R_HOME/etc/Rprofile.site ## Install wget -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - wget +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# wget ## Install pandoc RUN wget https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb \ && dpkg -i pandoc-2.7.3-1-amd64.deb \ && rm pandoc-2.7.3-1-amd64.deb -## Install git +## Install git depencencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ - git \ +# git \ openssh-client ## Install curl dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libcurl4-openssl-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libcurl4-openssl-dev ## Install ggplot2 dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libfreetype6-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libfreetype6-dev ## Install rgdal dependencies RUN apt-get update \ @@ -58,19 +58,19 @@ RUN apt-get update \ proj-bin ## Install openssl dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libssl-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libssl-dev ## Install systemfonts dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libfontconfig1-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libfontconfig1-dev ## Install textshaping dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libharfbuzz-dev libfribidi-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libharfbuzz-dev libfribidi-dev ## Install V8 dependencies RUN apt-get update \ @@ -78,9 +78,9 @@ RUN apt-get update \ libv8-dev ## Install xml2 dependencies -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libxml2-dev +#RUN apt-get update \ +# && apt-get install -y --no-install-recommends \ +# libxml2-dev WORKDIR /github/workspace @@ -94,4 +94,4 @@ COPY docker/entrypoint_website.sh /entrypoint_website.sh COPY docker/entrypoint_update.sh /entrypoint_update.sh COPY docker/entrypoint_check.sh /entrypoint_check.sh -ENTRYPOINT ["/entrypoint_website.sh"] +ENTRYPOINT ["/entrypoint_check.sh"] From b8cba68d20e8bf51f944cdaf12ebfbe5c3b5ee03 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Mon, 5 Sep 2022 14:49:12 +0200 Subject: [PATCH 61/64] change version number to test function update_version_number() --- .../4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd index 8cf03301..56182068 100644 --- a/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd +++ b/src/thematic/4_vegetation/sfp-401-nl_vegopname-terrest/index.Rmd @@ -14,7 +14,7 @@ reviewers: - Els Lommelen file_manager: Hans Van Calster protocol_code: sfp-401-nl -version_number: '2022.01' +version_number: '2021.01' language: nl theme: vegetation params: From 3ecd59a3c0816a6bde7cbd2aca657ac73c480181 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Thu, 8 Sep 2022 11:41:14 +0200 Subject: [PATCH 62/64] ignore superfluous code (due to update of protocolhelper) --- docker/entrypoint_check.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/entrypoint_check.sh b/docker/entrypoint_check.sh index aff96a76..7d4bf2a4 100755 --- a/docker/entrypoint_check.sh +++ b/docker/entrypoint_check.sh @@ -29,10 +29,10 @@ UPDATED=$(Rscript -e 'protocolhelper::update_version_number("'$PROTOCOL_CODE'")' echo 'output updated:' $UPDATED if [ "$UPDATED" = "[1] TRUE" ]; then # remake the last commit without deletion of .Rprofile - MESSAGE=$(git log -1 --pretty=%B) - git reset --soft HEAD^ - git reset HEAD .Rprofile - git commit --message="$MESSAGE" +# MESSAGE=$(git log -1 --pretty=%B) +# git reset --soft HEAD^ +# git reset HEAD .Rprofile +# git commit --message="$MESSAGE" git push -f echo '\ncommit with new version pushed\n' @@ -40,7 +40,8 @@ fi echo '\nChecking protocols specific tests...\n' #git checkout $BRANCH_SOURCE -rm .Rprofile +#rm .Rprofile +ls -a Rscript "docker/check_all.R" #Rscript --no-save --no-restore -e 'check_all("'$PROTOCOL_CODE'")' From c72e14555cf27d1fe07a7ae8a271d612cc616904 Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Thu, 22 Sep 2022 16:30:01 +0200 Subject: [PATCH 63/64] test GHA --- .github/workflows/test_refs_PR.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/test_refs_PR.yml diff --git a/.github/workflows/test_refs_PR.yml b/.github/workflows/test_refs_PR.yml new file mode 100644 index 00000000..7444555c --- /dev/null +++ b/.github/workflows/test_refs_PR.yml @@ -0,0 +1,25 @@ +name: Env var on PR + +on: + pull_request: + branches: + - main + +jobs: + build-website: + runs-on: ubuntu-latest + name: "test env var in PR" + env: + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: test + run: | + echo 'GitHub actions:' $GITHUB_ACTIONS + echo 'Event name:' $GITHUB_EVENT_NAME + echo 'ref:' $GITHUB_REF + echo 'ref name:' $GITHUB_REF_NAME + echo 'base ref:' $GITHUB_BASE_REF + echo 'head ref:' $GITHUB_HEAD_REF + echo 'repo:' $GITHUB_REPOSITORY From 8f454115b19dc5f7aee2387f907dd05fb09e5e8e Mon Sep 17 00:00:00 2001 From: ElsLommelen Date: Thu, 22 Sep 2022 16:38:30 +0200 Subject: [PATCH 64/64] nog wat extra info toegevoegd aan kladbestandje build_push.sh --- build_push.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build_push.sh b/build_push.sh index 2f86e2fe..1e639415 100644 --- a/build_push.sh +++ b/build_push.sh @@ -28,3 +28,20 @@ docker run --rm -it --entrypoint=/bin/bash --env GITHUB_REPOSITORY="inbo/checkli # run on main docker run --rm --env GITHUB_REPOSITORY="inbo/checklist" --env GITHUB_SHA=$(git rev-parse HEAD) --env GITHUB_PAT=$GITHUB_PAT --env INPUT_PATH="." --env ORCID_TOKEN=$ORCID_TOKEN --env CODECOV_TOKEN=$CODECOV_TOKEN --env GITHUB_ACTIONS=true --env GITHUB_EVENT_NAME=push --env GITHUB_REF=refs/heads/main inbobmk/checklist + + +#zinvolle env uit github +GITHUB_BASE_REF: name of target branch of the PR +GITHUB_EVENT_NAME: name of the event that triggered the workflow run +GITHUB_HEAD_REF: source branch of the PR +GITHUB_REF: full ref of branch or tag that triggered the workflow run (best niet gebruiken bij PR) +GITHUB_REF_NAME: short ref name of branch or tag that triggered the workflow run +GITHUB_REPOSITORY: owner and repository name, bv. inbo/protocolsource + +#aan te passen env +BRANCH_SOURCE (on PR) -> GITHUB_HEAD_REF +BRANCH_SOURCE (on push) -> GITHUB_REF_NAME +PROTOCOL_CODE -> BRANCH_SOURCE (zie hierboven) +INPUT_TOKEN??? +GITHUB_REPOSITORY_SOURCE -> GITHUB_REPOSITORY +GITHUB_REPOSITORY_DEST: meegeven als env!