Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions .github/workflows/ci_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ on:
pull_request:
branches: [master, 'stabilization*']
permissions:
contents: read
contents: read
jobs:
yamllint:
name: Yaml Lint on Changed Controls and Profiles Files
name: Yaml Lint on Changed yaml files
runs-on: ubuntu-latest
steps:
- name: Install Git
Expand All @@ -27,37 +27,16 @@ jobs:
url="repos/$repo/pulls/$pr_number/files"
response=$(gh api "$url" --paginate)
echo "$response" | jq -r '.[].filename' > filenames.txt
cat filenames.txt

if grep -q "controls/" filenames.txt; then
echo "CONTROLS_CHANGES=true" >> $GITHUB_ENV
else
echo "CONTROLS_CHANGES=false" >> $GITHUB_ENV
fi
if grep -q "\.profile" filenames.txt; then
echo "PROFILES_CHANGES=true" >> $GITHUB_ENV
else
echo "PROFILES_CHANGES=false" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install yamllint
if: ${{ env.CONTROLS_CHANGES == 'true' || env.PROFILES_CHANGES == 'true' }}
run: pip install yamllint

- name: Run yamllint in Control Files Modified by PR
if: ${{ env.CONTROLS_CHANGES == 'true' }}
run: |
for control_file in $(cat filenames.txt | grep "controls/"); do
echo "Running yamllint on $control_file..."
yamllint "$control_file"
done

- name: Run yamllint in Profile Files Modified by PR
if: ${{ env.PROFILES_CHANGES == 'true' }}
- name: Run yamllint on files modified by the PR
run: |
for profile_file in $(cat filenames.txt | grep "\.profile"); do
echo "Running yamllint on $profile_file..."
yamllint "$profile_file"
for file in $(cat filenames.txt); do
echo "Running yamllint on $file..."
yamllint -c .yamllint "$file"
done
18 changes: 13 additions & 5 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
---
extends: default
locale: en_US.UTF-8
yaml-files:
- "*.yaml"
- "*.yml"
- "*.fmf"

# https://yamllint.readthedocs.io/en/stable/rules.html
rules:
comments: disable
comments-indentation: disable
document-start: disable
truthy: disable # do not check for strict true / false boolean values
comments: disable # disable syntax checking of comments
comments-indentation: disable # disable indentation checks for comments
document-start: disable # do not require the document start marker
empty-lines:
level: warning
level: warning # only warn about empty lines
indentation:
# pass if spaces are used for indentation and number of spaces is consistent through a file
spaces: consistent
line-length: disable
line-length:
max: 99 # allow lines up to 99 chars
Loading