-
Notifications
You must be signed in to change notification settings - Fork 747
141 lines (122 loc) · 5.39 KB
/
e2e-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
name: e2e-TEST
on:
push:
branches:
- 'master'
- 'release-*'
pull_request:
branches:
- 'master'
- 'release-*'
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: ks-installer
IMAGE_REPO: kubespheredev
IMAGE_VERSION: latest
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_TEST }}
jobs:
Test-on-k8s-v-1-19-7:
runs-on: self-hosted
timeout-minutes: 150
outputs:
is_MY_SECRET_set: ${{ steps.checksecret_job.outputs.is_MY_SECRET_set }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Clean up
run: kind delete cluster --name chart-testing && docker image prune -f
- name: Build image (pr)
if: ${{ github.event_name == 'pull_request' }}
run: |
echo ${{ github.base_ref }}
tag=${{ github.base_ref }} && sed -i "2idev_tag\: $tag" roles/download/defaults/main.yml && sed -i "/ \"version\"/s/\:.*/\: \"$tag\"/g" controller/installRunner.py
docker build . --file Dockerfile --tag ks-installer
- name: Build image (push)
if: ${{ github.event_name == 'push' }}
run: |
echo ${GITHUB_REF#refs/heads/}
tag=${GITHUB_REF#refs/heads/} && sed -i "2idev_tag\: $tag" roles/download/defaults/main.yml && sed -i "/ \"version\"/s/\:.*/\: \"$tag\"/g" controller/installRunner.py
docker build . --file Dockerfile --tag ks-installer
- name: Create kind cluster
uses: helm/[email protected]
with:
config: .github/workflows/kind/kind.yaml
- name: Load image to kind
run: kind load docker-image ks-installer --name chart-testing
- name: Deploy KubeSphere to Kind
run: |
sed -i 's/image: .*/image: ks-installer/g' deploy/kubesphere-installer.yaml
sed -i 's/imagePullPolicy: .*/imagePullPolicy: IfNotPresent/g' deploy/kubesphere-installer.yaml
sed -i 's/jenkinsMemoryReq: .*/jenkinsMemoryReq: 200Mi/g' deploy/cluster-configuration.yaml
kubectl apply -f deploy/kubesphere-installer.yaml
kubectl apply -f deploy/cluster-configuration.yaml
bash scripts/check_cluster_status.sh
- name: Test plugin
run: |
kubectl -n kubesphere-system patch cc ks-installer --type merge --patch '{"spec":{"servicemesh":{"enabled":true},"devops":{"enabled":true},"alerting":{"enabled":true},"auditing":{"enabled":true},"console":{"enableMultiLogin":true},"events":{"enabled":true},"logging":{"enabled":true},"metrics_server":{"enabled":true},"network":{"networkpolicy":{"enabled":true}},"openpitrix":{"store":{"enabled":true}}}}'
bash scripts/check_cluster_status.sh
# - name: Clean up (servicemesh / devops / gatekeeper)
# run: kind delete cluster --name chart-testing
#
# - name: Create kind cluster (servicemesh / devops / gatekeeper)
# uses: helm/[email protected]
# with:
# config: .github/workflows/kind/kind.yaml
#
# - name: Load image to kind (servicemesh / devops / gatekeeper)
# run: kind load docker-image ks-installer --name chart-testing
#
# - name: Deploy KubeSphere to Kind (servicemesh / devops / gatekeeper)
# run: |
# kubectl apply -f deploy/kubesphere-installer.yaml
# kubectl apply -f deploy/cluster-configuration.yaml
# bash scripts/check_cluster_status.sh
#
# - name: Test plugin (servicemesh / devops / gatekeeper)
# run: |
# kubectl -n kubesphere-system patch cc ks-installer --type merge --patch '{"spec":{"servicemesh":{"enabled":true},"devops":{"enabled":true},"gatekeeper":{"enabled":true}}}'
# bash scripts/check_cluster_status.sh
- name: Check DOCKER_PASSWORD secret
id: checksecret_job
env:
MY_SECRET: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "is_MY_SECRET_set: ${{ env.MY_SECRET != '' }}"
echo "::set-output name=is_MY_SECRET_set::${{ env.MY_SECRET != '' }}"
- name: slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
if: ${{ failure() }}
push-image-to-dockerhub:
runs-on: ubuntu-latest
needs: [Test-on-k8s-v-1-19-7]
if: needs.Test-on-k8s-v-1-19-7.outputs.is_MY_SECRET_set == 'true'
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v1
- name: Log into registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Get Version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/heads/}
- name: Push image
run: |
echo ${GITHUB_REF#refs/heads/}
tag=${GITHUB_REF#refs/heads/} && sed -i "2idev_tag\: $tag" roles/download/defaults/main.yml && sed -i "/ \"version\"/s/\:.*/\: \"$tag\"/g" controller/installRunner.py
IMAGE=$IMAGE_REPO/$IMAGE_NAME:${{ steps.get_version.outputs.VERSION }}
docker buildx build --platform linux/amd64,linux/arm64 --push -f Dockerfile.complete -t $IMAGE .
echo "Push $IMAGE success!"
- name: slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
if: ${{ failure() }}