Skip to content

Improve linter by going deeper into pipeline generation

Problem to solve

The CI Lint currently uses YamlProcessor to validate the content passed in. The YamlProcessor represents a small part of the whole pipeline creation process and it only covers syntax errors. Using YamlProcessor today it gives a false sense of validation to users because it can return that a configuration is valid but when trying to create a pipeline it fails for some other reasons not considered before. Typical examples are logical validations that occur beyond the YamlProcessor.

Example: The following syntax is considered valid by CI Lint but it would return an error test: needs 'build' when trying to actually create the pipeline.

build:
  script: echo
  stage: build
  rules:
    - if: '$CI_MERGE_REQUEST_ID'
test:
  script: echo
  stage: test
  needs: [build]

Intended users

User experience goal

Improved understanding of errors at lint-time.

Proposal

We will introduce a new mode in Ci::CreatePipelineService called dry_run: true (which is false by default). This mode would skip persisting the pipeline while letting everything else happening. In the end, a non-persisted pipeline is returned including any errors and (recently added) warnings.

Then we change the Lint controller to use Ci::CreatePipelineService with dry_run: true and pass in the content to validate.

Further details

Permissions and Security

Documentation

Availability & Testing

  • Unit test changes - Yes, please add unit tests along with new/updated logics
  • Integration test changes - not required
  • End-to-end test change - not required

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Links / references

Edited by Tiffany Rea