Skip to content

CI CD Integration for Gitlab #589

Description

@DrMeghaS

Discussed in #586

Requesting for automatic integration for Gitlab workflow

Here is the github workflow that I am trying to run in Gitlab

name: Rhino Test
on: push
permissions:
  contents: read
jobs:
  main:
    name: Run linters and tests
    runs-on: ubuntu-20.04
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

      - name: Extract R version from lockfile
        run: printf 'R_VERSION=%s\n' "$(jq --raw-output .R.Version renv.lock)" >> $GITHUB_ENV

      - name: Setup R
        uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ env.R_VERSION }}

      - name: Setup system dependencies
        run: >
          sudo apt-get update && sudo apt-get install --yes
          libcurl4-openssl-dev
          libharfbuzz-dev
          libfribidi-dev 
          gdal-bin
          libgdal-dev
          libudunits2-dev

      - name: Restore renv from cache
        uses: actions/cache@v2
        env:
          CACHE_KEY: renv-${{ runner.arch }}-${{ runner.os }}-${{ env.R_VERSION }}
        with:
          path: renv/library
          key: ${{ env.CACHE_KEY }}-${{ hashFiles('renv.lock') }}
          restore-keys: ${{ env.CACHE_KEY }}-

      - name: Sync renv with lockfile
        shell: Rscript {0}
        run: |
          options(renv.config.cache.symlinks = FALSE)
          renv::restore(clean = TRUE)

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Lint R
        if: always()
        shell: Rscript {0}
        run: rhino::lint_r()

      - name: Lint JavaScript
        if: always()
        shell: Rscript {0}
        run: rhino::lint_js()

      - name: Lint Sass
        if: always()
        shell: Rscript {0}
        run: rhino::lint_sass()

      - name: Build JavaScript
        if: always()
        shell: Rscript {0}
        run: rhino::build_js()

      - name: Build Sass
        if: always()
        shell: Rscript {0}
        run: rhino::build_sass()

      - name: Run R unit tests
        if: always()
        shell: Rscript {0}
        run: rhino::test_r()

      - name: Run Cypress end-to-end tests
        if: always()
        uses: cypress-io/github-action@v2
        with:
          working-directory: .rhino # Created by earlier commands which use Node.js
          start: npm run run-app
          project: ../tests

Here is my updated .gitlab-ci.yml file as referenced from rhino-showcase but it is not working.

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: rhino-base:v1
  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()"
 ```</div>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions