TCP is just so much easier. #61
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: ["master"] | |
| pull_request: | |
| branches: ["master"] | |
| jobs: | |
| format-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.24.x" | |
| - name: Install tools | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Check and Fix Formatting & Imports | |
| run: | | |
| gofmt -w . | |
| goimports -w . | |
| - name: Create Pull Request for Formatting Changes | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: auto-format Go code" | |
| branch: auto-fix/go-format-${{ github.head_ref }} | |
| title: "chore: Auto-format Go code" | |
| body: | | |
| This PR automatically applies `gofmt` and `goimports` fixes. | |
| Please review and merge. | |
| labels: automated-fix | |
| reviewers: ${{ github.actor }} | |
| add-paths: | | |
| **/*.go | |
| go.mod | |
| go.sum | |
| - name: Run Linters | |
| run: golangci-lint run --timeout=5m | |
| build-test-coverage: | |
| runs-on: ${{ matrix.os }} | |
| needs: format-lint | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| go-version: "1.24.x" | |
| - os: ubuntu-latest | |
| go-version: "1.23.x" | |
| - os: ubuntu-latest | |
| go-version: "1.22.x" | |
| - os: macos-latest | |
| go-version: "1.24.x" | |
| - os: windows-latest | |
| go-version: "1.24.x" | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go ${{ matrix.go-version }} | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Build project | |
| run: go build -v ./... | |
| - name: Run tests with coverage and race detector | |
| shell: bash | |
| run: go test -v -race ./... -coverprofile=coverage.out -covermode=atomic | |
| - name: Debug coverage file | |
| shell: bash | |
| run: | | |
| echo "Listing files in workspace:" | |
| ls -lah | |
| echo "Checking coverage.out:" | |
| cat coverage.out || echo "coverage.out not found" | |
| - name: Display coverage in PR summary | |
| if: github.event_name == 'pull_request' | |
| shell: bash | |
| run: | | |
| go tool cover -func=coverage.out -o coverage.txt | |
| echo "## Go Test Coverage" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat coverage.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.out | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| security-checks: | |
| runs-on: ubuntu-latest | |
| needs: build-test-coverage | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.24.x" | |
| - name: Run go mod tidy and check for changes | |
| shell: bash | |
| run: | | |
| go mod tidy | |
| if [ -n "$(git status --porcelain go.mod go.sum)" ]; then | |
| echo "::error::go.mod or go.sum were modified by 'go mod tidy'." | |
| echo "Please run 'go mod tidy' locally and commit the changes." | |
| git diff | |
| exit 1 | |
| fi | |
| - name: Install govulncheck | |
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
| - name: Run govulncheck for vulnerabilities | |
| run: govulncheck ./... |