| 1 | name: go |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - main |
| 7 | tags: |
| 8 | pull_request: |
| 9 | |
| 10 | jobs: |
| 11 | lint: |
| 12 | runs-on: ubuntu-latest |
| 13 | name: Linters (Static Analysis) for Go |
| 14 | steps: |
| 15 | - name: Checkout code into the Go module directory. |
| 16 | uses: actions/checkout@v2 |
| 17 | |
| 18 | - name: Install Go |
| 19 | uses: actions/setup-go@v2 |
| 20 | with: |
| 21 | go-version: 1.19.x |
| 22 | |
| 23 | - uses: actions/cache@v1 |
| 24 | with: |
| 25 | path: ~/go/pkg/mod |
| 26 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 27 | |
| 28 | - name: Linting & vetting. |
| 29 | env: |
| 30 | GOBIN: /tmp/.bin |
| 31 | run: make lint |
| 32 | tests: |
| 33 | runs-on: ${{ matrix.platform }} |
| 34 | strategy: |
| 35 | fail-fast: false |
| 36 | matrix: |
| 37 | go: [ '1.16.x', '1.17.x', '1.18.x', '1.19.x'] |
| 38 | platform: [ubuntu-latest, macos-latest] |
| 39 | |
| 40 | name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }} |
| 41 | steps: |
| 42 | - name: Checkout code into the Go module directory. |
| 43 | uses: actions/checkout@v2 |
| 44 | |
| 45 | - name: Install Go |
| 46 | uses: actions/setup-go@v2 |
| 47 | with: |
| 48 | go-version: ${{ matrix.go }} |
| 49 | |
| 50 | - uses: actions/cache@v1 |
| 51 | with: |
| 52 | path: ~/go/pkg/mod |
| 53 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 54 | |
| 55 | - name: Run unit tests. |
| 56 | env: |
| 57 | GOBIN: /tmp/.bin |
| 58 | run: make test |