microdata_mirror/.github/workflows/test.yml

81 lines
2.1 KiB
YAML
Raw Normal View History

2022-09-20 15:32:43 +03:00
on:
workflow_dispatch:
pull_request:
2023-03-03 13:40:09 +03:00
types: [opened, reopened, ready_for_review, synchronize]
2022-09-20 15:32:43 +03:00
push:
branches:
- main
- master
2023-03-03 13:59:32 +03:00
name: Run tests
2022-09-20 15:32:43 +03:00
jobs:
2023-11-25 16:39:16 +03:00
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Go
2024-02-21 13:52:50 +03:00
uses: actions/setup-go@v5
2023-11-25 16:39:16 +03:00
with:
go-version-file: 'go.mod'
- name: Get StaticCheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Gomod
run: |
go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy"
exit 1
fi
git diff --exit-code -- go.sum go.mod
- name: Gofmt
if: ${{ success() || failure() }} # run this step even if the previous one failed
run: |
out=$(gofmt -s -l .)
if [[ -n "$out" ]]; then
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
exit 1
fi
- name: Vet
if: ${{ success() || failure() }} # run this step even if the previous one failed
run: go vet ./...
- name: StaticCheck
if: ${{ success() || failure() }} # run this step even if the previous one failed
run: staticcheck ./...
2022-09-20 15:32:43 +03:00
test:
strategy:
matrix:
2023-03-03 13:40:09 +03:00
os: ["ubuntu", "windows", "macos"]
2022-09-20 15:32:43 +03:00
runs-on: ${{ matrix.os }}-latest
steps:
2023-03-03 13:40:09 +03:00
- name: Checkout
2023-11-24 17:58:53 +03:00
uses: actions/checkout@v4
2023-03-03 13:40:09 +03:00
with:
submodules: recursive
2023-11-24 17:58:53 +03:00
- name: Install Go
2024-02-21 13:52:50 +03:00
uses: actions/setup-go@v5
2023-03-03 13:40:09 +03:00
with:
2023-11-24 17:58:53 +03:00
go-version-file: 'go.mod'
2023-03-03 13:40:09 +03:00
- name: Test
run: go test ./...
2023-11-24 17:58:53 +03:00
2023-03-03 13:40:09 +03:00
- name: Test 32 bit
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
env:
GOARCH: 386
run: go test ./...
2023-11-24 17:58:53 +03:00
2023-03-03 13:40:09 +03:00
- name: Test with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
run: go test -race ./...