forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (135 loc) · 5.41 KB
/
e2e.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
name: Test Controllers Metering and Account
env:
# Common versions
GO_VERSION: "1.20"
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- "controllers/metering/**"
- "controllers/common/metering/**"
- ".github/workflows/e2e.yml"
- "controllers/account/**"
- "!**/*.md"
- "!**/*.yaml"
jobs:
build-image:
runs-on: ubuntu-latest
strategy:
matrix:
module: [ metering, account ]
steps:
- name: Checkout # clone 代码
uses: actions/checkout@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Auto install sealos
uses: labring/[email protected]
with:
sealosVersion: 4.1.5-alpha2
- name: Build ${{ matrix.module }} amd64 # 打包amd64镜像
working-directory: controllers/${{ matrix.module }}
run: |
GOARCH=amd64 make build
mv bin/manager bin/controller-${{ matrix.module }}-amd64
chmod +x bin/controller-${{ matrix.module }}-amd64
- name: Build ${{ matrix.module }} arm64
working-directory: controllers/${{ matrix.module }}
run: |
GOARCH=arm64 make build
mv bin/manager bin/controller-${{ matrix.module }}-arm64
chmod +x bin/controller-${{ matrix.module }}-arm64
- name: Prepare
id: prepare
working-directory: controllers/${{ matrix.module }}
run: |
TAG=deploy
echo tag_name=${TAG} >> $GITHUB_OUTPUT
DOCKER_REPO=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller
echo docker_repo=${DOCKER_REPO} >> $GITHUB_OUTPUT
IMG=${DOCKER_REPO}:dev make pre-deploy
- name: Build ${{ matrix.module }} image
working-directory: controllers/${{ matrix.module }}
run: |
sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io
sealos build --debug -t ${{ steps.prepare.outputs.docker_repo }}:dev .
sealos push ${{ steps.prepare.outputs.docker_repo }}:dev
- name: build ${{ matrix.module }} main controller cluster image
working-directory: controllers/${{ matrix.module }}/deploy
run: |
ls -l
sealos build --debug -t ${{ steps.prepare.outputs.docker_repo }}:${{ steps.prepare.outputs.tag_name }}-cluster .
sealos push ${{ steps.prepare.outputs.docker_repo }}:${{ steps.prepare.outputs.tag_name }}-cluster
- name: docker images
run: |
sudo sealos images
e2e-test:
needs:
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Auto install sealos
uses: labring/[email protected]
with:
sealosVersion: 4.1.5-alpha2
- name: Auto install k8s using sealos
uses: labring/[email protected]
with:
image: labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:v3.24.1
debug: true
type: run-k8s
- name: After k8s operation
run: |
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
NODENAME=$(sudo -u root kubectl get nodes -ojsonpath='{.items[0].metadata.name}' )
NODEIP=$(sudo -u root kubectl get nodes -ojsonpath='{.items[0].status.addresses[0].address}' )
echo "NodeName=$NODENAME,NodeIP=$NODEIP"
sudo -u root kubectl taint node $NODENAME node-role.kubernetes.io/control-plane-
sleep 40
sudo -u root crictl ps -a
sudo -u root cat /etc/hosts
sudo -u root systemctl status kubelet
sudo -u root kubectl get nodes
sudo -u root kubectl get pods -A
- name: Prepare
id: prepare
run: |
TAG=deploy
echo tag_name=${TAG} >> $GITHUB_OUTPUT
- name: install common metering CRD
working-directory: ./controllers/common/metering
run: |
sudo -u root apt install make
make install
- name: install CRD metering
working-directory: ./controllers/metering
run: |
sudo sealos run --env METERING_INTERVAL=1 ghcr.io/${{ github.repository_owner }}/sealos-metering-controller:${{ steps.prepare.outputs.tag_name }}-cluster
- name: install CRD account
working-directory: ./controllers/account
run: |
sudo -u root sealos run docker.io/labring/cert-manager:v1.8.0
sleep 10
sudo kubectl get pod -A
IMG=ghcr.io/${{ github.repository_owner }}/sealos-account-controller:dev make pre-deploy
sudo -u root kubectl create namespace sealos-system
sudo -u root kubectl apply -f ./deploy/manifests/deploy.yaml
kubectl create configmap account-manager-configmap --from-literal=SMALL_BLOCK_WAIT_SECOND=1 -n account-system
sudo -u root kubectl create secret generic payment-secret -n account-system
sleep 10
- name: account e2e Test
working-directory: ./controllers/account
run: |
go test -v ./testdata/e2e/debt_test.go
sleep 20
- name: metering e2e Test
working-directory: ./controllers/metering
run: |
go test -v ./testdata/e2e/metering_test.go -run TestMetering