Skip to content

yamllint: cover all changed files ending in yaml, yml or fmf#14601

Open
vojtapolasek wants to merge 8 commits intoComplianceAsCode:masterfrom
vojtapolasek:make_yamllint_filepaths_stricter
Open

yamllint: cover all changed files ending in yaml, yml or fmf#14601
vojtapolasek wants to merge 8 commits intoComplianceAsCode:masterfrom
vojtapolasek:make_yamllint_filepaths_stricter

Conversation

@vojtapolasek
Copy link
Copy Markdown
Collaborator

@vojtapolasek vojtapolasek commented Mar 26, 2026

Description:

  • update the ci-lint workflow to utilize .yamllint config file present in the root of the project
  • update the .yamllint config file to implement some of project's style requirements
  • apply yamllint to all files which are being changed by a PR, let yamllint ignore files which are not matching yml, yaml or fmf extensions

Rationale:

  • The previous grep "controls/" pattern matched any file path containing controls/, which could include non-YAML files that yamllint cannot process. Restricting to controls/.*\.yml ensures only relevant YAML files are linted, avoiding spurious CI failures.

Review Hints:

  • Single-commit, single-line change in .github/workflows/ci_lint.yml (line 52).
  • No product builds are affected — this is a CI infrastructure change only.

if: ${{ env.CONTROLS_CHANGES == 'true' }}
run: |
for control_file in $(cat filenames.txt | grep "controls/"); do
for control_file in $(cat filenames.txt | grep "controls/.*\.yml"); do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a similar regex on line 32. Should that regex be changed as well?

@comps
Copy link
Copy Markdown
Collaborator

comps commented Mar 27, 2026

Are you sure you don't want to configure yamllint properly instead, as I suggested in #14529 (comment) ?

@vojtapolasek vojtapolasek force-pushed the make_yamllint_filepaths_stricter branch from 8ca69d6 to d48dd28 Compare March 27, 2026 11:48
Filter out files inside the .yamllint configuration
@vojtapolasek vojtapolasek force-pushed the make_yamllint_filepaths_stricter branch from d48dd28 to 975e2d6 Compare March 27, 2026 11:55
@vojtapolasek vojtapolasek force-pushed the make_yamllint_filepaths_stricter branch from b803433 to 02bffa8 Compare March 27, 2026 13:55
@vojtapolasek vojtapolasek changed the title yamllint: make control file path matching stricter in CI lint workflow yamllint: cover all changed files ending in yaml, yml or fmf Mar 27, 2026
Copy link
Copy Markdown
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vojtapolasek Do I understand it well that now the .profile files won't be checked?

@vojtapolasek
Copy link
Copy Markdown
Collaborator Author

@jan-cerny oops, correct, I have to fix this.

@jan-cerny
Copy link
Copy Markdown
Collaborator

/retest

yamllint "$profile_file"
for file in $(cat filenames.txt); do
echo "Running yamllint on $file..."
yamllint -c .yamllint "$file"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will run yamllint on all files modified by the PR, think OVALs, Python files, ... It can slow the job down.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will not slow things down, the .yamllint config file explicitly specifies globs which will be actually scanned.

if grep -q "\.profile" filenames.txt; then
echo "PROFILES_CHANGES=true" >> $GITHUB_ENV
else
echo "PROFILES_CHANGES=false" >> $GITHUB_ENV
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed this insertion of PROFILES_CHANGES and CONTROL_CHANGES environment variables to GITHUB_ENV. But, the "Install yamllint" phase still uses these environment variables. I suspect it doesn't work.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the leftover conditional.

echo "Running yamllint on $profile_file..."
yamllint "$profile_file"
for file in $(cat filenames.txt); do
echo "Running yamllint on $file..."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on YAML files that contain Jinja macros?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the last commit I added a script which strips Jinja and still allows us to lint files.

spaces: consistent
line-length: disable
line-length:
max: 99 # allow lines up to 99 chars
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all our YAML files meet the line lenghth limit of 99 lines?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They probably don't, but this should run only on newly modified files. At the same time, we impose this limit on our selves... so with this approach, it will be enforced gradually. Do you think it is a problem?

vojtapolasek and others added 2 commits April 2, 2026 10:28
Many YAML files in this project contain Jinja2 templating ({{% %}},
{{{ }}}, {{# #}}) which causes yamllint to report false syntax errors.

Add a helper script (utils/strip_jinja_for_yamllint.py) that removes
Jinja constructs while preserving line numbers, and update the CI
workflow to use it for files that contain Jinja. Files without Jinja
are linted directly as before. Warnings are reported but do not fail
the job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants