-
Notifications
You must be signed in to change notification settings - Fork 106
130 lines (122 loc) · 3.99 KB
/
ci.yml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI
on:
push:
branches: [ main ]
pull_request: {}
workflow_dispatch: {}
jobs:
fmt:
name: Format
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: false
- name: Check Go modules
run: |
go mod tidy && git add go.* &&
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Verify gofumpt
run: |
echo "refer to https://github.com/mvdan/gofumpt for detailed info" &&
GO111MODULE=on go install mvdan.cc/[email protected] &&
make fmt-strict && git add pkg cmd &&
git diff --cached --exit-code || (echo 'Please run "make fmt-strict" to verify fmt' && exit 1);
vet:
name: Vet
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: false
- name: Verify govet
run: |
make vet && git add pkg cmd &&
git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1);
lint:
name: Lint
runs-on: vci-self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: false
- uses: golangci/golangci-lint-action@v3
with:
args: --verbose --out-${NO_FUTURE}format colored-line-number --config .golangci.yml
version: v1.52.2
skip-cache: true
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Build
run: make all-binaries
parallel:
name: Parallel
runs-on: vci-self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: false
- name: Check parallel
run: |
echo "refer to https://github.com/kunwardeep/paralleltest for detailed info" &&
GO111MODULE=on go install github.com/kunwardeep/[email protected] &&
paralleltest `go list ./... | grep -E -v "pkg/scheduler|pkg/controller/resource-recommend|pkg/util/resource-recommend"`
unit-test:
name: Unit Test
runs-on: vke-self-hosted
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Run unit tests
run: |
go install github.com/jstemmer/go-junit-report/v2@latest &&
sudo make test 2>&1 | go-junit-report -parser gojson --set-exit-code -iocopy -out report.xml
- name: Test summary
uses: test-summary/action@v2
with:
paths: report.xml
if: always()
- name: Check the number of changed lines
run: |
LINES_ADDED=$(git diff --numstat ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} pkg/ | awk '{ add += $1 } END { printf add }')
echo "lines added: $LINES_ADDED"
if [[ $LINES_ADDED -lt 10 ]]; then
echo "NEED_TO_CHECK=false" >> $GITHUB_ENV
else
echo "NEED_TO_CHECK=true" >> $GITHUB_ENV
fi
- name: Upload coverage to Codecov
if: ${{ (env.NEED_TO_CHECK == 'true') || (github.event_name != 'pull_request') }}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: 411bcf91-fb5f-444e-ad16-8380573a8c81
with:
flags: unittest
file: coverage.txt
fail_ci_if_error: true
verbose: true
license:
name: License
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Check license header
run: |
make license && git add pkg cmd &&
git diff --cached --exit-code || (echo 'Please run "make license" to add license headers' && exit 1);