Skip to content

WIP: CI verify yaml in markdown files

Ben Bodenmiller requested to merge patch-177 into master

What does this MR do?

CI verify each yaml code block in Markdown files via yamllint.

e.g. from https://gitlab.com/gitlab-org/gitlab/blob/master/doc/ci/yaml/README.md

```yaml
job1:
  script: "execute-script-for-job1"

job2:
  script: "execute-script-for-job2"
```

Idea from !35894 (comment 373597038)

a CI script that pulls out all the yaml codeblock, saves them as files and pipes those into yamllint. If you name the created file after the source file + line number, it would be easily findable. Something like YAMLLINT Error in 'source-file-md-line-123.yml', incorrect blah blah blah.

Todo:

  • regex to find code blocks
  • in ci, for each code block write to new temporary file named something like source-file-md-line-123.yml
    • use original file name then append line number where code block starts
  • make pipeline runs for doc changes

regex to find code blocks - working notes:

(?<=```yaml).*?(?=```) - https://regexr.com/

(?s)(?<=```yaml).*?(?=```) - https://regex101.com/

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Ben Bodenmiller

Merge request reports