-
Notifications
You must be signed in to change notification settings - Fork 499
80 lines (75 loc) · 2.43 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: ci
on:
pull_request:
branches:
- master
- release-*
push:
branches:
- master
- release-*
jobs:
pull:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
job:
- verify
- build
- test
- e2e-examples
steps:
# the GITHUB_SHA env is not the real commit hash but is the pre-merge commit ID for `pull_request` event,
# see https://github.community/t/github-sha-isnt-the-value-expected/17903/2
# so we checkout the repo with `fetch-depth: 2` and let `codecov/codecov-action` to retrieve the real commit hash.
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
path: go/src/github.com/${{ github.repository }}
fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go/src/github.com/${{ github.repository }}/go.mod
cache-dependency-path: "**/*.sum"
- name: Set vars
run: |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Try to use build cache
uses: actions/cache@v4
with:
path: |
${{ env.GOCACHE }}
${{ env.GOMODCACHE }}
key: ${{ runner.os }}-go-${{ hashFiles(format('go/src/github.com/{0}/**/go.sum', github.repository)) }}
restore-keys: |
${{ runner.os }}-go-
- name: ${{ matrix.job }}
run: |
# workaround for https://github.com/actions/setup-go/issues/14
export GOPATH=${GITHUB_WORKSPACE}/go
export PATH=$PATH:$GOPATH/bin
if [[ "$job" == "verify" ]]; then
make check-setup check
elif [[ "$job" == "build" ]]; then
make docker e2e-docker debug-build-docker
elif [[ "$job" == "test" ]]; then
make test GOFLAGS=-race GO_COVER=y
else
make $job
fi
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
env:
job: ${{ matrix.job }}
- name: Upload test coverage
uses: codecov/codecov-action@v4
with:
flags: unittest
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
if: ${{ matrix.job == 'test' }}
- name: Set up tmate session
if: ${{ matrix.job == 'e2e-examples' && failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60