mirror of
https://gitee.com/rulego/streamsql.git
synced 2026-04-19 18:38:48 +00:00
test:增加基准测试
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master, develop ]
|
||||
pull_request:
|
||||
branches: [ main, master, develop ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ['1.19', '1.20', '1.21']
|
||||
|
||||
steps:
|
||||
- name: Set up Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-${{ matrix.go-version }}-
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Verify dependencies
|
||||
run: go mod verify
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Run tests
|
||||
run: go test -v -race -timeout 30s ./...
|
||||
|
||||
- name: Run tests with coverage
|
||||
if: matrix.go-version == '1.21'
|
||||
run: go test -v -race -coverprofile=coverage.out -covermode=atomic -timeout 30s ./...
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
if: matrix.go-version == '1.21'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.out
|
||||
flags: unittests
|
||||
name: codecov-umbrella
|
||||
|
||||
case-expression-tests:
|
||||
name: CASE Expression Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run CASE Expression Parsing Tests
|
||||
run: go test -v -run TestCaseExpressionParsing -timeout 15s
|
||||
|
||||
- name: Run CASE Expression Comprehensive Tests
|
||||
run: go test -v -run TestCaseExpressionComprehensive -timeout 15s
|
||||
|
||||
- name: Run CASE Expression Field Extraction Tests
|
||||
run: go test -v -run TestCaseExpressionFieldExtraction -timeout 15s
|
||||
|
||||
- name: Run CASE Expression in SQL Tests
|
||||
run: go test -v -run TestCaseExpressionInSQL -timeout 15s
|
||||
|
||||
- name: Run CASE Expression Aggregation Tests (with known limitations)
|
||||
run: go test -v -run "TestCaseExpressionInAggregation|TestComplexCaseExpressionsInAggregation" -timeout 20s
|
||||
|
||||
- name: Run CASE Expression Edge Cases
|
||||
run: go test -v -run TestCaseExpressionEdgeCases -timeout 15s
|
||||
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: latest
|
||||
args: --timeout=5m
|
||||
|
||||
security:
|
||||
name: Security Scan
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run Gosec Security Scanner
|
||||
uses: securecodewarrior/github-action-gosec@master
|
||||
with:
|
||||
args: './...'
|
||||
@@ -0,0 +1,112 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Before Release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run all tests
|
||||
run: go test -v -race -timeout 30s ./...
|
||||
|
||||
- name: Run CASE expression tests specifically
|
||||
run: |
|
||||
echo "Testing CASE expression functionality..."
|
||||
go test -v -run TestCaseExpression -timeout 20s
|
||||
|
||||
release:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
# Build for multiple platforms
|
||||
GOOS=linux GOARCH=amd64 go build -o streamsql-linux-amd64 ./...
|
||||
GOOS=windows GOARCH=amd64 go build -o streamsql-windows-amd64.exe ./...
|
||||
GOOS=darwin GOARCH=amd64 go build -o streamsql-darwin-amd64 ./...
|
||||
GOOS=darwin GOARCH=arm64 go build -o streamsql-darwin-arm64 ./...
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "## 🚀 StreamSQL $(echo ${{ github.ref }} | sed 's/refs\/tags\///')" >> $GITHUB_OUTPUT
|
||||
echo "" >> $GITHUB_OUTPUT
|
||||
echo "### ✨ 新增功能" >> $GITHUB_OUTPUT
|
||||
echo "- 完善的CASE表达式支持" >> $GITHUB_OUTPUT
|
||||
echo "- 多条件逻辑表达式 (AND, OR)" >> $GITHUB_OUTPUT
|
||||
echo "- 数学函数集成" >> $GITHUB_OUTPUT
|
||||
echo "- 字段提取和引用功能" >> $GITHUB_OUTPUT
|
||||
echo "" >> $GITHUB_OUTPUT
|
||||
echo "### 🔧 改进" >> $GITHUB_OUTPUT
|
||||
echo "- 负数解析优化" >> $GITHUB_OUTPUT
|
||||
echo "- 字符串和数值混合比较" >> $GITHUB_OUTPUT
|
||||
echo "- 表达式解析性能提升" >> $GITHUB_OUTPUT
|
||||
echo "" >> $GITHUB_OUTPUT
|
||||
echo "### 📋 测试覆盖" >> $GITHUB_OUTPUT
|
||||
echo "- ✅ 基础CASE表达式解析" >> $GITHUB_OUTPUT
|
||||
echo "- ✅ 复杂条件组合" >> $GITHUB_OUTPUT
|
||||
echo "- ✅ 函数调用支持" >> $GITHUB_OUTPUT
|
||||
echo "- ✅ 字段提取功能" >> $GITHUB_OUTPUT
|
||||
echo "- ⚠️ 聚合函数中的使用 (部分支持)" >> $GITHUB_OUTPUT
|
||||
echo "" >> $GITHUB_OUTPUT
|
||||
echo "---" >> $GITHUB_OUTPUT
|
||||
echo "📖 **完整文档**: [README.md](README.md) | [中文文档](README_ZH.md)" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body: ${{ steps.changelog.outputs.CHANGELOG }}
|
||||
files: |
|
||||
streamsql-linux-amd64
|
||||
streamsql-windows-amd64.exe
|
||||
streamsql-darwin-amd64
|
||||
streamsql-darwin-arm64
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,79 @@
|
||||
run:
|
||||
timeout: 5m
|
||||
modules-download-mode: readonly
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- gofmt
|
||||
- goimports
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- gosimple
|
||||
- staticcheck
|
||||
- unused
|
||||
- typecheck
|
||||
- errcheck
|
||||
- gosec
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofumpt
|
||||
- godot
|
||||
- goprintffuncname
|
||||
- gomodguard
|
||||
- revive
|
||||
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
min-complexity: 15
|
||||
|
||||
gosec:
|
||||
excludes:
|
||||
- G404 # 随机数生成器可能不是密码学安全的
|
||||
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- style
|
||||
- performance
|
||||
disabled-checks:
|
||||
- unnamedResult
|
||||
- whyNoLint
|
||||
|
||||
revive:
|
||||
rules:
|
||||
- name: exported
|
||||
disabled: false
|
||||
arguments:
|
||||
- "checkPrivateReceivers"
|
||||
- "sayRepetitiveInsteadOfStutters"
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
# 排除测试文件中的某些检查
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gosec
|
||||
- errcheck
|
||||
- gocyclo
|
||||
|
||||
# 排除CASE表达式测试中的复杂度检查
|
||||
- path: streamsql_case_test\.go
|
||||
linters:
|
||||
- gocyclo
|
||||
- funlen
|
||||
|
||||
# 排除generated文件
|
||||
- path: ".*\\.pb\\.go"
|
||||
linters:
|
||||
- all
|
||||
|
||||
exclude:
|
||||
# 排除一些常见的false positive
|
||||
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print.*|os\\.(Un)?Setenv). is not checked"
|
||||
- "should have a package comment"
|
||||
|
||||
output:
|
||||
format: colored-line-number
|
||||
print-issued-lines: true
|
||||
print-linter-name: true
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user