Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Test
on: [push, pull_request]
permissions:
contents: read

jobs:
build:
name: Go CI
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.22", "1.23"]
steps:
- name: Check out source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 #v5.3.0
with:
go-version: ${{ matrix.go }}
- name: Use lint cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 #v4.2.0
with:
path: |
~/.cache/golangci-lint
key: go-lint-${{ matrix.go }}-${{ hashFiles('./go.sum') }}
restore-keys: go-lint-${{ matrix.go }}
- name: Install Linters
run: "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2"
- name: Build
run: go build ./...
- name: Test
run: |
sh ./run_tests.sh
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "2"
run:
timeout: 10m
linters:
default: none
enable:
- asciicheck
- bidichk
- durationcheck
- copyloopvar
- govet
- grouper
- ineffassign
- makezero
- nosprintfhostport
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- tparallel
- unconvert
settings:
staticcheck:
checks:
- S1*
formatters:
enable:
- gofmt
- goimports
24 changes: 24 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex

GV=$(go version | sed "s/^.*go\([0-9.]*\).*/\1/")
echo "Go version: $GV"

# Run `go mod tidy` and fail if the git status of go.mod and/or
# go.sum changes. Only do this for the latest Go version.
if [[ "$GV" =~ ^1.23 ]]; then
MOD_STATUS=$(git status --porcelain go.mod go.sum)
go mod tidy
UPDATED_MOD_STATUS=$(git status --porcelain go.mod go.sum)
if [ "$UPDATED_MOD_STATUS" != "$MOD_STATUS" ]; then
echo "running 'go mod tidy' modified go.mod and/or go.sum"
git diff --unified=0 go.mod go.sum
exit 1
fi
fi

# run tests
env GORACE="halt_on_error=1" go test -race -short ./...

# check linters
golangci-lint -c ./.golangci.yml run