Skip to content

Commit 1746b62

Browse files
committed
feat: add YAML linting to local tests
- Add --yaml option to test-local.sh for YAML formatting tests - Include YAML linting in default 'all' tests - Test Kubernetes manifests in k8s/ directory - Test router configuration YAML file - Auto-install yamllint if not available - Update test summary to include YAML formatting results
1 parent c026891 commit 1746b62

File tree

2 files changed

+85
-22
lines changed

2 files changed

+85
-22
lines changed

k8s/router-deployment-clusterip.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ spec:
1717
app: apollo-router
1818
spec:
1919
containers:
20-
- name: apollo-router
21-
image: ghcr.io/apollographql/router:v2.5.0
22-
ports:
23-
- containerPort: 4000
24-
name: graphql
25-
- containerPort: 8088
26-
name: health
27-
env:
28-
- name: APOLLO_GRAPH_REF
29-
value: "${APOLLO_GRAPH_REF}"
30-
- name: APOLLO_KEY
31-
value: "${APOLLO_KEY}"
32-
- name: PORT
33-
value: "4000"
34-
volumeMounts:
20+
- name: apollo-router
21+
image: ghcr.io/apollographql/router:v2.5.0
22+
ports:
23+
- containerPort: 4000
24+
name: graphql
25+
- containerPort: 8088
26+
name: health
27+
env:
28+
- name: APOLLO_GRAPH_REF
29+
value: "${APOLLO_GRAPH_REF}"
30+
- name: APOLLO_KEY
31+
value: "${APOLLO_KEY}"
32+
- name: PORT
33+
value: "4000"
34+
volumeMounts:
3535
- name: router-config
3636
mountPath: /dist/config.yaml
3737
subPath: config.yaml
@@ -62,13 +62,13 @@ spec:
6262
port: 8088
6363
initialDelaySeconds: 5
6464
periodSeconds: 5
65-
volumes:
66-
- name: router-config
67-
configMap:
68-
name: router-config
69-
- name: supergraph-schema
70-
configMap:
71-
name: supergraph-schema
65+
volumes:
66+
- name: router-config
67+
configMap:
68+
name: router-config
69+
- name: supergraph-schema
70+
configMap:
71+
name: supergraph-schema
7272
---
7373
apiVersion: v1
7474
kind: Service

test-local.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3941
TEST_SUBGRAPHS=true
4042
TEST_COMPOSITION=true
4143
TEST_DOCKER=true
4244
TEST_ROUTER=true
45+
TEST_YAML=true
4346

4447
# Parse command line arguments
4548
while [[ $# -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"
201217
fi
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
204264
if [ "$TEST_ROUTER" = true ]; then
205265
print_status "Testing router and subgraphs functionality..."
@@ -311,6 +371,9 @@ fi
311371
if [ "$TEST_DOCKER" = true ]; then
312372
echo " ✅ Docker builds"
313373
fi
374+
if [ "$TEST_YAML" = true ]; then
375+
echo " ✅ YAML formatting"
376+
fi
314377
if [ "$TEST_ROUTER" = true ]; then
315378
echo " ✅ Router and subgraphs functionality"
316379
fi

0 commit comments

Comments
 (0)