forked from kubestellar/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (154 loc) · 4.84 KB
/
ci.yml
File metadata and controls
179 lines (154 loc) · 4.84 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Build, Check Formatting, and Run Tests
on:
push:
branches: ['*']
pull_request:
branches: ['*']
jobs:
frontend:
name: Frontend Checks
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install Dependencies
working-directory: frontend
run: npm ci
- name: Check Formatting
working-directory: frontend
run: npm run format:check
- name: ✅ Formatting Check Passed
if: success()
run: echo "Prettier formatting check passed ✅"
- name: Lint Check
working-directory: frontend
run: npm run lint
- name: ✅ Lint Check Passed
if: success()
run: echo "Linting successful ✅"
- name: Run Frontend Tests
working-directory: frontend
run: npm test -- --ci --coverage --passWithNoTests
- name: ✅ Frontend Tests Passed
if: success()
run: echo "Frontend tests passed ✅"
- name: Build
working-directory: frontend
run: npm run build
env:
VITE_BASE_URL: http://localhost:4000
- name: ✅ Frontend Build Successful
if: success()
run: echo "Frontend build successful ✅"
- name: Run Frontend
working-directory: frontend
run: |
echo "Starting Frontend Server..."
npm run dev &
env:
VITE_BASE_URL: http://localhost:4000
- name: ✅ Frontend Server Started
if: success()
run: echo "Frontend server started successfully ✅"
backend:
name: Backend Checks
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
cache-dependency-path: backend/go.sum
- name: Install Dependencies
working-directory: backend
run: go mod download
- name: ✅ Dependencies Installed
if: success()
run: echo "Go dependencies installed successfully ✅"
- name: Check Go Formatting
working-directory: backend
run: |
if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
echo "The following files are not formatted correctly:"
gofmt -l .
exit 1
fi
- name: ✅ Formatting Check Passed
if: success()
run: echo "Go formatting check passed ✅"
- name: Build Backend
working-directory: backend
run: go build -v ./...
- name: ✅ Backend Build Successful
if: success()
run: echo "Backend build successful ✅"
- name: Run Backend Tests
working-directory: backend
run: go test ./... -v
- name: ✅ Backend Tests Passed
if: success()
run: echo "Backend Tests Passed ✅"
- name: Run Backend
working-directory: backend
run: |
echo "Starting Backend Server..."
go run . &
- name: ✅ Backend Server Started
if: success()
run: echo "Backend server started successfully ✅"
helm-chart-test:
name: Helm Chart Test
runs-on: ubuntu-latest
needs: [frontend, backend] # ✅ Wait until images are built & pushed
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up KinD Cluster
uses: helm/kind-action@v1.9.0
with:
cluster_name: helm-ui-test # 🧠 Must match --cluster arg in test script
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Build Helm Dependencies
run: |
cd chart
helm dependency build
- name: Patch Helm values with SHA-tagged GHCR images
run: |
cp chart/values.yaml chart/values.ci.yaml
yq e '
.frontend.image.repository = "ghcr.io/kubestellar/ui-frontend" |
.frontend.image.tag = "${{ github.sha }}" |
.backend.image.repository = "ghcr.io/kubestellar/ui-backend" |
.backend.image.tag = "${{ github.sha }}"
' -i chart/values.ci.yaml
- name: Run Helm Chart Test Script
run: |
bash scripts/helm-test.sh \
--release=ui-test-release \
--namespace=helm-ui-test \
--cluster=helm-ui-test \
--values=chart/values.ci.yaml