-
Notifications
You must be signed in to change notification settings - Fork 1
259 lines (228 loc) · 8.89 KB
/
ci-test.yml
File metadata and controls
259 lines (228 loc) · 8.89 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: CI Tests
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
- labeled
push:
branches:
- main
permissions:
contents: read
env:
GOPRIVATE: github.com/TykTechnologies
jobs:
# ==========================================================================
# Dependency Guard
# ==========================================================================
dep-guard:
uses: TykTechnologies/github-actions/.github/workflows/dependency-guard.yml@d3fa20888fa2878e877e22bb7702141217290e7c # main
permissions:
contents: read
# ==========================================================================
# Go Linting (disabled for now)
# ==========================================================================
golangci-lint:
if: false
runs-on: warp-ubuntu-latest-arm64-4x
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 2
- name: Fetch base branch
if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }}
- name: golangci-lint
if: ${{ github.event_name == 'pull_request' }}
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
version: latest
args: --out-format=checkstyle:golanglint.xml --timeout=600s --max-issues-per-linter=0 --max-same-issues=0 --new-from-rev=origin/${{ github.base_ref }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: golangcilint
retention-days: 1
path: |
golanglint.xml
# ==========================================================================
# Frontend Tests (Jest)
# ==========================================================================
frontend-tests:
needs: [dep-guard]
name: Frontend Tests
runs-on: warp-ubuntu-latest-arm64-2x
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Install and Test Frontend
env:
CI: true
run: |
cd ui/admin-frontend
npm ci --ignore-scripts
npm rebuild
npm test -- --forceExit
- name: Build Frontend
run: |
cd ui/admin-frontend
CI=false npm run build
# ==========================================================================
# Go Unit Tests (Studio + Microgateway) - Matrix for CE/ENT
# ==========================================================================
go-unit-tests:
needs: [dep-guard]
name: Go Unit Tests (${{ matrix.edition }})
runs-on: warp-ubuntu-latest-arm64-4x
strategy:
fail-fast: false
matrix:
edition: [ce, ent]
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 2
submodules: ${{ matrix.edition == 'ent' }}
token: ${{ secrets.CI_SUBMODULE_PAT }}
- name: Create enterprise stub for CE builds
if: matrix.edition == 'ce'
run: |
mkdir -p enterprise
cat > enterprise/go.mod << 'EOF'
module github.com/TykTechnologies/midsommar/v2/enterprise
go 1.25.6
EOF
- name: Setup Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Go Cache
uses: WarpBuilds/cache@f643a1ba29942d56621d07fc2d4284c7219868ad # v1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.edition }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.edition }}-
${{ runner.os }}-go-
- name: Set build tags
id: tags
run: |
if [ "${{ matrix.edition }}" == "ent" ]; then
echo "BUILD_TAGS=-tags enterprise" >> $GITHUB_OUTPUT
else
echo "BUILD_TAGS=" >> $GITHUB_OUTPUT
fi
- name: Verify Go dependencies
run: |
go mod verify
cd microgateway && go mod verify
- name: Create placeholders for embeds
run: |
# Create placeholder for docs embed (tests don't need actual docs)
mkdir -p docs/site/dist
echo "placeholder" > docs/site/dist/index.html
# Create placeholder for frontend embed (tests don't need actual frontend)
mkdir -p ui/admin-frontend/build
echo "placeholder" > ui/admin-frontend/build/index.html
# Use dev environment template for tests
cp dev/.env.dev .env
- name: Run AI Studio Unit Tests
run: |
go test ${{ steps.tags.outputs.BUILD_TAGS }} -v -race -short \
-coverprofile=coverage-studio-${{ matrix.edition }}.out \
-covermode=atomic ./...
- name: Run Microgateway Unit Tests
run: |
cd microgateway
go test ${{ steps.tags.outputs.BUILD_TAGS }} -v -race -short \
-coverprofile=../coverage-microgateway-${{ matrix.edition }}.out \
-covermode=atomic ./...
- name: Upload Coverage
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-${{ matrix.edition }}
path: coverage-*.out
retention-days: 7
# ==========================================================================
# Documentation Build
# ==========================================================================
docs-build:
needs: [dep-guard]
name: Documentation Build
runs-on: warp-ubuntu-latest-arm64-2x
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: "docs/site/package-lock.json"
- name: Cache VitePress
uses: WarpBuilds/cache@f643a1ba29942d56621d07fc2d4284c7219868ad # v1
with:
path: docs/site/.vitepress/cache
key: ${{ runner.os }}-vitepress-${{ hashFiles('docs/site/package-lock.json') }}
restore-keys: |
${{ runner.os }}-vitepress-
- name: Build Documentation
run: |
cp .env.example .env
cd docs/site
npm ci --ignore-scripts
npm rebuild
NODE_ENV=production npm run docs:build
# ==========================================================================
# Test Summary
# ==========================================================================
test-summary:
name: Test Summary
runs-on: warp-ubuntu-latest-arm64-2x
needs: [frontend-tests, go-unit-tests, docs-build]
if: always()
steps:
- name: Download Coverage Artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: coverage-*
merge-multiple: true
continue-on-error: true
- name: Generate Summary
run: |
echo "# CI Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Frontend Tests | ${{ needs.frontend-tests.result == 'success' && ':white_check_mark:' || ':x:' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Go Unit Tests (CE) | ${{ contains(needs.go-unit-tests.result, 'success') && ':white_check_mark:' || ':x:' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Go Unit Tests (ENT) | ${{ contains(needs.go-unit-tests.result, 'success') && ':white_check_mark:' || ':x:' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Documentation Build | ${{ needs.docs-build.result == 'success' && ':white_check_mark:' || ':x:' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Coverage files:" >> $GITHUB_STEP_SUMMARY
ls -la coverage-*.out 2>/dev/null || echo "No coverage files found"
- name: Upload Combined Coverage
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-combined
path: coverage-*.out
retention-days: 30
continue-on-error: true
- name: Check Results
if: needs.frontend-tests.result != 'success' || needs.go-unit-tests.result != 'success'
run: |
echo "Some tests failed!"
exit 1