From d848fed69f5665ad874718dfc3031a7a53069cc6 Mon Sep 17 00:00:00 2001 From: "Recle E. Vibal" Date: Tue, 14 Mar 2023 16:17:53 +0800 Subject: [PATCH 1/3] Feat: Adds gitlab-ci dockerfile template --- .../gitlab_ci/dot.gitlab-ci.Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 inst/templates/gitlab_ci/dot.gitlab-ci.Dockerfile diff --git a/inst/templates/gitlab_ci/dot.gitlab-ci.Dockerfile b/inst/templates/gitlab_ci/dot.gitlab-ci.Dockerfile new file mode 100644 index 000000000..1cd4f5cb6 --- /dev/null +++ b/inst/templates/gitlab_ci/dot.gitlab-ci.Dockerfile @@ -0,0 +1,19 @@ +# Use appropriate R version for runner +FROM rstudio/r-base:4.2.2-focal + +# Install other app system dependencies here +RUN apt-get update && apt-get install --yes libcurl4-openssl-dev + +# Install cypress dependencies +RUN apt-get update && apt-get install --yes \ + libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 \ + libxtst6 xauth xvfb \ + && rm -rf /var/lib/apt/lists/* + +# Install nodejs +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash \ + && apt-get install nodejs -yq \ + && rm -rf /var/lib/apt/lists/* + +# Build: docker build -f .gitlab-ci.Dockerfile -t your/image:latest . +# Push: docker push your/image:latest \ No newline at end of file From f97028b59cc026fd0239a9eede26f00feba01901 Mon Sep 17 00:00:00 2001 From: "Recle E. Vibal" Date: Tue, 14 Mar 2023 16:18:25 +0800 Subject: [PATCH 2/3] Feat: Creates gitlab-ci yml template --- inst/templates/gitlab_ci/dot.gitlab-ci.yml | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 inst/templates/gitlab_ci/dot.gitlab-ci.yml diff --git a/inst/templates/gitlab_ci/dot.gitlab-ci.yml b/inst/templates/gitlab_ci/dot.gitlab-ci.yml new file mode 100644 index 000000000..5d0965cf0 --- /dev/null +++ b/inst/templates/gitlab_ci/dot.gitlab-ci.yml @@ -0,0 +1,28 @@ +variables: + # For caching renv library + RENV_PATHS_CACHE: ${CI_PROJECT_DIR}/cache + RENV_PATHS_LIBRARY: ${CI_PROJECT_DIR}/renv/library + + +default: + # Use deployed image with .gitlab-ci.Dockerfile + image: your/image:latest + cache: + # This key needs to be constant so all jobs in all branches will share the same cache + key: rhino-ci + paths: + - ${RENV_PATHS_CACHE} + - ${RENV_PATHS_LIBRARY} + +Runs linters and tests: + before_script: + # Restores renv if not yet cached + - R -e "options(renv.config.cache.symlinks = FALSE); renv::restore(clean = TRUE);" + script: + - R -e "rhino::lint_r()" + - R -e "rhino::lint_sass()" + - R -e "rhino::lint_js()" + - R -e "rhino::build_sass()" + - R -e "rhino::build_js()" + - R -e "rhino::test_r()" + - R -e "rhino::test_e2e()" \ No newline at end of file From 0e5c1c3806df1477d45bcf7f060445bb40c46b01 Mon Sep 17 00:00:00 2001 From: "Recle E. Vibal" Date: Tue, 14 Mar 2023 20:53:02 +0800 Subject: [PATCH 3/3] Feat: Adds caching of .rhino and cypress --- inst/templates/gitlab_ci/dot.gitlab-ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inst/templates/gitlab_ci/dot.gitlab-ci.yml b/inst/templates/gitlab_ci/dot.gitlab-ci.yml index 5d0965cf0..b4bc85293 100644 --- a/inst/templates/gitlab_ci/dot.gitlab-ci.yml +++ b/inst/templates/gitlab_ci/dot.gitlab-ci.yml @@ -2,6 +2,12 @@ variables: # For caching renv library RENV_PATHS_CACHE: ${CI_PROJECT_DIR}/cache RENV_PATHS_LIBRARY: ${CI_PROJECT_DIR}/renv/library + # Cache .rhino + DOT_RHINO_PATH: ${CI_PROJECT_DIR}/.rhino + # Necessary for cypress to run. + # https://docs.cypress.io/guides/references/error-messages#A-Cached-Cypress-Binary-Could-not-be-found + # https://docs.cypress.io/guides/continuous-integration/introduction#Caching + CYPRESS_CACHE_FOLDER: ${CI_PROJECT_DIR}/.cache/Cypress default: @@ -13,10 +19,12 @@ default: paths: - ${RENV_PATHS_CACHE} - ${RENV_PATHS_LIBRARY} + - ${DOT_RHINO_PATH} + - ${CYPRESS_CACHE_FOLDER} Runs linters and tests: before_script: - # Restores renv if not yet cached + # Restores renv when cache is not available. - R -e "options(renv.config.cache.symlinks = FALSE); renv::restore(clean = TRUE);" script: - R -e "rhino::lint_r()"