| 1 | on: |
| 2 | push: |
| 3 | branches: |
| 4 | - master |
| 5 | pull_request: |
| 6 | branches: |
| 7 | - master |
| 8 | |
| 9 | name: run tests |
| 10 | jobs: |
| 11 | lint: |
| 12 | runs-on: ubuntu-latest |
| 13 | steps: |
| 14 | - uses: actions/cache@v2 |
| 15 | with: |
| 16 | path: ~/go/pkg/mod |
| 17 | key: x${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 18 | restore-keys: | |
| 19 | ${{ runner.os }}-go- |
| 20 | - name: Install Go |
| 21 | uses: actions/setup-go@v2 |
| 22 | with: |
| 23 | go-version: 1.16.x |
| 24 | - name: Checkout code |
| 25 | uses: actions/checkout@v2 |
| 26 | - name: Run linters |
| 27 | uses: golangci/golangci-lint-action@v2 |
| 28 | with: |
| 29 | version: v1.29 |
| 30 | |
| 31 | test: |
| 32 | needs: lint |
| 33 | strategy: |
| 34 | matrix: |
| 35 | go-version: [1.16.x] |
| 36 | platform: [ubuntu-latest, macos-latest, windows-latest] |
| 37 | runs-on: ${{ matrix.platform }} |
| 38 | steps: |
| 39 | - uses: actions/cache@v2 |
| 40 | with: |
| 41 | path: ~/go/pkg/mod |
| 42 | key: x${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 43 | restore-keys: | |
| 44 | ${{ runner.os }}-go- |
| 45 | - name: Install Go |
| 46 | if: success() |
| 47 | uses: actions/setup-go@v2 |
| 48 | with: |
| 49 | go-version: ${{ matrix.go-version }} |
| 50 | - name: Checkout code |
| 51 | uses: actions/checkout@v2 |
| 52 | - name: Run tests |
| 53 | run: go test -v -covermode=count |
| 54 | |
| 55 | coverage: |
| 56 | needs: lint |
| 57 | runs-on: ubuntu-latest |
| 58 | steps: |
| 59 | - uses: actions/cache@v2 |
| 60 | with: |
| 61 | path: ~/go/pkg/mod |
| 62 | key: x${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 63 | restore-keys: | |
| 64 | ${{ runner.os }}-go- |
| 65 | - name: Install Go |
| 66 | if: success() |
| 67 | uses: actions/setup-go@v2 |
| 68 | with: |
| 69 | go-version: 1.16.x |
| 70 | - name: Checkout code |
| 71 | uses: actions/checkout@v2 |
| 72 | - name: Calc coverage |
| 73 | run: | |
| 74 | go test -v -covermode=count -coverprofile=coverage.out |
| 75 | - name: Convert coverage.out to coverage.lcov |
| 76 | uses: jandelgado/[email protected] |
| 77 | - name: Coveralls |
| 78 | uses: coverallsapp/[email protected] |
| 79 | with: |
| 80 | github-token: ${{ secrets.github_token }} |
| 81 | path-to-lcov: coverage.lcov |