1+ # Tencent is pleased to support the open source community by making Polaris available.
2+ #
3+ # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
4+ #
5+ # Licensed under the BSD 3-Clause License (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # https://opensource.org/licenses/BSD-3-Clause
10+ #
11+ # Unless required by applicable law or agreed to in writing, software distributed
12+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
14+ # specific language governing permissions and limitations under the License.
15+
16+ name : Integration
17+
18+ on :
19+ push :
20+ branches :
21+ - main
22+ - release*
23+ pull_request :
24+ branches :
25+ - main
26+ - release*
27+ workflow_dispatch :
28+ inputs :
29+ logLevel :
30+ description : ' Log level'
31+ required : true
32+ default : ' warning'
33+ type : choice
34+ options :
35+ - info
36+ - warning
37+ - debug
38+ tags :
39+ description : ' Tags'
40+ required : false
41+ type : boolean
42+ environment :
43+ description : ' Environment to run tests against'
44+ type : environment
45+ required : false
46+
47+ permissions :
48+ contents : write
49+
50+ # Always force the use of Go modules
51+ env :
52+ GO111MODULE : on
53+
54+ jobs :
55+ build :
56+ strategy :
57+ matrix :
58+ os : [ ubuntu-latest ]
59+ goarch : [ amd64 ]
60+ goos : [ linux ]
61+ include :
62+ - os : ubuntu-latest
63+ goos : linux
64+ goarch : amd64
65+ vert : 1
66+ exclude :
67+ - os : ubuntu-latest
68+ goos : windows
69+ - os : ubuntu-latest
70+ goos : darwin
71+ - os : windows-latest
72+ goos : linux
73+ - os : windows-latest
74+ goos : darwin
75+ - os : macos-latest
76+ goos : windows
77+ - os : macos-latest
78+ goos : linux
79+
80+ runs-on : ${{ matrix.os }}
81+ services :
82+ # Label used to access the service container
83+ redis :
84+ # Docker Hub image
85+ image : redis
86+ # Set health checks to wait until redis has started
87+ options : >-
88+ --health-cmd "redis-cli ping"
89+ --health-interval 10s
90+ --health-timeout 5s
91+ --health-retries 5
92+ ports :
93+ # Maps port 6379 on service container to the host
94+ - 6379:6379
95+ steps :
96+ # Setup the environment.
97+ - name : Setup Go
98+ uses : actions/setup-go@v4
99+ with :
100+ go-version : " 1.21.5"
101+ # Checkout latest code
102+ - name : Checkout repo
103+ uses : actions/checkout@v2
104+
105+ - name : Initialize database
106+ env :
107+ MYSQL_DB_USER : root
108+ MYSQL_DB_PWD : root
109+ MYSQL_DATABASE : polaris_server
110+ run : |
111+ sudo systemctl start mysql.service
112+ mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }}
113+ mysql -e "ALTER USER '${{ env.MYSQL_DB_USER }}'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }}
114+
115+ # Compile
116+ - name : Build And Test
117+ env :
118+ GOOS : ${{ matrix.goos }}
119+ GOARCH : ${{ matrix.goarch }}
120+ MYSQL_DB_USER : root
121+ MYSQL_DB_PWD : root
122+ REDIS_ADDR : 127.0.0.1:6379
123+ REDIS_PWD :
124+ run : |
125+ workir=$(pwd)
126+ export STORE_MODE=sqldb
127+ export MYSQL_DB_USER=${{ env.MYSQL_DB_USER }}
128+ export MYSQL_DB_PWD=${{ env.MYSQL_DB_PWD }}
129+ echo "cur STORE MODE=${STORE_MODE}"
130+ polaris_server_tag=v1.18.0-beta.1
131+ # 设置严格模式
132+ mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "set sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'";
133+ # 清空数据
134+ mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "DROP DATABASE IF EXISTS polaris_server";
135+ # 初始化 polaris 数据库
136+ mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" < store/mysqlopt/scripts/polaris_server.sql
137+ # 临时放开 DB 的最大连接数
138+ mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "set GLOBAL max_connections = 3000;"
139+
140+ ## 清理之前的临时资源
141+ rm -rf build_resource
142+
143+ ## 准备临时构建资源文件夹
144+ mkdir build_resource
145+ cp plugin_store_mysql_opt.go.temp ./build_resource
146+ cd build_resource
147+
148+ git clone https://github.com/polarismesh/polaris.git
149+ cd polaris
150+ if [ "${polaris_server_tag}" != "" ]; then
151+ git checkout ${polaris_server_tag}
152+ fi
153+
154+ cat ../plugin_store_mysql_opt.go.temp >plugin_store_mysql_opt.go
155+
156+ go clean --modcache
157+ go get github.com/polaris-contrib/store-mysqlopt
158+ go mod tidy
159+
160+ make build VERSION=${polaris_server_tag}
161+
162+ # 找构建好的 server 安装目录
163+ server_install_dir=$(ls | grep polaris-server-release | sed -n '1p')
164+ echo "server_install_dir is $server_install_dir"
165+
166+ cp -rf ${workir}/test/data/polaris-server.yaml ${workir}/build_resource/polaris/${server_install_dir}
167+ cd ${workir}/build_resource/polaris/${server_install_dir}
168+
169+ ls -alR
170+ chmod +x ./tool/*.sh
171+ ./tool/start.sh
172+
173+ sleep 120s
174+ ls -alR
175+
176+ cd ..
177+ ls -lstrh
178+ # 先测试普通的集成测试
179+ pushd ${workir}/build_resource/polaris/test/integrate
180+ echo "[INTEGRATION TEST] begin"
181+ curl http://127.0.0.1:8090
182+ go test -count=1 -v -tags integration -timeout 60m
183+ echo "[INTEGRATION TEST] end"
184+ popd
185+ cd ${workir}/build_resource/polaris/${server_install_dir}
186+ ./tool/stop.sh
187+ cd ..
0 commit comments