-
Notifications
You must be signed in to change notification settings - Fork 67
170 lines (141 loc) · 4.92 KB
/
main.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
name: Main CI WorkFlow
on:
push:
branches:
- 'master'
- 'release-*'
tags:
- 'v*'
pull_request:
branches:
- 'master'
- 'release-*'
paths-ignore:
- 'docs/**'
- 'README.md'
- 'RELEASE.md'
- 'LICENSE'
- 'CHANGELOG.md'
env:
OP_IMAGE: kubesphere/notification-manager-operator:latest
NM_IMAGE: kubesphere/notification-manager:latest
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Basic test and verify
env:
GO111MODULE: "on"
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.x
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install kubebuilder-2.3.2
run: |
curl -L "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz" | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder
- name: Run basic test
run: make test
- name: Run verify crds test
run: make verify
build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Binary build
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.x
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- run: make binary
name: Run build all binaries
docker_build_and_helm_deployment:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Docker image build, install and uninstall by helm
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.x
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: build image
run: |
docker build . -t ${{ env.OP_IMAGE }} -f cmd/operator/Dockerfile --build-arg GOPROXY="https://proxy.golang.org"
docker build . -t ${{ env.NM_IMAGE }} -f cmd/notification-manager/Dockerfile --build-arg GOPROXY="https://proxy.golang.org"
- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Create kind cluster
uses: helm/kind-action@v1.2.0
with:
config: .github/workflows/kind/kind.yaml
- name: Setting up notification manager
run: |
kubectl create ns kubesphere-monitoring-system
helm install notification-manager ./helm -n kubesphere-monitoring-system --set "operator.containers.operator.image.tag=latest" --set "notificationmanager.image.tag=latest"
- name: Waiting for 60 seconds to keep the notification manager installed
uses: jakejarvis/wait-action@master
with:
time: '60s'
- name: Check the related resources
run: |
echo "list release:"
echo "-----"
helm list -n kubesphere-monitoring-system
echo "-----"
echo "list pods:"
echo "-----"
kubectl get pods -n kubesphere-monitoring-system
echo "-----"
- name: Deploy the default SlackConfig and global SlackReceiver if the slack secret is set
run: |
if [ '${{ secrets.SLACK_SECRET }}' != '' ] ; then
cat config/ci/slack-pr.yaml | sed -e 's/SLACK_SECRET/${{ secrets.SLACK_SECRET }}/g' | kubectl apply -f -
else
echo "No Slack secret is set, skipped..."
fi
- name: Expose service port as nodeport
run: |
kubectl -n kubesphere-monitoring-system patch svc notification-manager-svc --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"},{"op":"replace","path":"/spec/ports/0/nodePort","value":30008}]'
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v1
- name: Send alerts
run: |
NODE_IP=$(kubectl get nodes -o jsonpath={.items[0].status.addresses[0].address})
curl -XPOST -d @./config/ci/alerts.json "http://$NODE_IP:30008/api/v2/alerts" --connect-timeout 30
- name: Waiting for 2 seconds
uses: jakejarvis/wait-action@master
with:
time: '2s'
- name: Check the related logs
run: |
kubectl -n kubesphere-monitoring-system logs -l app=notification-manager | grep -i "error" || true
- name: Uninstall notification manager
run: |
helm uninstall notification-manager -n kubesphere-monitoring-system