Update .gitea/workflows/lint.yaml
All checks were successful
Check with kubeconform / lint (push) Successful in 10s
All checks were successful
Check with kubeconform / lint (push) Successful in 10s
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
name: Check with kubeconform
|
name: Check with kubeconform
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -16,22 +14,53 @@ jobs:
|
|||||||
- name: Kubeconform validation
|
- name: Kubeconform validation
|
||||||
id: kubeconform
|
id: kubeconform
|
||||||
run: |
|
run: |
|
||||||
|
# Create exclusion list - add files that should be skipped from validation
|
||||||
|
EXCLUSIONS=(
|
||||||
|
"./k8s/core/system-upgrade/crd.yaml"
|
||||||
|
# Add more files here as needed
|
||||||
|
# "./path/to/another/file.yaml"
|
||||||
|
)
|
||||||
|
|
||||||
# Create a temporary file for storing validation output
|
# Create a temporary file for storing validation output
|
||||||
VALIDATION_OUTPUT=$(mktemp)
|
VALIDATION_OUTPUT=$(mktemp)
|
||||||
|
|
||||||
# Run kubeconform and capture output
|
# Function to check if file is in exclusions
|
||||||
find . -name '*.yaml' \
|
is_excluded() {
|
||||||
|
local file="$1"
|
||||||
|
for exclusion in "${EXCLUSIONS[@]}"; do
|
||||||
|
if [[ "$file" == "$exclusion" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find all yaml files and filter out exclusions
|
||||||
|
YAML_FILES=()
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
if ! is_excluded "$file"; then
|
||||||
|
YAML_FILES+=("$file")
|
||||||
|
else
|
||||||
|
echo "⚠️ Skipping excluded file: $file"
|
||||||
|
fi
|
||||||
|
done < <(find . -name '*.yaml' \
|
||||||
! -name '*values.yaml' \
|
! -name '*values.yaml' \
|
||||||
! -path './.gitea/*' \
|
! -path './.gitea/*' \
|
||||||
-print0 \
|
-print0)
|
||||||
| xargs -0 kubeconform \
|
|
||||||
-summary \
|
# Run kubeconform only if there are files to validate
|
||||||
-verbose \
|
if [ ${#YAML_FILES[@]} -gt 0 ]; then
|
||||||
-output pretty \
|
printf '%s\0' "${YAML_FILES[@]}" | xargs -0 kubeconform \
|
||||||
-ignore-missing-schemas \
|
-summary \
|
||||||
-schema-location default \
|
-verbose \
|
||||||
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
-output pretty \
|
||||||
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT 2>&1 || true
|
-ignore-missing-schemas \
|
||||||
|
-schema-location default \
|
||||||
|
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
||||||
|
-schema-location 'https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/kustomization.json' > $VALIDATION_OUTPUT 2>&1 || true
|
||||||
|
else
|
||||||
|
echo "No files to validate after applying exclusions" > $VALIDATION_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
# Display output in logs
|
# Display output in logs
|
||||||
cat $VALIDATION_OUTPUT
|
cat $VALIDATION_OUTPUT
|
||||||
@@ -44,7 +73,7 @@ jobs:
|
|||||||
cat invalid_files.txt
|
cat invalid_files.txt
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "All manifests are valid!"
|
echo "✅ All manifests are valid!"
|
||||||
fi
|
fi
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user