Skip to content

Commit

Permalink
ci: Validate Test Yaml (OT-CONTAINER-KIT#854)
Browse files Browse the repository at this point in the history
* ci: Validate Test Yaml

Signed-off-by: Shubham Gupta <[email protected]>

* test: fix yaml intendation

Signed-off-by: Shubham Gupta <[email protected]>

* test: fix yaml via yamlfix

Signed-off-by: Shubham Gupta <[email protected]>

* add line for fun

Signed-off-by: Shubham Gupta <[email protected]>

* feat: run yamlfix in parallel

Signed-off-by: Shubham Gupta <[email protected]>

* chore: fix script

Signed-off-by: Shubham Gupta <[email protected]>

* fix: use root

Signed-off-by: Shubham Gupta <[email protected]>

* fix: add  yaml lint configuration

Signed-off-by: Shubham Gupta <[email protected]>

* fix: changes

Signed-off-by: Shubham Gupta <[email protected]>

* fix: config

Signed-off-by: Shubham Gupta <[email protected]>

* ci: chainsaw example

Signed-off-by: Shubham Gupta <[email protected]>

* fix: long lines

Signed-off-by: Shubham Gupta <[email protected]>

* test: example validation

Signed-off-by: Shubham Gupta <[email protected]>

* fix secrets

Signed-off-by: Shubham Gupta <[email protected]>

* chore: add comment

Signed-off-by: Shubham Gupta <[email protected]>

---------

Signed-off-by: Shubham Gupta <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
  • Loading branch information
shubham-cmyk authored and mattrobinsonsre committed Jul 11, 2024
1 parent e10b2cb commit 00205a4
Show file tree
Hide file tree
Showing 164 changed files with 2,376 additions and 2,349 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/e2e-chainsaw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ on:
- master

jobs:

validate-yaml:
name: Validate YAML
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install yamllint
run: sudo apt-get install -y yamllint
- name: Lint YAML files
run: yamllint --strict ./tests/

test:
name: ${{ matrix.testpath }}
runs-on: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default

rules:
line-length:
max: 200
level: warning
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
comments-indentation: disable
29 changes: 29 additions & 0 deletions hack/yaml-fixer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

export YAMLFIX_LINE_LENGTH="150"

# This script is used to fix the yaml files in the repository.
# Note: yamlfix utility doesn't seems to be much mature idk but it is fixing the .crt .tls .ca extenstion present in testdata

DIR=""

if [ -n "$1" ]; then
DIR="$1"
fi

if which yamlfix >/dev/null; then
echo "yamlfix version is." "$(yamlfix --version)"
else
echo "yamlfix is not installed. Please install it using 'pip install yamlfix'"
exit 0
fi


# Since yamlfix is not able to search in a directory recursively
# run in parallel so stdout is mixed up
if [ -n "$DIR" ]; then
echo "------------------------------"
echo "Fixing all YAML files in the directory and its subdirectories: $DIR"
find "$DIR" \( -name '*.yml' -o -name '*.yaml' \) -type f -print0 | xargs -0 -P 4 -I {} yamlfix "{}"
echo "yamlfix has been applied to all YAML files in $DIR and its subdirectories."
fi
2 changes: 1 addition & 1 deletion tests/_config/chainsaw-configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
Expand Down
15 changes: 8 additions & 7 deletions tests/_config/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: kind
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
- role: control-plane
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
- role: worker
6 changes: 3 additions & 3 deletions tests/_config/kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
startKIND: false
kindConfig: "./kind-config.yaml"
kindConfig: ./kind-config.yaml
parallel: 1
timeout: 1200
testDirs:
Expand All @@ -10,5 +11,4 @@ testDirs:
- tests/e2e/v1beta2/ignore-annots
- tests/e2e/v1beta2/scaling
- tests/e2e/v1beta2/hostnetwork
suppress :
- events
suppress: [events]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
type: Opaque
stringData:
# yamllint disable-line rule:line-length
user.acl: |
user.acl: |-
user opstree on ~* &* +@all >abc@123
user buildpiper on ~* &* +@all >abc@123
Loading

0 comments on commit 00205a4

Please sign in to comment.