fix(tests): add missing farp import in farp_adapter_test.go #227
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: Go CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| security-events: write | |
| jobs: | |
| # Build and test | |
| test: | |
| name: Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| /* | |
| !docs/ | |
| sparse-checkout-cone-mode: false | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| check-latest: true | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Check go.mod tidiness | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod go.sum || (echo "❌ go.mod or go.sum needs tidying" && exit 1) | |
| - name: Build | |
| run: go build -v ./... | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| PKGS=$(go list ./... | grep -v '/bk/') | |
| go test -v -short -race -timeout=10m -coverprofile=coverage.out $PKGS | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.out | |
| - name: Upload coverage | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage.out | |
| retention-days: 7 | |
| # Build and vet ALL submodules (extensions, examples, cmd) | |
| build-all-modules: | |
| name: Build All Modules | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| /* | |
| !docs/ | |
| sparse-checkout-cone-mode: false | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| check-latest: true | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| key: ${{ runner.os }}-go-all-modules-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-all-modules- | |
| ${{ runner.os }}-go- | |
| - name: Build and vet all modules | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| FAILED=0 | |
| TOTAL=0 | |
| FAILED_MODULES="" | |
| for modfile in $(find . -name "go.mod" -not -path "./docs/*" | sort); do | |
| dir=$(dirname "$modfile") | |
| mod_name=$(head -1 "$modfile" | awk '{print $2}') | |
| TOTAL=$((TOTAL + 1)) | |
| echo "::group::Building $dir ($mod_name)" | |
| if ! (cd "$dir" && go build ./... 2>&1); then | |
| echo "::error::Build failed for module: $dir ($mod_name)" | |
| FAILED=$((FAILED + 1)) | |
| FAILED_MODULES="$FAILED_MODULES\n - $dir ($mod_name)" | |
| fi | |
| if ! (cd "$dir" && go vet ./... 2>&1); then | |
| echo "::error::Vet failed for module: $dir ($mod_name)" | |
| FAILED=$((FAILED + 1)) | |
| FAILED_MODULES="$FAILED_MODULES\n - $dir ($mod_name) [vet]" | |
| fi | |
| echo "::endgroup::" | |
| done | |
| echo "" | |
| echo "=====================================" | |
| echo "Module Build Summary: $TOTAL modules checked" | |
| echo "=====================================" | |
| if [ "$FAILED" -gt 0 ]; then | |
| echo "FAILED modules ($FAILED failures):$FAILED_MODULES" | |
| exit 1 | |
| else | |
| echo "All $TOTAL modules built and vetted successfully." | |
| fi | |
| - name: Test submodules | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| FAILED=0 | |
| FAILED_MODULES="" | |
| for modfile in $(find . -name "go.mod" -not -path "./docs/*" -not -path "./go.mod" | sort); do | |
| dir=$(dirname "$modfile") | |
| mod_name=$(head -1 "$modfile" | awk '{print $2}') | |
| echo "::group::Testing $dir ($mod_name)" | |
| if ! (cd "$dir" && go test -short -count=1 -timeout=5m ./... 2>&1); then | |
| echo "::error::Tests failed for module: $dir ($mod_name)" | |
| FAILED=$((FAILED + 1)) | |
| FAILED_MODULES="$FAILED_MODULES\n - $dir ($mod_name)" | |
| fi | |
| echo "::endgroup::" | |
| done | |
| if [ "$FAILED" -gt 0 ]; then | |
| echo "" | |
| echo "FAILED submodule tests ($FAILED failures):$FAILED_MODULES" | |
| exit 1 | |
| fi | |
| # Linting | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| check-latest: true | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| args: --timeout=5m --exclude-dirs=bk | |
| continue-on-error: true | |
| - name: Run go vet | |
| run: go vet $(go list ./... | grep -v '/bk/') | |
| # Security scanning | |
| security: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run gosec | |
| run: | | |
| go install github.com/securego/gosec/v2/cmd/gosec@latest | |
| gosec -exclude-dir=bk -exclude-dir=vendor -exclude-dir=examples -fmt=sarif -out=gosec.sarif ./... || true | |
| - name: Fix SARIF file format | |
| if: always() | |
| run: | | |
| chmod +x .github/scripts/fix_sarif.py | |
| python3 .github/scripts/fix_sarif.py | |
| - name: Run govulncheck | |
| continue-on-error: true | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck ./... | |
| # - name: Upload SARIF file | |
| # uses: github/codeql-action/upload-sarif@v4 | |
| # if: always() | |
| # with: | |
| # sarif_file: gosec.sarif | |
| # Build CLI binary | |
| build-cli: | |
| name: Build CLI | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| ~/.cache/go-build | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| - name: Build CLI | |
| run: | | |
| cd cmd/forge | |
| go build -v -ldflags="-s -w -X main.version=dev-${{ github.sha }}" -o forge . | |
| - name: Test CLI binary | |
| run: | | |
| cd cmd/forge | |
| ./forge --version | |
| ./forge doctor || true | |
| - name: Upload CLI artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: forge-cli-${{ github.sha }} | |
| path: cmd/forge/forge | |
| retention-days: 7 | |
| # Summary | |
| ci-summary: | |
| name: CI Summary | |
| runs-on: ubuntu-latest | |
| needs: [test, build-all-modules, lint, security, build-cli] | |
| if: always() | |
| steps: | |
| - name: Generate summary | |
| run: | | |
| cat >> $GITHUB_STEP_SUMMARY << EOF | |
| # CI Results Summary | |
| ## Job Status | |
| - **Test**: ${{ needs.test.result }} (Windows optional) | |
| - **Build All Modules**: ${{ needs.build-all-modules.result }} | |
| - **Lint**: ${{ needs.lint.result }} | |
| - **Security**: ${{ needs.security.result }} | |
| - **Build CLI**: ${{ needs.build-cli.result }} | |
| ## Details | |
| - **Commit**: ${{ github.sha }} | |
| - **Branch**: ${{ github.ref_name }} | |
| - **Triggered by**: ${{ github.event_name }} | |
| - **Run number**: ${{ github.run_number }} | |
| > **Note**: Windows tests are optional and failures won't block CI | |
| EOF | |
| # Allow Windows test failures | |
| if [ "${{ needs.build-all-modules.result }}" != "success" ] || \ | |
| [ "${{ needs.lint.result }}" != "success" ] || \ | |
| [ "${{ needs.security.result }}" != "success" ] || \ | |
| [ "${{ needs.build-cli.result }}" != "success" ]; then | |
| echo "❌ **CI Failed** - Please check the logs above" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| elif [ "${{ needs.test.result }}" != "success" ]; then | |
| echo "⚠️ **Tests have issues (Windows may be failing)** - Please review logs" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "✅ **All CI checks passed**" >> $GITHUB_STEP_SUMMARY | |
| fi | |