aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 9cec2f643b4a0282f745d9afe0c42b400b8cc3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: ci

on:
  - push
  - pull_request

jobs:
  go:
    name: Go ${{matrix.go}} - ${{matrix.os}}
    runs-on: ${{matrix.os}}

    strategy:
      matrix:
        os: ["windows-latest", "ubuntu-latest", "macOS-latest"]
        go: ["1.19.x"]
      fail-fast: false

    steps:
    - uses: actions/checkout@v1

    - uses: actions/setup-go@v3
      with:
        go-version: ${{matrix.go}}

    - name: Get Go cache path
      id: go-cache
      run: |
        echo "::set-output name=goos::$(go env GOOS)"
        echo "::set-output name=goarch::$(go env GOARCH)"
        echo "::set-output name=goversion::$(go env GOVERSION)"
        echo "::set-output name=gocache::$(go env GOCACHE)"
        echo "::set-output name=gomodcache::$(go env GOMODCACHE)"

    - name: Checkout
      uses: actions/checkout@v2

    - name: Go build cache
      uses: actions/cache@v2
      with:
        path: ${{steps.go-cache.outputs.gocache}}
        key: ${{steps.go-cache.outputs.goversion}}-${{steps.go-cache.outputs.goos}}-${{steps.go-cache.outputs.goarch}}-go-build-${{hashFiles('**/go.sum')}}

    - name: Go mod cache
      uses: actions/cache@v2
      with:
        path: ${{steps.go-cache.outputs.gomodcache}}
        key: ${{steps.go-cache.outputs.goversion}}-${{steps.go-cache.outputs.goos}}-${{steps.go-cache.outputs.goarch}}-go-mod-${{hashFiles('**/go.sum')}}

    - name: Go test
      run: go test -v ./...

    - name: Go vet
      run: go vet ./...

    - name: Go staticcheck
      run: go run honnef.co/go/tools/cmd/staticcheck@2022.1.3 ./...