-
Notifications
You must be signed in to change notification settings - Fork 79
190 lines (186 loc) · 5.98 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: CI
on:
push:
branches:
- master
- release-*
pull_request: {}
workflow_dispatch: {}
env:
# Common versions
GO_VERSION: '1.19'
GOLANGCI_VERSION: 'v1.51'
DOCKER_BUILDX_VERSION: 'v0.4.2'
KUSTOMIZE_VERSION: '3.9.2'
KUBEDL_CI: 'true'
KIND_VERSION: 'v0.11.1'
jobs:
staticcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dominikh/staticcheck-action@v1
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Fetch History
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Kubebuilder
run: |
os=$(go env GOOS)
arch=$(go env GOARCH)
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Validate Helm Chart
run: |
chart_version=$(yq e '.version' helm/kubedl/Chart.yaml)
values_version=$(yq e '.version' helm/kubedl/values.yaml)
if [ "$chart_version" != "$values_version" ]; then
echo "ERROR: Chart version ($chart_version) does not match values version ($values_version)"
exit 1
fi
- name: Run Unit Tests
run: |
make generate
make -j2 test
git status
- name: Publish Unit Test Coverage
uses: codecov/codecov-action@v1
with:
flags: unittests
file: cover.out
- name: Check diff
run: '[[ -z $(git status -s) ]] || (git diff; printf "Existing modified/untracked files.\nPlease run \"make generate manifests\" and push again.\n"; exit 1)'
go-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Code generate
run: |
make generate
- name: Lint golang code
uses: golangci/[email protected]
with:
version: ${{ env.GOLANGCI_VERSION }}
args: --out-format=colored-line-number --verbose
skip-pkg-cache: true
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Kind Cluster
uses: engineerd/[email protected]
with:
version: ${{ env.KIND_VERSION }}
- name: Build image
run: |
export IMAGE="kubedl/kubedl:e2e-${GITHUB_RUN_ID}"
docker build --pull --no-cache . -t $IMAGE
kind load docker-image $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; }
- name: Install KubeDL
run: |
set -ex
kubectl cluster-info
kubectl describe node
IMG_TAG=e2e-${GITHUB_RUN_ID} ./scripts/deploy_kubedl.sh
for ((i=1;i<10;i++));
do
set +e
PODS=$(kubectl get pod -n kubedl-system | grep 'kubedl' | grep 'Running' | wc -l)
set -e
if [ "$PODS" -eq 1 ]; then
break
fi
sleep 3
done
set +e
PODS=$(kubectl get pod -n kubedl-system | grep 'kubedl' | grep 'Running' | wc -l)
kubectl get all -n kubedl-system -o yaml
set -e
if [ "$PODS" -eq 1 ]; then
echo "kubedl-controller pod is running now"
else
echo "kubedl-controller pod is not at running state "
exit 1
fi
- name: Run TF simple distributed test job
run: |
set -ex
./scripts/run_tf_test_job.sh
if [ $? -eq 0 ]; then
echo "Succeed: ./scripts/run_tf_test_job.sh"
else
echo "Failed: ./scripts/run_tf_test_job.sh"
exit 1
fi
# enable golint checks later.
# golangci-lint:
# runs-on: ubuntu-18.04
# steps:
# - uses: actions/checkout@v2
# with:
# submodules: true
# - name: Fetch History
# run: git fetch --prune --unshallow
# - name: Setup Go
# uses: actions/setup-go@v2
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Cache Go Dependencies
# uses: actions/cache@v2
# with:
# path: ~/go/pkg/mod
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
# restore-keys: ${{ runner.os }}-go-
# - name: Code generate
# run: |
# make generate
# - name: Lint golang code
# uses: golangci/golangci-lint-action@v2
# with:
# version: ${{ env.GOLANGCI_VERSION }}
# args: --skip-dirs=apis --disable-all -E deadcode -E gofmt -E goimports -E golint -E ineffassign -E misspell -E vet --timeout=5m