fix: remove unused fmt import and fix missing parens in doctor #35
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
| # ============================================================================= | |
| # MindX CI Pipeline — Production-grade GitHub Actions | |
| # ============================================================================= | |
| # Stages: lint → vet → security → test (race + coverage) → build (matrix) | |
| # | |
| # Triggers: | |
| # - push to main/develop, all PRs | |
| # - manual dispatch for debugging | |
| # ============================================================================= | |
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - 'LICENSE' | |
| - '.all-contributorsrc' | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| # Cancel in-progress runs on the same branch/PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # ========================================================================== | |
| # Environment defaults | |
| # ========================================================================== | |
| env: | |
| GO_VERSION: '1.26' | |
| CGO_ENABLED: 1 | |
| GOLANGCI_LINT_VERSION: v2.9 | |
| MINDX_WORKSPACE: ${{ github.workspace }}/.test | |
| jobs: | |
| # ========================================================================== | |
| # Stage 1: Lint — golangci-lint with project config | |
| # ========================================================================== | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v9 | |
| with: | |
| version: ${{ env.GOLANGCI_LINT_VERSION }} | |
| args: --timeout=5m | |
| # ========================================================================== | |
| # Stage 2: Vet — static analysis | |
| # ========================================================================== | |
| vet: | |
| name: Vet | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| # Note: vet runs with CGO_ENABLED=1 (set globally) so CGO-dependent | |
| # packages (gorag/go-tree-sitter/onnxruntime_go) compile correctly. | |
| - name: Run go vet | |
| run: | | |
| PKGS=$(go list ./... | grep -v 'gort\|onnxruntime\|tree-sitter' || true) | |
| if [ -z "$PKGS" ]; then | |
| echo "No packages to vet" | |
| else | |
| echo "$PKGS" | xargs go vet | |
| fi | |
| # ========================================================================== | |
| # Stage 3: Security — vulnerability check | |
| # ========================================================================== | |
| security: | |
| name: Security | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Install govulncheck | |
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
| - name: Run govulncheck | |
| run: | | |
| PKGS=$(go list ./... | grep -v 'gort\|onnxruntime\|tree-sitter' || true) | |
| if [ -z "$PKGS" ]; then | |
| echo "No packages to scan" | |
| else | |
| govulncheck $PKGS | tee govulncheck-output.txt | |
| fi | |
| # ========================================================================== | |
| # Stage 4: Test — race detector + coverage (matrix: OS) | |
| # ========================================================================== | |
| test: | |
| name: Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: [lint, vet] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| env: | |
| CGO_ENABLED: 1 # race detector requires CGO | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Prepare test workspace | |
| run: | | |
| mkdir -p .test | |
| cp -r config .test/config 2>/dev/null || true | |
| shell: bash | |
| - name: Run tests with race detector & coverage | |
| run: | | |
| go test \ | |
| -race \ | |
| -coverprofile=coverage.out \ | |
| -covermode=atomic \ | |
| -timeout=10m \ | |
| -v ./... 2>&1 | tee test-output.txt | |
| env: | |
| MINDX_WORKSPACE: ${{ env.MINDX_WORKSPACE }} | |
| - name: Display coverage summary | |
| if: runner.os != 'Windows' | |
| run: go tool cover -func=coverage.out | tail -1 | |
| - name: Upload coverage artifact | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage.out | |
| retention-days: 7 | |
| - name: Upload test output | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-output-${{ matrix.os }} | |
| path: test-output.txt | |
| retention-days: 7 | |
| # ========================================================================== | |
| # Stage 5: Build verification (matrix: OS + Arch) | |
| # ========================================================================== | |
| build: | |
| name: Build (${{ matrix.goos }}/${{ matrix.goarch }}) | |
| runs-on: ${{ matrix.runner }} | |
| needs: [test] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| runner: ubuntu-latest | |
| - goos: linux | |
| goarch: arm64 | |
| runner: ubuntu-latest | |
| - goos: darwin | |
| goarch: arm64 | |
| runner: macos-latest | |
| - goos: windows | |
| goarch: amd64 | |
| runner: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Install C cross-compiler (linux/arm64) | |
| if: matrix.goos == 'linux' && matrix.goarch == 'arm64' | |
| run: sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Setup MinGW (Windows CGO) | |
| if: matrix.goos == 'windows' | |
| run: choco install mingw -y --no-progress | |
| - name: Get version info | |
| id: version | |
| run: | | |
| echo "version=$(git describe --tags --abbrev=0 2>/dev/null || echo 'dev')" >> "$GITHUB_OUTPUT" | |
| echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | |
| echo "build_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | |
| - name: Build | |
| shell: bash | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| # Set C cross-compiler for linux/arm64 (CGO requires matching CC) | |
| if [ "$GOOS" = "linux" ] && [ "$GOARCH" = "arm64" ]; then | |
| export CC=aarch64-linux-gnu-gcc | |
| fi | |
| BINARY_NAME=mindx | |
| VERSION=${{ steps.version.outputs.version }} | |
| COMMIT=${{ steps.version.outputs.commit }} | |
| BUILD_TIME=${{ steps.version.outputs.build_time }} | |
| SUFFIX="" | |
| [ "${{ matrix.goos }}" = "windows" ] && SUFFIX=".exe" | |
| go build \ | |
| -trimpath \ | |
| -ldflags="-s -w \ | |
| -X github.com/DotNetAge/mindx/cmd.Version=${VERSION#v} \ | |
| -X github.com/DotNetAge/mindx/cmd.Commit=${COMMIT} \ | |
| -X github.com/DotNetAge/mindx/cmd.BuildTime=${BUILD_TIME}" \ | |
| -o dist/${BINARY_NAME}-${{ matrix.goos }}-${{ matrix.goarch }}${SUFFIX} \ | |
| . | |
| ls -lh dist/ | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mindx-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: dist/ | |
| retention-days: 7 |