-
Notifications
You must be signed in to change notification settings - Fork 2
528 lines (459 loc) · 15.5 KB
/
ci.yml
File metadata and controls
528 lines (459 loc) · 15.5 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-15]
go: ['1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Get dependencies
run: go mod download
- name: Test
run: go test -v ./...
- name: Test with race detector
run: go test -race -v ./...
- name: Test mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go test -v ./...
- name: Test mtlog-lsp
run: |
cd cmd/mtlog-lsp
go test -v ./...
- name: Test benchmarks module
run: |
cd benchmarks
go test -v ./...
- name: Test logr adapter module
run: |
cd adapters/logr
go test -v ./...
- name: Test OTEL adapter module
run: |
cd adapters/otel
go test -v ./...
go test -race -v ./...
- name: Test HTTP middleware adapter module
run: |
cd adapters/middleware
go test -v ./...
go test -race -v ./...
- name: Test Sentry adapter module
run: |
cd adapters/sentry
go test -v ./...
go test -race -v ./...
- name: Test coverage
run: go test -coverprofile=coverage.out ./...
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.23'
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.23'
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
fuzz:
name: Fuzz Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Start OTEL Collector for OTEL adapter tests
run: |
# Start collector for OTEL adapter tests which include integration tests
docker run -d \
--name otel-collector \
--network host \
-v ${{ github.workspace }}/.github/otel-collector-config.yaml:/etc/otel-collector-config.yaml \
otel/opentelemetry-collector:latest \
--config=/etc/otel-collector-config.yaml
# Wait for collector to be ready
echo "Waiting for OTEL Collector..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:13133/ 2>/dev/null; then
echo "OTEL Collector is ready"
break
fi
echo "Waiting for OTEL Collector... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "OTEL Collector failed to start in 30 seconds"
exit 1
fi
- name: Run fuzz tests
run: |
# Parser fuzz tests
go test -fuzz=FuzzParseMessageTemplate -fuzztime=30s ./internal/parser
go test -fuzz=FuzzExtractPropertyNames -fuzztime=30s ./internal/parser
# Output template fuzz tests
go test -fuzz=FuzzParseOutputTemplate -fuzztime=30s ./internal/formatters/output
go test -fuzz=FuzzTimeFormatting -fuzztime=30s ./internal/formatters/output
go test -fuzz=FuzzLevelFormatting -fuzztime=30s ./internal/formatters/output
# OTEL adapter fuzz tests (with collector available for chaos tests)
cd adapters/otel
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzBridgeMessageTemplate -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzHandlerProperties -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzEnricherContext -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzOTLPSinkConfiguration -fuzztime=30s .
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Run benchmarks
run: |
cd benchmarks
go test -run=^$ -bench=. -benchmem -benchtime=10s . | tee ../benchmark.txt
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmark.txt
vscode-extension:
name: VS Code Extension
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-15]
node-version: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: vscode-extension/mtlog-analyzer/package-lock.json
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
cd ../..
- name: Install dependencies
working-directory: vscode-extension/mtlog-analyzer
run: npm ci
- name: Compile TypeScript
working-directory: vscode-extension/mtlog-analyzer
run: npm run compile
- name: Package extension
working-directory: vscode-extension/mtlog-analyzer
run: |
npm install -g @vscode/vsce
vsce package --no-dependencies
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
- name: Upload VSIX
uses: actions/upload-artifact@v4
with:
name: mtlog-analyzer-vsix
path: vscode-extension/mtlog-analyzer/*.vsix
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
goland-plugin:
name: GoLand Plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
cd ../..
- name: Make gradlew executable
working-directory: goland-plugin
run: chmod +x ./gradlew
- name: Build Plugin
working-directory: goland-plugin
run: ./gradlew buildPlugin
- name: Run Tests
working-directory: goland-plugin
run: |
# Run tests with real mtlog-analyzer
export PATH=$HOME/go/bin:$PATH
# Use set -o pipefail to ensure grep doesn't hide test failures
set -o pipefail
./gradlew test --info 2>&1 | grep -v "WARN.*directory not found"
- name: Run Plugin Verifier
working-directory: goland-plugin
run: ./gradlew verifyPlugin -PverifierIdeVersions=GO-2024.2,GO-2025.1
- name: Upload Plugin
uses: actions/upload-artifact@v4
with:
name: mtlog-analyzer-goland-plugin
path: goland-plugin/build/distributions/*.zip
zed-extension:
name: Zed Extension
strategy:
matrix:
os: [ubuntu-latest, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0
targets: wasm32-wasip2
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-lsp
run: |
cd cmd/mtlog-lsp
go build -o $HOME/go/bin/mtlog-lsp .
echo "$HOME/go/bin" >> $GITHUB_PATH
cd ../..
- name: Build Zed Extension
working-directory: zed-extension/mtlog
run: |
cargo build --release --target wasm32-wasip2
# Verify WASM was created
test -f target/wasm32-wasip2/release/mtlog_analyzer.wasm
- name: Run Rust Tests
working-directory: zed-extension/mtlog
run: cargo test
- name: Upload WASM artifact
uses: actions/upload-artifact@v4
with:
name: zed-extension-wasm-${{ matrix.os }}
path: zed-extension/mtlog/target/wasm32-wasip2/release/mtlog_analyzer.wasm
if: matrix.os == 'ubuntu-latest'
neovim-plugin:
name: Neovim Plugin
strategy:
matrix:
os: [ubuntu-latest, macos-15]
neovim: ['v0.10.0', 'stable']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
echo "$HOME/go/bin" >> $GITHUB_PATH
cd ../..
- name: Setup Neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim }}
- name: Install Plenary
run: |
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
- name: Run Tests
working-directory: neovim-plugin
run: |
nvim --headless -u tests/minimal_init.lua -c "PlenaryBustedDirectory tests/spec/ {minimal_init = 'tests/minimal_init.lua', sequential = true}"
- name: Validate Health Check
working-directory: neovim-plugin
run: |
# Run checkhealth - on macOS it outputs to buffer not stdout, so we write to file
nvim --headless -u tests/minimal_init.lua -c "enew" -c "checkhealth mtlog" -c "w! health.txt" -c "qa" 2>&1
# Check if analyzer is detected and no errors occurred
if grep -q "mtlog-analyzer is installed\|mtlog-analyzer version" health.txt && ! grep -q "Error\|E121" health.txt; then
echo "✅ Health check passed: mtlog-analyzer detected"
else
echo "❌ Health check failed - output:"
cat health.txt
exit 1
fi
integration:
name: Integration Tests
runs-on: ubuntu-latest
services:
# Note: OTEL Collector is set up separately due to config requirements
seq:
image: datalust/seq:latest
env:
ACCEPT_EULA: Y
SEQ_FIRSTRUN_NOAUTHENTICATION: true
ports:
- 5341:5341
- 8080:80
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.1
env:
discovery.type: single-node
xpack.security.enabled: false
ports:
- 9200:9200
options: >-
--health-cmd "curl -f http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 5
splunk:
image: splunk/splunk:latest
env:
SPLUNK_GENERAL_TERMS: --accept-sgt-current-at-splunk-com
SPLUNK_START_ARGS: --accept-license --seed-passwd changeme123!
SPLUNK_PASSWORD: changeme123!
SPLUNK_HEC_TOKEN: abcd1234
SPLUNK_ENABLE_LISTEN: 9997
SPLUNK_ADD: tcp 1514
ports:
- 8088:8088
- 8089:8089
- 8000:8000
options: >-
--health-cmd "curl -k -f https://localhost:8088/services/collector/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Start OTEL Collector
run: |
# Use the external config file from the repository
docker run -d \
--name otel-collector \
--network host \
-v ${{ github.workspace }}/.github/otel-collector-config.yaml:/etc/otel-collector-config.yaml \
otel/opentelemetry-collector:latest \
--config=/etc/otel-collector-config.yaml
- name: Wait for services
run: |
echo "Waiting for OTEL Collector..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:13133/ 2>/dev/null; then
echo "OTEL Collector is ready"
break
fi
echo "Waiting for OTEL Collector... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "OTEL Collector failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Seq..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:8080/ 2>/dev/null; then
echo "Seq is ready"
break
fi
echo "Waiting for Seq... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Seq failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Elasticsearch..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:9200/_cluster/health 2>/dev/null; then
echo "Elasticsearch is ready"
break
fi
echo "Waiting for Elasticsearch... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Elasticsearch failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Splunk..."
timeout=60
while [ $timeout -gt 0 ]; do
if curl -k -f https://localhost:8088/services/collector/health 2>/dev/null; then
echo "Splunk is ready"
break
fi
echo "Waiting for Splunk... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Splunk failed to start in 60 seconds"
exit 1
fi
- name: Run integration tests
run: |
# Run main integration tests
go test -tags=integration -v ./...
# Run OTEL adapter integration tests
cd adapters/otel
go test -tags=integration -v ./integration/...
env:
OTEL_EXPORTER_OTLP_ENDPOINT: localhost:4317
OTEL_EXPORTER_OTLP_HTTP_ENDPOINT: localhost:4318
SEQ_URL: http://localhost:5341
SEQ_QUERY_URL: http://localhost:8080
ELASTICSEARCH_URL: http://localhost:9200
SPLUNK_URL: https://localhost:8088
SPLUNK_QUERY_URL: https://localhost:8089
SPLUNK_TOKEN: abcd1234
SPLUNK_USERNAME: admin
SPLUNK_PASSWORD: changeme123!