10305059
10305059

Reputation: 128

All testcase should run in gitlab instead 1st one failed

I was setting up a gitlab environment. After each push 1 am running 5 test cases. But if the any of the test cases is falling other testcase are skipped. I want to run all the cases. Because they are independent to each other.

gitlab-ci.yml

stages:
  - build
  - unit_test_1
  - unit_test_2
  - unit_test_3

job1:
    stage: build
    script:
        - bash build.sh

job2:
    stage: unit_test_1
    script:
        - bash ./unit_test_1.sh

job3:
    stage: unit_test_2
    script:
        - bash ./unit_test_2.sh

job4:
    stage: unit_test_3
    script:
        - bash ./unit_test_3.sh

If uint_test_1.sh is failing. Other tests are skipped.

Upvotes: 0

Views: 658

Answers (2)

BrokenBinary
BrokenBinary

Reputation: 7879

You can use the when property to make your jobs run every time, regardless of the status of jobs from prior stages of the build.

stages:
  - build
  - test

job1:
    stage: build
    script:
        - bash build.sh

job2:
    stage: test
    when: always
    script:
        - bash ./unit_test_1.sh

job3:
    stage: test
    when: always
    script:
        - bash ./unit_test_2.sh

job4:
    stage: test
    when: always
    script:
        - bash ./unit_test_3.sh

Also, if you want to make sure you never have jobs running in parallel then you can configure your runners with concurrency limits.

Configuring it globally will limit all your runners to only run 1 job concurrently between all runners.

Configuring it per runner will limit that runner to only run 1 job concurrently per build token.

Upvotes: 3

pinage404
pinage404

Reputation: 33

You can try like this:

gitlab-ci.yml

stages:
    - build
    - test

job1:
    stage: build
    script:
        - bash build.sh

job2:
    stage: test
    script:
        - bash ./unit_test_1.sh

job3:
    stage: test
    script:
        - bash ./unit_test_2.sh

job4:
    stage: test
    script:
        - bash ./unit_test_3.sh

The documentation say:

The ordering of elements in stages defines the ordering of builds' execution:

Builds of the same stage are run in parallel. Builds of the next stage are run after the jobs from the previous stage complete successfully.

https://docs.gitlab.com/ce/ci/yaml/README.html#stages

To run in parallel you have to put the same stage name https://docs.gitlab.com/ce/ci/pipelines.html#pipelines

Upvotes: 1

Related Questions