firecow / gitlab-ci-local

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

before_script, script and after_script can be strings #1043

Closed hverlin closed 11 months ago

hverlin commented 11 months ago

Minimal .gitlab-ci.yml illustrating the issue

---
test-job:
  before_script: echo "Before test"
  script: echo "Test something"
  after_script: echo "After something"

Expected behavior example job logs

Host information Ubuntu gitlab-ci-local 4.1.33

Containerd binary Docker

Additional context The spec indicates this it should be an array. However, the implementation seems to support plain strings: https://docs.gitlab.com/ee/ci/yaml/#before_script

The example for scripts shows a plain string being used: https://docs.gitlab.com/ee/ci/yaml/#script image

image

Currently, gitlab-ci-local crashes with the following error:

    TypeError: job.beforeScripts.forEach is not a function

      74 |         for (const job of jobs) {
      75 |             if (job.trigger) continue;
    > 76 |             job.beforeScripts.forEach((s: any) => assert(typeof s === "string", chalk`{blue ${job.name}} before_script contains non string value`));
         |                               ^
      77 |             job.afterScripts.forEach((s: any) => assert(typeof s === "string", chalk`{blue ${job.name}} after_script contains non string value`));
      78 |             job.scripts.forEach((s: any) => assert(typeof s === "string", chalk`{blue ${job.name}} script contains non string value`));
      79 |         }
hverlin commented 11 months ago

@firecow Would it be possible to release a new version? Or otherwise, do you know when a new one will be available?

firecow commented 11 months ago

I'll make a release during the weekend @hverlin 👍

hverlin commented 11 months ago

Thanks!