| 1 | name: Go |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [ v3 ] |
| 6 | pull_request: |
| 7 | branches: [ v3 ] |
| 8 | jobs: |
| 9 | fmt: |
| 10 | runs-on: ubuntu-latest |
| 11 | steps: |
| 12 | - uses: actions/checkout@v4 |
| 13 | - name: Set up Go |
| 14 | uses: actions/setup-go@v5 |
| 15 | with: |
| 16 | go-version: stable |
| 17 | - name: Run go fmt |
| 18 | run: go fmt ./... |
| 19 | - name: Check if working tree is dirty |
| 20 | run: | |
| 21 | if [[ $(git diff --stat) ]]; then |
| 22 | git --no-pager diff |
| 23 | echo 'Run go fmt ./... and commit changes.' |
| 24 | exit 1 |
| 25 | fi |
| 26 | build: |
| 27 | strategy: |
| 28 | matrix: |
| 29 | go-versions: [1.21.x, 1.22.x, 1.23.x, 1.24.x] |
| 30 | runs-on: ubuntu-latest |
| 31 | steps: |
| 32 | - uses: actions/checkout@v4 |
| 33 | - name: Set up Go |
| 34 | uses: actions/setup-go@v5 |
| 35 | with: |
| 36 | go-version: ${{ matrix.go-versions }} |
| 37 | - name: Run go vet |
| 38 | run: go vet ./... |
| 39 | - name: Run go test |
| 40 | run: GO111MODULE=on go test -v -race ./... |