|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + schedule: |
| 6 | + - cron: "0 0 * * 0" |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + name: Test |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + go-version: |
| 14 | + - "1.15" |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout/@v2 |
| 19 | + |
| 20 | + - name: Setup Go |
| 21 | + uses: actions/setup-go@v1 |
| 22 | + with: |
| 23 | + go-version: ${{ matrix.go-version }} |
| 24 | + |
| 25 | + - name: Cache go modules |
| 26 | + uses: actions/cache@v2 |
| 27 | + with: |
| 28 | + path: ~/go/pkg/mod |
| 29 | + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} |
| 30 | + restore-keys: ${{ runner.os }}-go-mod- |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: go mod vendor -v |
| 34 | + |
| 35 | + - name: Run go test |
| 36 | + run: go test -ldflags "-s -w" -coverprofile coverage.txt -covermode atomic ./cmd/... ./pkg/... |
| 37 | + |
| 38 | + - name: Check coverage.txt existence |
| 39 | + id: check-coverage-file |
| 40 | + if: ${{ always() }} |
| 41 | + uses: andstor/file-existence-action@v1 |
| 42 | + with: |
| 43 | + files: coverage.txt |
| 44 | + |
| 45 | + - name: Upload coverage as artifacts |
| 46 | + if: ${{ always() && steps.check-coverage-file.outputs.files_exists == 'true' }} |
| 47 | + uses: actions/upload-artifact@v2 |
| 48 | + with: |
| 49 | + name: coverage-${{ matrix.go-version }} |
| 50 | + path: coverage.txt |
| 51 | + |
| 52 | + - name: Upload coverage to Codecov |
| 53 | + if: ${{ always() && steps.check-coverage-file.outputs.files_exists == 'true' }} |
| 54 | + uses: codecov/codecov-action@v1 |
| 55 | + with: |
| 56 | + name: coverage-${{ matrix.go-version }} |
| 57 | + file: coverage.txt |
| 58 | + |
| 59 | + vet: |
| 60 | + name: Vet |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout/@v2 |
| 65 | + |
| 66 | + - name: Setup Go |
| 67 | + uses: actions/setup-go@v1 |
| 68 | + with: |
| 69 | + go-version: "1.15" |
| 70 | + |
| 71 | + - name: Cache go modules |
| 72 | + uses: actions/cache@v2 |
| 73 | + with: |
| 74 | + path: ~/go/pkg/mod |
| 75 | + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} |
| 76 | + restore-keys: ${{ runner.os }}-go-mod- |
| 77 | + |
| 78 | + - name: Install dependencies |
| 79 | + run: go mod vendor -v |
| 80 | + |
| 81 | + - name: Run go vet |
| 82 | + run: go vet -ldflags "-s -w" ./cmd/... ./pkg/... |
0 commit comments