|
| 1 | +name: Test |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - release/** |
| 7 | + pull_request: |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | +concurrency: |
| 14 | + group: test-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + name: Unit |
| 19 | + runs-on: ${{ matrix.os }}-latest |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + go: [ "1.18", "1.17", "1.16", "1.15", "1.14", "1.13" ] |
| 23 | + os: [ ubuntu, windows, macos ] |
| 24 | + fail-fast: false |
| 25 | + env: |
| 26 | + GO111MODULE: "on" |
| 27 | + GOFLAGS: "-mod=readonly" |
| 28 | + steps: |
| 29 | + - uses: actions/setup-go@v3 |
| 30 | + with: |
| 31 | + go-version: ${{ matrix.go }} |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + - uses: actions/cache@v2 |
| 34 | + with: |
| 35 | + # In order: |
| 36 | + # * Module download cache |
| 37 | + # * Build cache (Linux) |
| 38 | + # * Build cache (Mac) |
| 39 | + # * Build cache (Windows) |
| 40 | + path: | |
| 41 | + ~/go/pkg/mod |
| 42 | + ~/.cache/go-build |
| 43 | + ~/Library/Caches/go-build |
| 44 | + %LocalAppData%\go-build |
| 45 | + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-go-${{ matrix.go }}- |
| 48 | + ${{ runner.os }}-go- |
| 49 | + - name: Build |
| 50 | + run: go build ./... |
| 51 | + - name: Vet |
| 52 | + run: go vet ./... |
| 53 | + - name: Check go.mod Tidiness |
| 54 | + run: go mod tidy -go=1.18 -compat=1.16 && git diff --exit-code |
| 55 | + if: ${{ matrix.go == '1.18' }} |
| 56 | + - name: Test |
| 57 | + run: go test -count=1 ./... |
| 58 | + - name: Test (race) |
| 59 | + run: go test -count=1 -race ./... |
| 60 | + # The race detector adds considerable runtime overhead. To save time on |
| 61 | + # pull requests, only run this step for a single job in the matrix. For |
| 62 | + # all other workflow triggers (e.g., pushes to a release branch) run |
| 63 | + # this step for the whole matrix. |
| 64 | + if: ${{ github.event_name != 'pull_request' || (matrix.go == '1.18' && matrix.os == 'ubuntu') }} |
| 65 | + timeout-minutes: 5 |
0 commit comments