2022-05-16 11:02:12 +00:00
|
|
|
name: build
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [opened, synchronize]
|
|
|
|
push:
|
2022-05-16 11:03:02 +00:00
|
|
|
branches: [main]
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
2022-11-28 10:34:25 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macos-latest
|
|
|
|
- ubuntu-latest
|
|
|
|
- windows-latest
|
|
|
|
|
2022-05-16 11:02:12 +00:00
|
|
|
steps:
|
2022-09-07 09:55:59 +00:00
|
|
|
- name: Checkout repository and submodules
|
2022-12-12 15:51:27 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
2022-05-16 11:02:12 +00:00
|
|
|
with:
|
2023-02-03 14:13:29 +00:00
|
|
|
go-version: 1.19.5
|
2022-09-08 09:21:00 +00:00
|
|
|
cache: true
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
- name: Set go env
|
|
|
|
run: |
|
|
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
2022-09-07 18:08:42 +00:00
|
|
|
go install gotest.tools/gotestsum@latest
|
2022-09-07 09:55:59 +00:00
|
|
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
2022-05-16 11:02:12 +00:00
|
|
|
|
|
|
|
- name: Pull external libraries
|
|
|
|
run: make vendor
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: make test
|
2022-09-07 13:15:23 +00:00
|
|
|
|
|
|
|
fmt:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Checkout
|
2022-12-12 15:51:27 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v3
|
2022-09-07 13:15:23 +00:00
|
|
|
with:
|
2022-12-14 14:59:47 +00:00
|
|
|
# Use 1.19 because of godoc formatting.
|
|
|
|
# See https://tip.golang.org/doc/go1.19#go-doc.
|
|
|
|
go-version: 1.19
|
2022-09-07 13:15:23 +00:00
|
|
|
|
2022-09-08 09:21:00 +00:00
|
|
|
# No need to download cached dependencies when running gofmt.
|
|
|
|
cache: false
|
|
|
|
|
2022-09-07 13:15:23 +00:00
|
|
|
- name: Run gofmt
|
|
|
|
run: |
|
|
|
|
# -l: list files that were reformatted
|
|
|
|
# -w: write back formatted files to disk
|
|
|
|
gofmt -l -w ./
|
|
|
|
|
2022-12-22 08:33:46 +00:00
|
|
|
- name: Run go mod tidy
|
|
|
|
run: |
|
|
|
|
go mod tidy
|
|
|
|
|
2022-09-07 13:15:23 +00:00
|
|
|
- name: Fail on differences
|
|
|
|
run: |
|
|
|
|
# Exit with status code 1 if there are differences (i.e. unformatted files)
|
|
|
|
git diff --exit-code
|