Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add validation with yamllint #951

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
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
Loading