bahmutov / cypress-split

Split Cypress specs across parallel CI machines for speed
MIT License
199 stars 22 forks source link

Error: Do not know how to determine the correct split - Gitlab CI and Docker compose #239

Closed TimOleSanmann closed 3 months ago

TimOleSanmann commented 3 months ago

Hello,

in my Gitlab CI I start a testing environment via docker compose and I start Cypress through an entrypoint in a compose file. So far, Gitlab correctly splits to 4 parallel jobs but when Cypress starts I've got the error "Error: Do not know how to determine the correct split" Can this be a problem of used environment variables or something simmilar?

Docker compse part:

cypress:
    image: entdecken-test-cypress:latest
    depends_on:
      entdecken:
        condition: service_healthy
      kaufen-mock:
        condition: service_started
      nginx:
        condition: service_started
      mailservice:
        condition: service_started
    env_file: docker.integration.env
    entrypoint: cypress run ./node_modules/.bin/cypress run --reporter junit --reporter-options mochaFile='./cypressLog/CYPRESSTESTS-integration-[hash].xml' --config-file ./cypress/cypress.config.js --env split=true
    ports:
      - 7000:7000

Gitlab ci part:

test:integration:
  tags:
    - ecom-shared
  services:
    - name: docker:dind-rootless
  only:
    - merge_requests
    - master
  stage: test
  needs: ["build:node", "build:images"]
  dependencies:
    - build:node
    - build:images
  parallel: 4
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker buildx build --target cypress -t entdecken-test-cypress:latest .
    - docker load -i kaufen-mock-image.tar
    - docker compose -f docker-compose.gitlab-ci.yml up --exit-code-from cypress
TimOleSanmann commented 3 months ago

I already found a solution myself: in the src/parse-inputs.js cypress-splits requires some env variables from Gitlab. Those has to be put into the. "environment" clause in the compose file. Then it works.

  environment:
      - CI_NODE_INDEX=${CI_NODE_INDEX}
      - CI_NODE_TOTAL=${CI_NODE_TOTAL}