Gitlab pipeline running very slow

9.4k views Asked by At

I am using Gitlab as my DevOps platform and running pipeline in docker container. So i am using docker executor and my runner is running as a docker container. Below is my gitlab-ci.yml file which is doing nothing but npm install cypress

stages:
  - release

release:
  image: node:12.19.0
  stage: release
  only:
    refs:
      - master
      - alpha
      - /^(([0-9]+)\.)?([0-9]+)\.x/
      - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
  before_script:
    - export http_proxy=http://17.14.45.41:8080/
    - export https_proxy=http://17.14.45.41:8080/
    - echo 'strict-ssl=false'>>.npmrc
  script:
    # - npm ci
    - npm install cypress

When i run this job, it takes almost 12 minutes which is hell lot of time. My Gitlab is self hosted and I am using proxy to talk to outside world but I don't think proxy has any issue because when i do docker pull it works fine and runs instantly.

I don't know if there is anything I could do or I am missing in Gitlab configuration but if anyone has any ideas please let me know. That will be great help.

1

There are 1 answers

3
Sergio Tanaka On

I don't know your project and if you have too much dependencies do download and install.

To improve the performance, you need to use the cache https://docs.gitlab.com/ee/ci/caching/ feature of gitlab

but, before doing it, you need to configure the cypress cache folder using the environment variable CYPRESS_CACHE_FOLDER https://docs.cypress.io/guides/getting-started/installing-cypress.html#Environment-variables, look at my example below

CYPRESS_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/Cypress'

I'm telling to cypress to download all the dependencies and binaries to this specific folder, and after that, I configured the gitlab to cache this folder

  stage: ci
  cache:
    paths:
      - cache/Cypress

In your case your .gitlab-ci.yml file will be

stages:
  - release

release:
  image: node:12.19.0
  variables:
    CYPRESS_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/Cypress'
  stage: release
  cache:
    paths:
      - cache/Cypress
  only:
    refs:
      - master
      - alpha
      - /^(([0-9]+)\.)?([0-9]+)\.x/
      - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
  before_script:
    - export http_proxy=http://17.14.45.41:8080/
    - export https_proxy=http://17.14.45.41:8080/
    - echo 'strict-ssl=false'>>.npmrc
  script:
    # - npm ci
    - npm install cypress

But don't forget you need to configure the cache depending of executor you are using. The details about it you can get from the gitlab docs