1

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.

mikita agrawal
  • 571
  • 1
  • 12
  • 27

1 Answers1

1

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

Sergio Tanaka
  • 1,325
  • 1
  • 6
  • 18
  • I think I've figured it out. I am using rootless docker and that could be the reason because it uses vfl file system. I will post another question for that but thank you for the help. – mikita agrawal Dec 02 '20 at 20:31
  • 2
    For us even using cache it's slow as hell trying to cache Cypress folder and then extracting it on other jobs. Too slow to be usable. There's an open issue about this here https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1797 – trainoasis Mar 22 '21 at 12:38
  • Ended up skipping cache and doing npm install on all steps, it was faster. – Kim Nov 09 '21 at 10:20