|
9 | 9 | push: |
10 | 10 | branches: |
11 | 11 | - main |
| 12 | + release: |
| 13 | + types: |
| 14 | + - published |
| 15 | + |
| 16 | +env: |
| 17 | + IS_PR: ${{github.event_name == 'pull_request' || ''}} |
| 18 | + IS_MAIN: ${{github.event_name == 'push' || ''}} |
| 19 | + IS_RELEASE: ${{github.event_name == 'release' || ''}} |
12 | 20 |
|
13 | 21 | jobs: |
14 | 22 | build: |
15 | 23 | runs-on: ubuntu-latest |
16 | 24 | steps: |
17 | | - - uses: actions/checkout@v4 |
18 | | - |
19 | | - - name: Setup Go |
20 | | - uses: actions/setup-go@v5 |
21 | | - |
22 | | - - name: Download dependencies |
23 | | - run: go mod download |
24 | | - |
25 | | - - name: Test |
26 | | - env: |
27 | | - GOTESTSUM_JUNITFILE: junit.xml |
28 | | - run: make |
29 | | - |
30 | | - - name: Upload results to Codecov |
31 | | - uses: codecov/codecov-action@v4 |
32 | | - with: |
33 | | - token: ${{ secrets.CODECOV_TOKEN }} |
34 | | - |
35 | | - - name: Upload test results to Codecov |
36 | | - if: ${{ !cancelled() }} |
37 | | - uses: codecov/test-results-action@v1 |
38 | | - with: |
39 | | - token: ${{ secrets.CODECOV_TOKEN }} |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - uses: actions/cache/restore@v4 |
| 28 | + with: |
| 29 | + key: ${{ runner.os }}-go-cache |
| 30 | + path: | |
| 31 | + ~/.magefile |
| 32 | + ~/.cache/golangci-lint |
| 33 | + ~/.cache/go-build |
| 34 | + ~/go/pkg/mod |
| 35 | +
|
| 36 | + - uses: actions/setup-go@v5 |
| 37 | + with: |
| 38 | + go-version-file: go.mod |
| 39 | + cache: false |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: go mod download |
| 43 | + |
| 44 | + - name: Lint |
| 45 | + run: make lint |
| 46 | + |
| 47 | + - name: Test |
| 48 | + run: make test |
| 49 | + |
| 50 | + - name: Upload results to Codecov |
| 51 | + uses: codecov/codecov-action@v4 |
| 52 | + with: |
| 53 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 54 | + files: ./coverage.txt |
| 55 | + |
| 56 | + - name: Upload test results to Codecov |
| 57 | + if: ${{ !cancelled() }} |
| 58 | + uses: codecov/test-results-action@v1 |
| 59 | + with: |
| 60 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 61 | + files: ./junit.xml |
| 62 | + |
| 63 | + - uses: actions/cache/save@v4 |
| 64 | + if: ${{ env.IS_MAIN }} |
| 65 | + with: |
| 66 | + key: ${{ runner.os }}-go-cache |
| 67 | + path: | |
| 68 | + ~/.magefile |
| 69 | + ~/.cache/golangci-lint |
| 70 | + ~/.cache/go-build |
| 71 | + ~/go/pkg/mod |
0 commit comments