CI: Run yamllint on added or modified YAML files

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2020-06-19 15:49:31 +02:00 committed by nphilipp
parent 5e735e8263
commit 24deb169fb
3 changed files with 46 additions and 0 deletions

14
.yamllint.yaml Normal file
View File

@ -0,0 +1,14 @@
---
extends: default
rules:
indentation:
spaces: 2
indent-sequences: whatever
level: warning
line-length:
max: 100
level: warning
truthy:
allowed-values: ['true', 'false', 'yes', 'no']
...

View File

@ -19,8 +19,16 @@
parent: fi-ansible--ansible-review-base
run: ci/ansible-review-diff.yaml
- job:
name: fi-ansible--yamllint-diff
run: ci/yamllint-diff.yaml
files:
- \.yml$
- \.yaml$
- project:
check:
jobs:
- fi-ansible--zuul-jobs-verify-namespace
- fi-ansible--ansible-review-diff
- fi-ansible--yamllint-diff

24
ci/yamllint-diff.yaml Normal file
View File

@ -0,0 +1,24 @@
---
- hosts: all
tasks:
- name: Install yamllint
package:
name: yamllint
state: latest
- name: Determine added or modified YAML files
command:
cmd: >
git diff --name-only --diff-filter=AM
origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }}
args:
chdir: '{{ zuul.project.src_dir }}'
register: fi_ansible__added_modified_yaml_files
changed_when: "False"
failed_when: fi_ansible__added_modified_yaml_files.rc != 0
- name: Run yamllint on changed YAML files
command: yamllint {{ item }}
args:
chdir: '{{ zuul.project.src_dir }}'
with_items: "{{ fi_ansible__added_modified_yaml_files.stdout_lines | list }}"