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 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..b4bc85293 --- /dev/null +++ b/inst/templates/gitlab_ci/dot.gitlab-ci.yml @@ -0,0 +1,36 @@ +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: + # 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} + - ${DOT_RHINO_PATH} + - ${CYPRESS_CACHE_FOLDER} + +Runs linters and tests: + before_script: + # 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()" + - 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