blob: 95049cd377b667eaa3c5834ea04c3ef516e456e6 [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, and /usr/bin/chromium links to the former. Therefore, we
# don't need to apt-get it separately.
# If you wish to do some interactive debugging, the following is handy. It will print
# an SSH command that you can use to connect to the runner instance.
- name: tmate debugging (disabled)
if: false
run: |
sudo apt-get update && sudo apt-get install -y tmate
set -x
tmate -S /tmp/tmate.sock.${GITHUB_RUN_ID} new-session -d
tmate -S /tmp/tmate.sock.${GITHUB_RUN_ID} wait tmate-ready
tmate -S /tmp/tmate.sock.${GITHUB_RUN_ID} display -p '#{tmate_ssh}'
sleep 1800
- 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 ./...