|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths-ignore: |
| 8 | + - "Makefile" |
| 9 | + - "**/*.md" |
| 10 | + pull_request: |
| 11 | + paths-ignore: |
| 12 | + - "Makefile" |
| 13 | + - "**/*.md" |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-and-test: |
| 24 | + name: Go ${{ matrix.go }} — ${{ matrix.os }} |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + timeout-minutes: 15 |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 31 | + go: ["1.22.x"] |
| 32 | + include: |
| 33 | + # Extra Go patch line on Linux to catch regressions on newer toolchain. |
| 34 | + - os: ubuntu-latest |
| 35 | + go: "1.23.x" |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Set up Go |
| 42 | + uses: actions/setup-go@v5 |
| 43 | + with: |
| 44 | + go-version: ${{ matrix.go }} |
| 45 | + cache: true |
| 46 | + |
| 47 | + - name: Download modules |
| 48 | + run: go mod download |
| 49 | + |
| 50 | + - name: Verify go.sum |
| 51 | + run: go mod verify |
| 52 | + |
| 53 | + - name: Check formatting |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + out="$(gofmt -l .)" |
| 58 | + if [[ -n "$out" ]]; then |
| 59 | + echo "::error::Run gofmt on:" |
| 60 | + echo "$out" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Go vet |
| 65 | + run: go vet ./... |
| 66 | + |
| 67 | + - name: Build agentctl |
| 68 | + run: go build -v -o agentctl${{ runner.os == 'Windows' && '.exe' || '' }} ./cmd/agentctl |
| 69 | + |
| 70 | + # Use bash on Windows: PowerShell misparses -coverprofile=coverage.out |
| 71 | + # (".out" becomes a separate argument / package path). |
| 72 | + - name: Unit tests |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + go test -v \ |
| 76 | + -race \ |
| 77 | + -count=1 \ |
| 78 | + -shuffle=on \ |
| 79 | + -timeout=10m \ |
| 80 | + -covermode=atomic \ |
| 81 | + -coverprofile=coverage.out \ |
| 82 | + ./... |
| 83 | +
|
| 84 | + - name: Coverage summary |
| 85 | + if: runner.os == 'Linux' |
| 86 | + run: go tool cover -func=coverage.out | tail -n1 |
| 87 | + |
| 88 | + - name: Upload coverage artifact |
| 89 | + if: runner.os == 'Linux' && matrix.go == '1.22.x' |
| 90 | + uses: actions/upload-artifact@v4 |
| 91 | + with: |
| 92 | + name: coverage-linux-go122 |
| 93 | + path: coverage.out |
| 94 | + if-no-files-found: error |
0 commit comments