fix: 类型安全继续加固 + 新增 type_narrowing/mod_zero 测试 #256
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master, main] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [master, main] | |
| workflow_dispatch: | |
| jobs: | |
| # ── 编译 + 静态检查 ────────────────────────────────────────────────────── | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - run: go mod tidy | |
| - run: go build ./... | |
| - run: go vet ./... | |
| # ── tutorial 集成测试(需要 Redis)──────────────────────────────────────── | |
| tutorial-test: | |
| 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 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - run: go mod tidy | |
| - run: go build -o kvlang ./cmd/kvlang/ | |
| - run: python3 tutorial/test.py | |
| # ── 多平台交叉编译(仅 tag 时生成 release 产物)───────────────────────── | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Cross-compile | |
| run: | | |
| go mod tidy | |
| mkdir -p dist | |
| for GOOS in linux darwin; do | |
| for GOARCH in amd64 arm64; do | |
| echo "Building $GOOS/$GOARCH..." | |
| GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o dist/kvlang-$GOOS-$GOARCH ./cmd/kvlang/ | |
| done | |
| done | |
| ls -lh dist/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true |