-
Notifications
You must be signed in to change notification settings - Fork 184
121 lines (102 loc) · 3.54 KB
/
Copy pathsmoke-test.yml
File metadata and controls
121 lines (102 loc) · 3.54 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Smoke Tests (kind cluster)
on:
workflow_dispatch:
inputs:
wait_timeout:
description: 'Seconds to wait for pods to be ready'
default: '300'
required: false
workflow_run:
workflows: ["Tests"]
branches: [main]
types: [completed]
permissions:
contents: read
# Only one smoke test at a time — clusters are expensive
concurrency:
group: smoke-test
cancel-in-progress: false
jobs:
smoke:
name: kind cluster smoke test
runs-on: ubuntu-latest
# Only run if triggered manually OR Tests workflow succeeded on main
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.31.0'
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: '3.17.0'
- name: Create kind cluster
run: kind create cluster --name commonly-smoke --wait 60s
- name: Build backend Docker image
run: |
docker build -t commonly-backend:smoke backend/
- name: Build frontend Docker image
run: |
docker build -t commonly-frontend:smoke \
--build-arg VITE_API_URL=http://localhost:5000 \
frontend/
- name: Load images into kind
run: |
kind load docker-image commonly-backend:smoke --name commonly-smoke
kind load docker-image commonly-frontend:smoke --name commonly-smoke
- name: Deploy with Helm
run: |
helm upgrade --install commonly-smoke \
k8s/helm/commonly \
-f k8s/helm/commonly/values.yaml \
-f k8s/helm/commonly/values-local.yaml \
--set backend.image.repository=commonly-backend \
--set backend.image.tag=smoke \
--set frontend.image.repository=commonly-frontend \
--set frontend.image.tag=smoke \
--namespace commonly-local \
--create-namespace \
--wait \
--timeout ${{ github.event.inputs.wait_timeout || '300' }}s
- name: Port-forward backend
run: |
kubectl port-forward -n commonly-local svc/backend 5000:5000 &
echo "Waiting for backend port-forward..."
for i in $(seq 1 15); do
curl -sf http://localhost:5000/api/health/live > /dev/null && break
sleep 2
done
- name: Port-forward frontend
run: |
kubectl port-forward -n commonly-local svc/frontend 3000:80 &
echo "Waiting for frontend port-forward..."
for i in $(seq 1 10); do
curl -sf http://localhost:3000 > /dev/null && break
sleep 2
done
- name: Run smoke tests
env:
API_URL: http://localhost:5000
BASE_URL: http://localhost:3000
run: node smoke-tests/run.js
- name: Pod status on failure
if: failure()
run: |
kubectl get pods -n commonly-local
kubectl describe pods -n commonly-local | tail -80
- name: Delete kind cluster
if: always()
run: kind delete cluster --name commonly-smoke