firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.03k stars 115 forks source link

Rules evaluation is incorrect and it doesn't stop after the first match #1252

Closed vivek9ru3 closed 3 weeks ago

vivek9ru3 commented 4 weeks ago

Minimal .gitlab-ci.yml illustrating the issue

---
variables:
  VAR1: val1
  VAR2: val2

Test:
  script:
    - echo "hello"
  rules:
    - if: $VAR1 == 'val1'
    - if: $VAR2 == 'val2'
      when: never

Running gitlab-ci-local --list with the above gitlab ci configuration produces incorrect results (it doesn't list the Test job)

parsing and downloads finished in 63 ms
json schema validated in 95 ms
name  description  stage   when   allow_failure  needs

Expected behavior gitlab-ci-local --list should list the "Test" job as the first rule evaluates to true.

Host information Mac 14.4.1 gitlab-ci-local 4.50.0 and above

Additional context This started happening with version 4.50.0. Possibly due to https://github.com/firecow/gitlab-ci-local/commit/ef8097bedca05230bef15a3f52d395a6414eef23 as it doesn't stop evaluating rules unless when = never

But Gitlab docs for rules says

Rules are evaluated when the pipeline is created, and evaluated in order until the first match

vivek9ru3 commented 4 weeks ago

A small change to fix this issue https://github.com/firecow/gitlab-ci-local/pull/1253