-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-declarative.sh
More file actions
executable file
·35 lines (28 loc) · 1.04 KB
/
test-declarative.sh
File metadata and controls
executable file
·35 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -e
# Test all YAML/YML files for syntax
find . -type f \( -name '*.yml' -o -name '*.yaml' \) | while read -r file; do
echo "Testing YAML syntax: $file"
python3 -c "import sys, yaml; yaml.safe_load(open(sys.argv[1]))" "$file" || exit 1
done
echo "All YAML/YML files passed syntax check."
# Test all Dockerfiles with hadolint if available, else basic syntax via docker
if command -v hadolint &> /dev/null; then
find . -type f -name 'Dockerfile*' | while read -r file; do
echo "Linting Dockerfile: $file"
hadolint "$file" || exit 1
done
else
find . -type f -name 'Dockerfile*' | while read -r file; do
echo "Checking Dockerfile syntax: $file"
docker run --rm -i hadolint/hadolint < "$file" || exit 1
done
fi
echo "All Dockerfiles passed lint/syntax check."
# Test all JSON files for syntax
find . -type f -name '*.json' | while read -r file; do
echo "Testing JSON syntax: $file"
python3 -m json.tool "$file" > /dev/null || exit 1
done
echo "All JSON files passed syntax check."
echo "All declarative files are valid!"