Skip to content

Commit

Permalink
ci: add validation with yamllint (#951)
Browse files Browse the repository at this point in the history
* ci: add validation with yamllint

* use makefile

* disable warnings for comments-indentation

* fix configuration for comments-indentation
  • Loading branch information
dklimpel authored Dec 26, 2024
1 parent 00e9355 commit b563479
Show file tree
Hide file tree
Showing 22 changed files with 450 additions and 423 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
permissions:
packages: write
contents: read
security-events: write # To upload Trivy sarif files
security-events: write # To upload Trivy sarif files

steps:
- name: Checkout
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Validate YAML

on:
push:
branches:
- master
pull_request:
paths:
- "**/*.ya?ml"

jobs:
validate-yaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate YAML file
run: make lint-yaml
21 changes: 20 additions & 1 deletion .yamllint
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
---
extends: default

ignore:
# uses go templates (these are invalid yaml files)
- integration-tests/goss/goss-service.yaml
- integration-tests/goss/goss-shared.yaml
- docs/goss.yaml

rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 1 # required for schema.yaml
brackets:
min-spaces-inside: 0
max-spaces-inside: 1 # required for schema.yaml
comments-indentation: disable
indentation:
spaces: consistent
indent-sequences: consistent
line-length: disable
document-start: disable
truthy:
allowed-values:
- on
- "on" # required for github workflows
- "false"
- "true"
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ dcgoss-sha256:
kgoss-sha256:
cd extras/kgoss/ && sha256sum kgoss > kgoss.sha256

.PHONY: lint-yaml
lint-yaml:
$(info INFO: Starting $@)
yamllint -c .yamllint .

$(PYTHON):
$(info Creating virtualenv in $(VENV))
@python -m venv $(VENV)
Expand Down
12 changes: 4 additions & 8 deletions docs/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ command:
stdout:
- go version go1.6 linux/amd64
stderr: []
timeout: 10000 # in milliseconds
timeout: 10000 # in milliseconds
skip: false

dns:
Expand Down Expand Up @@ -64,7 +64,7 @@ group:
gid: 65534
nobody:
exists: true


http:
https://www.google.com:
Expand Down Expand Up @@ -190,14 +190,14 @@ user:
home: /var/lib/nfs
shell: /sbin/nologin
skip: false

nobody:
exists: true
uid:
lt: 500
groups:
consist-of: [nobody]

sshd:
title: UID must be between 50-100, GID doesn't matter. home is flexible
meta:
Expand All @@ -216,7 +216,3 @@ user:
- /var/run/sshd

# https://github.com/goss-org/goss/blob/master/README.md#manually-editing-goss-files




2 changes: 1 addition & 1 deletion docs/myapp_gossfile.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This is a sample file referenced by goss.yaml
# Used for render test and Json schema validation.
# Used for render test and Json schema validation.
Loading

0 comments on commit b563479

Please sign in to comment.