|
| 1 | +name: Run Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Setup go |
| 16 | + uses: actions/setup-go@v2 |
| 17 | + with: |
| 18 | + go-version: '^1.16' |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v2 |
| 21 | + - name: Setup golangci-lint |
| 22 | + uses: golangci/golangci-lint-action@v2 |
| 23 | + with: |
| 24 | + version: v1.42.0 |
| 25 | + args: --verbose |
| 26 | + test: |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + os: [ubuntu-latest, macos-latest] |
| 30 | + go: [1.13, 1.14, 1.15, 1.16, 1.17] |
| 31 | + test-tags: ['', nomsgpack] |
| 32 | + include: |
| 33 | + - os: ubuntu-latest |
| 34 | + go-build: ~/.cache/go-build |
| 35 | + - os: macos-latest |
| 36 | + go-build: ~/Library/Caches/go-build |
| 37 | + name: ${{ matrix.os }} @ Go ${{ matrix.go }} ${{ matrix.test-tags }} |
| 38 | + runs-on: ${{ matrix.os }} |
| 39 | + env: |
| 40 | + GO111MODULE: on |
| 41 | + TESTTAGS: ${{ matrix.test-tags }} |
| 42 | + GOPROXY: https://proxy.golang.org |
| 43 | + steps: |
| 44 | + - name: Set up Go ${{ matrix.go }} |
| 45 | + uses: actions/setup-go@v2 |
| 46 | + with: |
| 47 | + go-version: ${{ matrix.go }} |
| 48 | + |
| 49 | + - name: Checkout Code |
| 50 | + uses: actions/checkout@v2 |
| 51 | + with: |
| 52 | + ref: ${{ github.ref }} |
| 53 | + |
| 54 | + - uses: actions/cache@v2 |
| 55 | + with: |
| 56 | + path: | |
| 57 | + ${{ matrix.go-build }} |
| 58 | + ~/go/pkg/mod |
| 59 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-go- |
| 62 | +
|
| 63 | + - name: Run Tests |
| 64 | + run: make test |
| 65 | + |
| 66 | + - name: Upload coverage to Codecov |
| 67 | + uses: codecov/codecov-action@v2 |
| 68 | + with: |
| 69 | + flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }} |
| 70 | + notification-gitter: |
| 71 | + needs: test |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: Notification failure message |
| 75 | + if: failure() |
| 76 | + run: | |
| 77 | + PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)" |
| 78 | + curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" -d level=error https://webhooks.gitter.im/e/7f95bf605c4d356372f4 |
| 79 | + - name: Notification success message |
| 80 | + if: success() |
| 81 | + run: | |
| 82 | + PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)" |
| 83 | + curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" https://webhooks.gitter.im/e/7f95bf605c4d356372f4 |
0 commit comments