-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (73 loc) · 2.49 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
name: CI
on:
push:
branches:
- main
- release-*
pull_request: { }
workflow_dispatch: { }
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
cache: false
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
args: --timeout 10m0s
unit-tests:
strategy:
fail-fast: false
matrix:
include:
- step: mod
name: Check Go modules
command: go mod tidy && git add go.* && git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- step: manifests
name: Check manifests
command: make manifests && git add config && git diff --cached --exit-code || (echo 'Please run "make manifests" to generate manifests' && exit 1);
- step: generate
name: Check auto-generated codes
command: make generate && git add pkg apis && git diff --cached --exit-code || (echo 'Please run "make generate" to generate Go codes' && exit 1);
- step: gofmt
name: Verify gofmt
command: make fmt && git add apis pkg cmd && git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1);
- step: govet
name: Verify govet
command: make vet && git add apis pkg cmd && git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1);
- step: build
name: Run Go build
command: make build
- step: test
name: Run Go test
command: make fast-test
name: unit-tests(${{ matrix.name }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
cache: false
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-ut-${{ matrix.step }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-ut-${{ matrix.step }}-
- name: ${{ matrix.name }}
run: |
${{ matrix.command }}
- if: matrix.step == 'test'
name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: unittests
file: cover.out
fail_ci_if_error: true