ci: add build, vet and test workflow #1
Workflow file for this run
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
| # Build, vet and test the SDK on every push and pull request. | |
| # | |
| # This repository had no CI at all: it ships a Go SDK that downstream users | |
| # build against, and nothing verified it compiled. The steps below are the ones | |
| # that were already passing locally when this was added — the intent is a gate | |
| # that stays green and therefore stays meaningful, not a broad net that goes | |
| # red and gets ignored. | |
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| # Tracks the version in go.mod rather than pinning separately, so | |
| # the two cannot drift. | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Build | |
| run: go build ./... | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Test | |
| run: go test -race ./... | |
| formatting: | |
| name: Formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Check gofmt | |
| run: | | |
| unformatted="$(gofmt -l .)" | |
| if [ -n "$unformatted" ]; then | |
| echo "These files are not gofmt-formatted:" | |
| echo "$unformatted" | |
| echo | |
| echo "Run: gofmt -w ." | |
| exit 1 | |
| fi |