简体   繁体   中英

Gitlab pipeline running very slow

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM