-
Notifications
You must be signed in to change notification settings - Fork 14
218 lines (191 loc) · 7.86 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: CI
on:
release:
types: [created]
pull_request:
types: [opened, synchronize, reopened, ready_for_review, edited]
branches:
- main
paths:
- "charts/**"
- ".github/workflows/ci.yaml"
- "**.go"
- "**.proto"
- "go.mod"
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
with:
submodules: "recursive"
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #4.1.0
with:
go-version: "1.21"
cache: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: -v --config=.golangci.yml
unit-test:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/../go
HOME: ${{ github.workspace }}/..
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
with:
submodules: "recursive"
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #4.1.0
with:
go-version: "1.21"
cache: false
- name: EBPF prerequisites
run: |
set -x
sudo apt update && sudo apt install -y jq pkg-config libelf-dev clang
- name: Run unit tests
run: make unit-test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
verbose: true # optional (default = false)
test-k8s:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/../go
HOME: ${{ github.workspace }}/..
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
with:
submodules: "recursive"
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #4.1.0
with:
go-version: "1.21"
cache: false
- name: Install dependencies
run: |
set -x
# Install required dependencies and tools
sudo apt update && sudo apt install -y pkg-config libelf-dev clang
go install github.com/mgechev/revive@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@32051b4f86e54c2142c7c05362c6e96ae3454a1c # @v1.28.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@938f6e2f7550e542bd78f3b9e8812665db109e02 # @v1.1.0
- name: Create Kind registry
run: |
set -x
# Create a Kind registry
./dev/run-kind-registry.sh
- name: Kind Cluster
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 #v1.8.0
with:
config: "dev/cluster-config.yaml"
cluster_name: tarian-testing
- name: Testing Kind cluster setup
run: |
set -x
# Verify Kind cluster setup
kubectl cluster-info
kubectl wait --for=condition=ready pod --all --all-namespaces --timeout=300s
kubectl get pods -n kube-system
echo "kubectl config current-context:" $(kubectl config current-context)
echo "KUBECONFIG env var:" ${KUBECONFIG}
- name: Build
run: |
set -x
sudo apt update && sudo apt install -y jq pkg-config libelf-dev clang
go install google.golang.org/protobuf/cmd/protoc-gen-go@32051b4f86e54c2142c7c05362c6e96ae3454a1c # @v1.28.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@938f6e2f7550e542bd78f3b9e8812665db109e02 # @v1.1.0
make bin/protoc bin/goreleaser
bash ./dev/run-kind-registry.sh
make generate
./bin/goreleaser release --snapshot --rm-dist
make push-local-images
cp dist/tarianctl_linux_amd64/tarianctl ./bin/
- name: Install Tarian
run: |
set -x
./bin/tarianctl install --charts ./charts -l debug --agents-values ./dev/values/agents.yaml --server-values ./dev/values/server.yaml
continue-on-error: true
- name: Wait for pods to be ready
id: wait-until-tarian-is-ready
run: |
set -x
# Wait for all pods in the tarian-system namespace to be in the "Ready" state
kubectl wait --for=condition=ready pod --all -n tarian-system --timeout=300s
continue-on-error: true
- name: Run tests
id: run-tests
if: steps.wait-until-tarian-is-ready.outcome == 'success'
run: make k8s-test
continue-on-error: true
- name: Collect deployment information in case of failure
if: steps.wait-until-tarian-is-ready.outcome != 'success' || steps.run-tests.outcome != 'success'
run: |
set -x
# Collect logs and information for debugging in case of failure
kubectl get pods -n tarian-system
echo "======================================================================================================================"
kubectl describe pods -n tarian-system
echo "======================================================================================================================"
kubectl logs -n tarian-system deploy/tarian-server
echo "======================================================================================================================"
kubectl logs -n tarian-system deploy/tarian-cluster-agent
echo "======================================================================================================================"
kubectl logs -n tarian-system deploy/tarian-controller-manager
echo "======================================================================================================================"
kubectl logs -n tarian-system daemonsets/tarian-node-agent
echo "======================================================================================================================"
exit 1
test-e2e:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/../go
HOME: ${{ github.workspace }}/..
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
with:
submodules: "recursive"
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #4.1.0
with:
go-version: "1.21"
cache: false
- name: Start containers
run: docker-compose up -d
- name: Run end-to-end tests
id: run-e2e-tests
run: |
set -x
sudo apt update && sudo apt install -y pkg-config libelf-dev clang
go install github.com/mgechev/revive@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@32051b4f86e54c2142c7c05362c6e96ae3454a1c # @v1.28.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@938f6e2f7550e542bd78f3b9e8812665db109e02 # @v1.1.0
make bin/protoc
make build
make e2e-test
continue-on-error: true
- name: Collect logs in case of failure
if: steps.run-e2e-tests.outcome != 'success'
run: |
set -x
echo "======================================================================================================================"
docker-compose logs
echo "======================================================================================================================"
exit 1