@@ -27,19 +27,22 @@ show_usage() {
2727 echo " -c, --composition Test supergraph composition only"
2828 echo " -d, --docker Test Docker builds only"
2929 echo " -r, --router Test router only"
30+ echo " -y, --yaml Test YAML formatting only"
3031 echo " -h, --help Show this help message"
3132 echo " "
3233 echo " Examples:"
3334 echo " $0 # Run all tests"
3435 echo " $0 --subgraphs # Test subgraphs only"
3536 echo " $0 --composition # Test composition only"
37+ echo " $0 --yaml # Test YAML formatting only"
3638}
3739
3840# Default values
3941TEST_SUBGRAPHS=true
4042TEST_COMPOSITION=true
4143TEST_DOCKER=true
4244TEST_ROUTER=true
45+ TEST_YAML=true
4346
4447# Parse command line arguments
4548while [[ $# -gt 0 ]]; do
@@ -49,34 +52,47 @@ while [[ $# -gt 0 ]]; do
4952 TEST_COMPOSITION=true
5053 TEST_DOCKER=true
5154 TEST_ROUTER=true
55+ TEST_YAML=true
5256 shift
5357 ;;
5458 -s|--subgraphs)
5559 TEST_SUBGRAPHS=true
5660 TEST_COMPOSITION=false
5761 TEST_DOCKER=false
5862 TEST_ROUTER=false
63+ TEST_YAML=false
5964 shift
6065 ;;
6166 -c|--composition)
6267 TEST_SUBGRAPHS=false
6368 TEST_COMPOSITION=true
6469 TEST_DOCKER=false
6570 TEST_ROUTER=false
71+ TEST_YAML=false
6672 shift
6773 ;;
6874 -d|--docker)
6975 TEST_SUBGRAPHS=false
7076 TEST_COMPOSITION=false
7177 TEST_DOCKER=true
7278 TEST_ROUTER=false
79+ TEST_YAML=false
7380 shift
7481 ;;
7582 -r|--router)
7683 TEST_SUBGRAPHS=false
7784 TEST_COMPOSITION=false
7885 TEST_DOCKER=false
7986 TEST_ROUTER=true
87+ TEST_YAML=false
88+ shift
89+ ;;
90+ -y|--yaml)
91+ TEST_SUBGRAPHS=false
92+ TEST_COMPOSITION=false
93+ TEST_DOCKER=false
94+ TEST_ROUTER=false
95+ TEST_YAML=true
8096 shift
8197 ;;
8298 -h|--help)
@@ -200,6 +216,50 @@ if [ "$TEST_DOCKER" = true ]; then
200216 print_success " Docker build test passed"
201217fi
202218
219+ # Test YAML formatting
220+ if [ " $TEST_YAML " = true ]; then
221+ print_status " Testing YAML formatting..."
222+
223+ # Check if yamllint is available
224+ if ! command_exists yamllint; then
225+ print_warning " yamllint not found, installing..."
226+ if command_exists pip3; then
227+ pip3 install yamllint
228+ elif command_exists pip; then
229+ pip install yamllint
230+ else
231+ print_error " pip not found, cannot install yamllint"
232+ exit 1
233+ fi
234+ fi
235+
236+ # Test all YAML files in k8s directory
237+ if [ -d " k8s" ]; then
238+ print_status " Linting Kubernetes manifests..."
239+ yamllint k8s/ || {
240+ print_error " YAML linting failed"
241+ exit 1
242+ }
243+ print_success " Kubernetes manifests YAML linting passed"
244+ else
245+ print_warning " k8s directory not found, skipping YAML linting"
246+ fi
247+
248+ # Test router configuration YAML
249+ if file_exists " router/router.yaml" ; then
250+ print_status " Linting router configuration..."
251+ yamllint router/router.yaml || {
252+ print_error " Router configuration YAML linting failed"
253+ exit 1
254+ }
255+ print_success " Router configuration YAML linting passed"
256+ else
257+ print_warning " router/router.yaml not found, skipping"
258+ fi
259+
260+ print_success " YAML formatting test passed"
261+ fi
262+
203263# Test router and subgraphs functionality
204264if [ " $TEST_ROUTER " = true ]; then
205265 print_status " Testing router and subgraphs functionality..."
311371if [ " $TEST_DOCKER " = true ]; then
312372 echo " ✅ Docker builds"
313373fi
374+ if [ " $TEST_YAML " = true ]; then
375+ echo " ✅ YAML formatting"
376+ fi
314377if [ " $TEST_ROUTER " = true ]; then
315378 echo " ✅ Router and subgraphs functionality"
316379fi
0 commit comments