Skip to content

Commit 5d58bdc

Browse files
committed
fix unit test pattern matching e2e tests in CI
Switch CI from Knative-based overlay to Skaffold local-simple profile. Drops Knative operator install (not needed for plain Deployments), uses skaffold run to build image + deploy infra + functions in one step. Faster CI (~30min vs ~45min) with the same e2e test coverage.
1 parent 952a024 commit 5d58bdc

1 file changed

Lines changed: 27 additions & 139 deletions

File tree

.github/workflows/test-k8s-deployment.yaml

Lines changed: 27 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -28,79 +28,42 @@ concurrency:
2828
jobs:
2929
k8s-ci-test:
3030
runs-on: ubuntu-latest
31-
timeout-minutes: 45
31+
timeout-minutes: 30
3232

3333
steps:
3434
- name: Checkout
3535
uses: actions/checkout@v4
3636

37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: "22"
41+
42+
- name: Install pnpm
43+
run: npm install -g pnpm@10.12.2
44+
45+
- name: Install project dependencies
46+
run: pnpm install
47+
48+
- name: Generate workspace packages
49+
run: pnpm generate
50+
3751
- name: Setup kind cluster
3852
uses: helm/kind-action@v1
3953
with:
40-
cluster_name: local
54+
cluster_name: ci
4155
wait: 120s
4256

43-
- name: Install jq (for resource diagnostics)
44-
run: |
45-
sudo apt-get update
46-
sudo apt-get install -y jq
47-
4857
- name: Verify cluster
4958
run: |
5059
kubectl version
5160
kubectl get nodes -o wide
5261
53-
- name: Install Knative (operators-knative-only)
54-
run: |
55-
cd k8s/scripts/setup
56-
make operators-knative-only
57-
58-
- name: Trim Knative resources for CI
62+
- name: Install Skaffold
5963
run: |
60-
set -e
61-
62-
echo "=== Shrinking Knative control-plane resources ==="
63-
64-
echo "Patching knative-serving activator..."
65-
kubectl -n knative-serving set resources deploy/activator \
66-
--requests=cpu=50m,memory=80Mi --limits=cpu=200m,memory=256Mi \
67-
|| echo "WARN: failed to patch activator"
68-
69-
echo "Patching knative-serving autoscaler..."
70-
kubectl -n knative-serving set resources deploy/autoscaler \
71-
--requests=cpu=25m,memory=80Mi --limits=cpu=200m,memory=256Mi \
72-
|| echo "WARN: failed to patch autoscaler"
73-
74-
echo "Patching knative-serving controller..."
75-
kubectl -n knative-serving set resources deploy/controller \
76-
--requests=cpu=50m,memory=100Mi --limits=cpu=300m,memory=512Mi \
77-
|| echo "WARN: failed to patch controller"
78-
79-
echo "Patching knative-serving webhook..."
80-
kubectl -n knative-serving set resources deploy/webhook \
81-
--requests=cpu=25m,memory=80Mi --limits=cpu=200m,memory=256Mi \
82-
|| echo "WARN: failed to patch webhook"
83-
84-
echo "Patching knative net-kourier controller..."
85-
kubectl -n knative-serving set resources deploy/net-kourier-controller \
86-
--requests=cpu=25m,memory=80Mi --limits=cpu=200m,memory=256Mi \
87-
|| echo "WARN: failed to patch net-kourier-controller"
88-
89-
echo "Patching kourier gateway..."
90-
kubectl -n kourier-system set resources deploy/3scale-kourier-gateway \
91-
--requests=cpu=25m,memory=80Mi --limits=cpu=200m,memory=256Mi \
92-
|| echo "WARN: failed to patch 3scale-kourier-gateway"
93-
94-
echo "Optionally shrinking coredns..."
95-
kubectl -n kube-system scale deploy/coredns --replicas=1 || echo "WARN: failed to scale coredns"
96-
kubectl -n kube-system set resources deploy/coredns \
97-
--requests=cpu=50m,memory=70Mi --limits=cpu=200m,memory=170Mi \
98-
|| echo "WARN: failed to patch coredns"
99-
100-
echo "Restarting control-plane pods so resource changes take effect..."
101-
kubectl -n knative-serving rollout restart deploy/activator deploy/autoscaler deploy/controller deploy/webhook deploy/net-kourier-controller || true
102-
kubectl -n kourier-system rollout restart deploy/3scale-kourier-gateway || true
103-
kubectl -n kube-system rollout restart deploy/coredns || true
64+
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
65+
chmod +x skaffold
66+
sudo mv skaffold /usr/local/bin/
10467
10568
- name: Create namespace and GHCR pull secret
10669
env:
@@ -124,96 +87,21 @@ jobs:
12487
echo "GHCR_USERNAME/GHCR_TOKEN not set; assuming images are public."
12588
fi
12689
127-
- name: Sleep for a bit before install
128-
run: |
129-
sleep 10
130-
131-
- name: Apply CI overlay (on top of local)
132-
run: |
133-
cd k8s
134-
kubectl kustomize overlays/ci --load-restrictor=LoadRestrictionsNone | kubectl apply -f -
135-
136-
- name: Sleep for a bit
137-
run: |
138-
sleep 100
90+
- name: Deploy with Skaffold (local-simple)
91+
run: skaffold run -p local-simple
13992

140-
- name: Dump pod resource requests/limits (all namespaces)
141-
if: always()
142-
run: |
143-
echo "=== Per-pod resource requests/limits ==="
144-
kubectl get pods -A -o json \
145-
| jq -r '
146-
.items[]
147-
| .metadata.namespace as $ns
148-
| .metadata.name as $pod
149-
| .spec.containers[]
150-
| [$ns, $pod, .name,
151-
(.resources.requests.cpu // "0"),
152-
(.resources.requests.memory // "0"),
153-
(.resources.limits.cpu // "0"),
154-
(.resources.limits.memory // "0")]
155-
| @tsv
156-
' \
157-
| column -t
158-
159-
echo
160-
echo "=== Aggregated resource requests per namespace (CPU cores, MiB) ==="
161-
kubectl get pods -A -o json \
162-
| jq -r '
163-
[ .items[]
164-
| .metadata.namespace as $ns
165-
| {
166-
ns: $ns,
167-
cpu: ([.spec.containers[].resources.requests.cpu // "0"]
168-
| map(
169-
if test("m$") then (sub("m$";"") | tonumber / 1000)
170-
elif . == "0" then 0
171-
else tonumber
172-
end
173-
)
174-
| add),
175-
memMi: ([.spec.containers[].resources.requests.memory // "0"]
176-
| map(
177-
if test("Gi$") then (sub("Gi$";"") | tonumber * 1024)
178-
elif test("Mi$") then (sub("Mi$";"") | tonumber)
179-
elif . == "0" then 0
180-
else 0
181-
end
182-
)
183-
| add)
184-
}
185-
]
186-
| group_by(.ns)
187-
| map({ns: .[0].ns, cpu: (map(.cpu) | add), memMi: (map(.memMi) | add)})
188-
| sort_by(.ns)
189-
| .[]
190-
| [.ns, ( .cpu | tostring ), ( .memMi | tostring )]
191-
| @tsv
192-
' \
193-
| awk 'BEGIN{print "NAMESPACE\tCPU_CORES\tMEM_MIB"} {print}'
194-
195-
- name: Wait for workloads
93+
- name: Wait for pods to stabilize
19694
run: |
197-
set -e
198-
echo "Namespaces:" && kubectl get ns
199-
echo "All pods:" && kubectl get pods -n constructive-functions -o wide
200-
echo "Knative services:" && kubectl get ksvc -n constructive-functions || true
95+
echo "Waiting for deployments..."
96+
kubectl rollout status deploy --all -n constructive-functions --timeout=180s || true
97+
echo "Pod status:"
98+
kubectl get pods -n constructive-functions -o wide
20199
202100
- name: Wait for DB setup job
203101
run: |
204102
kubectl wait --for=condition=complete job/constructive-db \
205103
-n constructive-functions --timeout=180s
206104
207-
- name: Setup Node.js
208-
uses: actions/setup-node@v4
209-
with:
210-
node-version: '22'
211-
212-
- name: Install pnpm and project deps
213-
run: |
214-
npm install -g pnpm@10.12.2
215-
pnpm install
216-
217105
- name: Port-forward postgres and run e2e tests
218106
env:
219107
PGHOST: localhost

0 commit comments

Comments
 (0)