|
| 1 | +--- |
1 | 2 | name: test |
2 | 3 |
|
3 | 4 | on: |
|
7 | 8 | pull_request: |
8 | 9 |
|
9 | 10 | env: |
10 | | - GO111MODULE: on |
11 | | - GO_LATEST_VERSION: 1.20.x |
| 11 | + GO111MODULE: "on" |
12 | 12 |
|
13 | 13 | jobs: |
| 14 | + setup: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} |
| 18 | + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: nhatthm/gh-actions/checkout@master |
| 22 | + |
| 23 | + - id: find-go-version |
| 24 | + name: Find Go version |
| 25 | + uses: nhatthm/gh-actions/find-go-version@master |
| 26 | + |
14 | 27 | test: |
15 | 28 | strategy: |
16 | 29 | fail-fast: false |
17 | 30 | matrix: |
18 | 31 | os: [ ubuntu-latest, macos-latest ] |
19 | | - go-version: [ 1.18.x, 1.19.x, 1.20.x ] |
| 32 | + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} |
20 | 33 | runs-on: ${{ matrix.os }} |
| 34 | + needs: [setup] |
| 35 | + env: |
| 36 | + GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }} |
21 | 37 | steps: |
22 | | - - name: Install Go |
23 | | - uses: actions/setup-go@v5 |
24 | | - with: |
25 | | - go-version: ${{ matrix.go-version }} |
26 | | - |
27 | 38 | - name: Checkout code |
28 | | - uses: actions/checkout@v4 |
| 39 | + uses: nhatthm/gh-actions/checkout@master |
29 | 40 |
|
30 | | - - name: Go cache |
31 | | - uses: actions/cache@v4 |
| 41 | + - name: Install Go |
| 42 | + uses: nhatthm/gh-actions/setup-go@master |
32 | 43 | with: |
33 | | - # In order: |
34 | | - # * Module download cache |
35 | | - # * Build cache (Linux) |
36 | | - path: | |
37 | | - ~/go/pkg/mod |
38 | | - ~/.cache/go-build |
39 | | - key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }} |
40 | | - restore-keys: | |
41 | | - ${{ runner.os }}-go-${{ matrix.go-version }}-cache |
| 44 | + go-version: ${{ matrix.go-version }} |
42 | 45 |
|
43 | 46 | - name: Test |
44 | | - id: test |
45 | 47 | run: | |
46 | 48 | make test |
47 | 49 |
|
48 | 50 | - name: Upload code coverage (unit) |
49 | 51 | if: matrix.go-version == env.GO_LATEST_VERSION |
50 | | - uses: codecov/codecov-action@v3 |
| 52 | + uses: nhatthm/gh-actions/codecov@master |
51 | 53 | with: |
52 | 54 | files: ./unit.coverprofile |
53 | 55 | flags: unittests-${{ runner.os }} |
54 | 56 |
|
55 | | -# - name: Upload code coverage (features) |
56 | | -# if: matrix.go-version == env.GO_LATEST_VERSION |
57 | | -# uses: codecov/codecov-action@v3 |
58 | | -# with: |
59 | | -# files: ./features.coverprofile |
60 | | -# flags: featurestests-${{ runner.os }} |
| 57 | + #- name: Upload code coverage (features) |
| 58 | + # if: matrix.go-version == env.GO_LATEST_VERSION |
| 59 | + # uses: nhatthm/gh-actions/codecov@master |
| 60 | + # with: |
| 61 | + # file: ./features.coverprofile |
| 62 | + # flags: featurestests-${{ runner.os }} |
0 commit comments