Skip to content

Commit 6aacccf

Browse files
authored
Merge pull request #1 from apollosolutions/feat/kubernetes-deployment
feat: Add Kubernetes deployment support
2 parents cf4ba4a + ed359aa commit 6aacccf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5786
-362
lines changed

.github/workflows/supergraph.graphql

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/test.yaml

Lines changed: 200 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,207 @@
1+
---
2+
name: Test Apollo Supergraph
3+
14
on:
5+
pull_request:
6+
branches:
7+
- main
28
push:
3-
paths:
4-
- Dockerfile
5-
- router.yaml
6-
- .github/workflows/test.yaml
7-
- .github/workflows/supergraph.graphql
9+
branches:
10+
- main
11+
812
jobs:
9-
test:
10-
name: Smoke test Router
13+
test-subgraphs:
14+
name: Test Subgraphs
1115
runs-on: ubuntu-latest
1216
steps:
1317
- name: Checkout
1418
uses: actions/[email protected]
15-
- name: Build Docker image
16-
run: docker build -t router .
17-
- name: Run Router
18-
run: docker run -d --name router -p 4000:4000 -v ./.github/workflows/supergraph.graphql:/dist/supergraph.graphql router -s supergraph.graphql
19-
- name: Wait for Router to start
20-
run: sleep 5
21-
- name: Test Router
22-
run: |
23-
curl http://localhost:4000 -d '{"query": "query{__typename}"}' -H "Content-Type: application/json"
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '18'
24+
cache: 'npm'
25+
cache-dependency-path: subgraphs/package-lock.json
26+
27+
- name: Install dependencies
28+
run: |
29+
cd subgraphs
30+
npm ci
31+
32+
- name: Test subgraphs validation
33+
run: |
34+
cd subgraphs
35+
if npm run | grep -q "validate"; then
36+
npm run validate
37+
else
38+
echo "No validate script found, skipping"
39+
fi
40+
41+
test-supergraph-composition:
42+
name: Test Supergraph Composition
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/[email protected]
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: '18'
52+
53+
- name: Install Rover CLI
54+
run: |
55+
curl -sSL https://rover.apollo.dev/nix/latest | sh
56+
echo "$HOME/.rover/bin" >> $GITHUB_PATH
57+
58+
- name: Test supergraph composition
59+
run: |
60+
cd router
61+
./compose.sh
62+
63+
# Verify the supergraph file was created
64+
if [ ! -f "supergraph.graphql" ]; then
65+
echo "❌ Supergraph composition failed - file not created"
66+
exit 1
67+
fi
68+
69+
# Verify the supergraph contains expected content
70+
if ! grep -q "join__Graph" supergraph.graphql; then
71+
echo "❌ Supergraph composition failed - missing join__Graph"
72+
exit 1
73+
fi
74+
75+
echo "✅ Supergraph composition successful"
76+
77+
test-docker-builds:
78+
name: Test Docker Builds
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout
82+
uses: actions/[email protected]
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v3
86+
87+
- name: Build subgraphs Docker image
88+
run: |
89+
cd subgraphs
90+
docker build -t subgraphs:test .
91+
92+
# Verify the image was created
93+
if ! docker images | grep -q "subgraphs.*test"; then
94+
echo "❌ Docker build failed for subgraphs"
95+
exit 1
96+
fi
97+
98+
echo "✅ Subgraphs Docker build successful"
99+
100+
test-scripts:
101+
name: Test Helper Scripts
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Checkout
105+
uses: actions/[email protected]
106+
107+
- name: Test script syntax
108+
run: |
109+
# Test that all scripts have valid syntax
110+
for script in *.sh; do
111+
if [ -f "$script" ]; then
112+
echo "Testing syntax for $script"
113+
bash -n "$script" || exit 1
114+
fi
115+
done
116+
117+
# Test scripts in scripts directory
118+
if [ -d "scripts" ]; then
119+
for script in scripts/*.sh; do
120+
if [ -f "$script" ]; then
121+
echo "Testing syntax for $script"
122+
bash -n "$script" || exit 1
123+
fi
124+
done
125+
fi
126+
127+
echo "✅ All scripts have valid syntax"
128+
129+
- name: Test script help options
130+
run: |
131+
# Test that scripts with help options work
132+
./run-k8s.sh --help || exit 1
133+
./cleanup-k8s.sh --help || exit 1
134+
./kill-minikube.sh --help || exit 1
135+
./setup-minikube.sh --help || exit 1
136+
./setup-env.sh --help || exit 1
137+
138+
echo "✅ All script help options working"
139+
140+
test-k8s-yaml:
141+
name: Test Kubernetes YAML Format
142+
runs-on: ubuntu-latest
143+
steps:
144+
- name: Checkout
145+
uses: actions/[email protected]
146+
147+
- name: Install yamllint
148+
run: |
149+
pip install yamllint
150+
151+
- name: Validate YAML files
152+
run: |
153+
# Test all YAML files in k8s directory
154+
if [ -d "k8s" ]; then
155+
for yaml_file in k8s/*.yaml; do
156+
if [ -f "$yaml_file" ]; then
157+
echo "Validating YAML format: $yaml_file"
158+
yamllint "$yaml_file" || exit 1
159+
fi
160+
done
161+
fi
162+
163+
# Test GitHub Actions workflows
164+
for workflow in .github/workflows/*.yaml; do
165+
if [ -f "$workflow" ]; then
166+
echo "Validating workflow: $workflow"
167+
yamllint "$workflow" || exit 1
168+
fi
169+
done
170+
171+
echo "✅ All YAML files have valid format"
172+
173+
- name: Test Kubernetes manifest structure
174+
run: |
175+
# Basic structure validation without kubectl
176+
echo "Testing Kubernetes manifest structure..."
177+
178+
# Check if required files exist
179+
required_files=("k8s/namespace.yaml" \
180+
"k8s/subgraphs-deployment-clusterip.yaml" \
181+
"k8s/router-deployment-clusterip.yaml" \
182+
"k8s/ingress.yaml")
183+
184+
for file in "${required_files[@]}"; do
185+
if [ ! -f "$file" ]; then
186+
echo "❌ Required Kubernetes manifest missing: $file"
187+
exit 1
188+
fi
189+
echo "✅ Found: $file"
190+
done
191+
192+
# Check for basic Kubernetes resource types
193+
for file in k8s/*.yaml; do
194+
if [ -f "$file" ]; then
195+
echo "Checking $file for Kubernetes resource types..."
196+
if ! grep -q "kind:" "$file"; then
197+
echo "❌ No 'kind:' field found in $file"
198+
exit 1
199+
fi
200+
if ! grep -q "apiVersion:" "$file"; then
201+
echo "❌ No 'apiVersion:' field found in $file"
202+
exit 1
203+
fi
204+
fi
205+
done
206+
207+
echo "✅ All Kubernetes manifests have basic structure"

.github/workflows/update-router-config.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.gitignore

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
.env
1+
# Environment files
2+
.env
3+
router/.env
4+
5+
# Node.js
6+
node_modules/
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
11+
# Generated files
12+
router/supergraph.graphql
13+
14+
# IDE files
15+
.idea/
16+
.vscode/
17+
*.swp
18+
*.swo
19+
*~
20+
21+
# OS files
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Logs
26+
*.log
27+
logs/
28+
29+
# Temporary files
30+
*.tmp
31+
*.temp
32+
*.backup
33+
34+
# Docker
35+
.dockerignore
36+
37+
# Kubernetes
38+
*.kubeconfig
39+
40+
# Build artifacts
41+
dist/
42+
build/

.idea/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.idea/graphql-settings.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)