blob: e10dbb3bd50e3d4e42200d234031041922fcc598 [file] [log] [blame]
name: go_tests
on:
workflow_call:
inputs:
ref:
description: "The git ref to checkout"
required: false
type: string
default: ""
push:
branches-ignore:
- "queue-main-*"
- "queue-dev-*"
pull_request:
jobs:
test:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Cache Go 1.24.4
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
key: ${{ runner.os }}-go1.24.4-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go1.24.4-
- name: Optimize APT
run: ./.github/scripts/optimize-apt.sh
- name: Install tools
run: |
go install golang.org/x/tools/gopls@latest
go install gotest.tools/gotestsum@latest
go install mvdan.cc/gofumpt@latest
go install golang.org/x/tools/cmd/goimports@latest
# Empirically (by logging into runners with tmate), there are versions of Chromium/Chrome in /opt/google/chrome
# and /usr/local/share/chromium/chrome-linux. However, adding them to the PATH
# hasn't worked yet. I don't know why.
sudo apt-get update && sudo apt-get -y install chromium
- name: Go generate
run: |
go generate ./...
# if go generate created a diff
if ! git diff --exit-code; then
echo "go generate created a diff"
git diff
exit 1
fi
- name: Run tests
run: |
GOEXPERIMENT=synctest gotestsum --format testname -- ./...
GOEXPERIMENT=synctest gotestsum --format testname -- -race ./...