-
Notifications
You must be signed in to change notification settings - Fork 6
231 lines (206 loc) · 7.09 KB
/
test.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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Tests
on:
push:
workflow_dispatch:
inputs:
log_format:
description: "Log format"
required: false
default: "text"
type: string
log_level:
description: "Log level"
required: false
default: "info"
type: string
permissions:
contents: read
jobs:
go-unit:
name: Unit - Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: |
go install github.com/mfridman/tparse@latest
go mod download
- name: Set log format and level
id: inputs
run: |
if [ -z "${{ inputs.log_format }}" ]; then
echo "LOG_FORMAT=text" >> $GITHUB_OUTPUT
else
echo "LOG_FORMAT=${{ inputs.log_format }}" >> $GITHUB_OUTPUT
fi
if [ -z "${{ inputs.log_level }}" ]; then
echo "LOG_LEVEL=info" >> $GITHUB_OUTPUT
else
echo "LOG_LEVEL=${{ inputs.log_level }}" >> $GITHUB_OUTPUT
fi
- name: Run go unit tests
env:
LOG_FORMAT: ${{ steps.inputs.outputs.LOG_FORMAT }}
LOG_LEVEL: ${{ steps.inputs.outputs.LOG_LEVEL }}
run: |
go test -v -count=1 -test.short -race ./... -json -coverpkg ./... \
| tee output.jsonl | tparse -notests -follow -all || true
tparse -format markdown -file output.jsonl -all -slow 20 > $GITHUB_STEP_SUMMARY
go-e2e:
name: E2E - Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: |
go install github.com/mfridman/tparse@latest
go mod download
- name: Set log format and level
id: inputs
run: |
if [ -z "${{ inputs.log_format }}" ]; then
echo "No log format provided, using default: text"
echo "LOG_FORMAT=text" >> $GITHUB_OUTPUT
else
echo "Log format provided: ${{ inputs.log_format }}"
echo "LOG_FORMAT=${{ inputs.log_format }}" >> $GITHUB_OUTPUT
fi
if [ -z "${{ inputs.log_level }}" ]; then
echo "No log level provided, using default: info"
echo "LOG_LEVEL=info" >> $GITHUB_OUTPUT
else
echo "Log level provided: ${{ inputs.log_level }}"
echo "LOG_LEVEL=${{ inputs.log_level }}" >> $GITHUB_OUTPUT
fi
- name: Run go e2e tests
env:
LOG_FORMAT: ${{ steps.inputs.outputs.LOG_FORMAT }}
LOG_LEVEL: ${{ steps.inputs.outputs.LOG_LEVEL }}
run: |
go test -v -count=1 -race ./... -json -coverpkg ./... \
| tee output.jsonl | tparse -notests -follow -all || true
tparse -format markdown -file output.jsonl -all -slow 20 > $GITHUB_STEP_SUMMARY
traceroute:
name: E2E - Traceroute
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
sudo add-apt-repository ppa:katharaframework/kathara
sudo apt-get update
sudo apt-get install -y jq kathara
- name: Setup kathara
run: |
echo '{
"image": "kathara/base",
"manager_type": "docker",
"terminal": "/usr/bin/xterm",
"open_terminals": false,
"device_shell": "/bin/bash",
"net_prefix": "kathara",
"device_prefix": "kathara",
"debug_level": "INFO",
"print_startup_log": true,
"enable_ipv6": false,
"last_checked": 1721834897.2415252,
"hosthome_mount": false,
"shared_mount": true,
"image_update_policy": "Prompt",
"shared_cds": 1,
"remote_url": null,
"cert_path": null,
"network_plugin": "kathara/katharanp_vde"
}' > ~/.config/kathara.conf
- name: Build binary for e2e
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: build --single-target --clean --snapshot --config .goreleaser-ci.yaml
- name: Run e2e tests
run: |
./scripts/run_e2e_tests.sh
k8s:
name: E2E - Kubernetes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up K3S
uses: debianmaster/actions-k3s@master
id: k3s
with:
version: "v1.31.2-k3s1"
- name: Check Cluster
run: kubectl get nodes
- name: Check Coredns Deployment
run: |
kubectl -n kube-system rollout status deployment/coredns --timeout=60s
STATUS=$(kubectl -n kube-system get deployment coredns -o jsonpath={.status.readyReplicas})
if [[ $STATUS -ne 1 ]]
then
echo "Deployment coredns not ready"
kubectl -n kube-system get events
exit 1
else
echo "Deployment coredns OK"
fi
- name: Check Metricsserver Deployment
run: |
kubectl -n kube-system rollout status deployment/metrics-server --timeout=60s
STATUS=$(kubectl -n kube-system get deployment metrics-server -o jsonpath={.status.readyReplicas})
if [[ $STATUS -ne 1 ]]
then
echo "Deployment metrics-server not ready"
kubectl -n kube-system get events
exit 1
else
echo "Deployment metrics-server OK"
fi
- name: Setup Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version
- name: Get Image Tag
id: version
run: echo "value=commit-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Install Sparrow
run: |
helm upgrade -i sparrow \
--atomic \
--timeout 300s \
--set image.tag=${{ steps.version.outputs.value }} \
--set sparrowConfig.name=the-sparrow.com \
--set sparrowConfig.loader.type=file \
--set sparrowConfig.loader.interval=5s \
--set sparrowConfig.loader.file.path=/config/.sparrow.yaml \
--set checksConfig.health.interval=1s \
--set checksConfig.health.timeout=1s \
./chart
- name: Check Pods
run: kubectl get pods
- name: Wait for Sparrow
run: sleep 45
- name: Healthcheck
run: |
kubectl create job curl --image=quay.io/curl/curl:latest -- curl -f -v -H 'Content-Type: application/json' http://sparrow:8080/v1/metrics/health
kubectl wait --for=condition=complete job/curl
STATUS=$(kubectl get job curl -o jsonpath={.status.succeeded})
if [[ $STATUS -ne 1 ]]
then
echo "Job failed"
kubectl logs -ljob-name=curl
kubectl delete job curl
exit 1
else
echo "Job OK"
kubectl delete job curl
fi