blob: a6fba4c7c61d93823a93ffaa9290f02a5f2df773 [file] [log] [blame]
Earl Lee2e463fb2025-04-17 11:22:22 -07001name: go_tests
2on:
3 workflow_call:
Josh Bleecher Snyder936ba622025-04-30 20:53:21 +00004 inputs:
5 ref:
6 description: "The git ref to checkout"
7 required: false
8 type: string
9 default: ""
Earl Lee2e463fb2025-04-17 11:22:22 -070010 push:
11 branches-ignore:
Josh Bleecher Snyder93bb66a2025-04-30 16:29:05 -070012 - "queue-main-*"
13 - "queue-dev-*"
Earl Lee2e463fb2025-04-17 11:22:22 -070014 pull_request:
15jobs:
16 test:
Sean McCullough9abbf922025-04-18 13:17:38 -070017 runs-on: "ubuntu-latest"
Earl Lee2e463fb2025-04-17 11:22:22 -070018 steps:
Josh Bleecher Snyder936ba622025-04-30 20:53:21 +000019 - uses: actions/checkout@v4
20 with:
21 ref: ${{ inputs.ref }}
Earl Lee2e463fb2025-04-17 11:22:22 -070022
23 - uses: actions/setup-go@v5
24 with:
25 go-version-file: "go.mod"
26 cache: true
27
28 - name: Cache Go 1.24.2
29 uses: actions/cache@v4
30 with:
31 path: |
32 ~/.cache/go-build
33 key: ${{ runner.os }}-go1.24.2-${{ hashFiles('**/go.sum') }}
34 restore-keys: |
35 ${{ runner.os }}-go1.24.2-
36
37 - name: Install tools
38 run: |
39 go install golang.org/x/tools/gopls@latest
Philip Zeyliger6c1f34f2025-04-23 19:33:03 -070040 go install gotest.tools/gotestsum@latest
Josh Bleecher Snyder833a0f82025-04-24 18:39:36 +000041 go install mvdan.cc/gofumpt@latest
42 go install golang.org/x/tools/cmd/goimports@latest
Earl Lee2e463fb2025-04-17 11:22:22 -070043
44 - name: Go generate
45 run: |
46 go generate ./...
Josh Bleecher Snyder88c61bd2025-04-30 13:40:34 -070047 # if go generate created a diff
48 if ! git diff --exit-code; then
49 echo "go generate created a diff"
50 git diff
51 exit 1
52 fi
Earl Lee2e463fb2025-04-17 11:22:22 -070053
54 - name: Run tests
55 run: |
Philip Zeyliger6c1f34f2025-04-23 19:33:03 -070056 gotestsum --format testname -- ./...
57 gotestsum --format testname -- -race ./...