blob: e10dbb3bd50e3d4e42200d234031041922fcc598 [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
Josh Bleecher Snyder2a32f012025-06-05 19:40:07 -070028 - name: Cache Go 1.24.4
Earl Lee2e463fb2025-04-17 11:22:22 -070029 uses: actions/cache@v4
30 with:
31 path: |
32 ~/.cache/go-build
Josh Bleecher Snyder2a32f012025-06-05 19:40:07 -070033 key: ${{ runner.os }}-go1.24.4-${{ hashFiles('**/go.sum') }}
Earl Lee2e463fb2025-04-17 11:22:22 -070034 restore-keys: |
Josh Bleecher Snyder2a32f012025-06-05 19:40:07 -070035 ${{ runner.os }}-go1.24.4-
Earl Lee2e463fb2025-04-17 11:22:22 -070036
philip.zeyliger46be0962025-06-14 17:51:15 +000037 - name: Optimize APT
38 run: ./.github/scripts/optimize-apt.sh
39
Earl Lee2e463fb2025-04-17 11:22:22 -070040 - name: Install tools
41 run: |
42 go install golang.org/x/tools/gopls@latest
Philip Zeyliger6c1f34f2025-04-23 19:33:03 -070043 go install gotest.tools/gotestsum@latest
Josh Bleecher Snyder833a0f82025-04-24 18:39:36 +000044 go install mvdan.cc/gofumpt@latest
45 go install golang.org/x/tools/cmd/goimports@latest
Philip Zeyligerc0131342025-06-13 21:07:08 -070046 # Empirically (by logging into runners with tmate), there are versions of Chromium/Chrome in /opt/google/chrome
47 # and /usr/local/share/chromium/chrome-linux. However, adding them to the PATH
48 # hasn't worked yet. I don't know why.
Philip Zeyliger8b43ffb2025-05-05 21:44:18 -070049 sudo apt-get update && sudo apt-get -y install chromium
Earl Lee2e463fb2025-04-17 11:22:22 -070050
51 - name: Go generate
52 run: |
53 go generate ./...
Josh Bleecher Snyder88c61bd2025-04-30 13:40:34 -070054 # if go generate created a diff
55 if ! git diff --exit-code; then
56 echo "go generate created a diff"
57 git diff
58 exit 1
59 fi
Earl Lee2e463fb2025-04-17 11:22:22 -070060
61 - name: Run tests
62 run: |
Josh Bleecher Snyder923a3ba2025-05-05 15:27:13 -070063 GOEXPERIMENT=synctest gotestsum --format testname -- ./...
64 GOEXPERIMENT=synctest gotestsum --format testname -- -race ./...