复制项目
This commit is contained in:
165
.github/workflows/chat-build-test.yml
vendored
Normal file
165
.github/workflows/chat-build-test.yml
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
name: OpenIM Chat Build Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release-*
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "README.md"
|
||||
- "README_zh-CN.md"
|
||||
- "**.md"
|
||||
- "docs/**"
|
||||
- "CONTRIBUTING.md"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- release-*
|
||||
paths-ignore:
|
||||
- "README.md"
|
||||
- "README_zh-CN.md"
|
||||
- "CONTRIBUTING/**"
|
||||
- "**.md"
|
||||
- "docs/**"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
name: Execute OpenIM Script On Linux
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
# environment:
|
||||
# name: openim
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.22"
|
||||
|
||||
- name: init
|
||||
run: sudo bash bootstrap.sh
|
||||
timeout-minutes: 20
|
||||
|
||||
- name: Checkout chat repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "openimsdk/chat-deploy"
|
||||
path: "server-repo"
|
||||
|
||||
- name: Set up Docker for Linux
|
||||
run: |
|
||||
cd ${{ github.workspace }}/server-repo
|
||||
sudo docker compose up -d
|
||||
sudo sleep 30 # Increased sleep time for better stability
|
||||
timeout-minutes: 30 # Increased timeout for Docker setup
|
||||
|
||||
- name: Modify Server Configuration
|
||||
run: |
|
||||
yq e '.secret = 123456' -i ${{ github.workspace }}/server-repo/config/share.yml
|
||||
|
||||
- name: Build and Start IM Serevr Services
|
||||
run: |
|
||||
cd ${{ github.workspace }}/server-repo
|
||||
sudo mage
|
||||
sudo mage start
|
||||
sudo mage check
|
||||
|
||||
- name: Modify Chat Configuration
|
||||
run: |
|
||||
yq e '.openIM.secret = 123456' -i config/share.yml
|
||||
|
||||
- name: Build, Start, Check Services and Print Logs for Linux
|
||||
run: |
|
||||
sudo mage
|
||||
sudo mage start
|
||||
sudo mage check
|
||||
|
||||
- name: Restart Services and Print Logs
|
||||
run: |
|
||||
sudo mage stop
|
||||
sudo mage start
|
||||
sudo mage check
|
||||
|
||||
- name: Test Chat
|
||||
run: |
|
||||
check_error() {
|
||||
echo "Response: $1"
|
||||
errCode=$(echo $1 | jq -r '.errCode')
|
||||
if [ "$errCode" != "0" ]; then
|
||||
errMsg=$(echo $1 | jq -r '.errMsg')
|
||||
echo "Error: $errMsg"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test register
|
||||
response1=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
|
||||
"verifyCode": "666666",
|
||||
"platform": 3,
|
||||
"autoLogin": true,
|
||||
"user":{
|
||||
"nickname": "test12312",
|
||||
"areaCode":"+86",
|
||||
"phoneNumber": "12345678190",
|
||||
"password":"test123456"
|
||||
}
|
||||
}' http://127.0.0.1:10008/account/register)
|
||||
check_error "$response1"
|
||||
userID1=$(echo $response1 | jq -r '.data.userID')
|
||||
echo "userID1: $userID1"
|
||||
|
||||
response2=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
|
||||
"verifyCode": "666666",
|
||||
"platform": 3,
|
||||
"autoLogin": true,
|
||||
"user":{
|
||||
"nickname": "test22312",
|
||||
"areaCode":"+86",
|
||||
"phoneNumber": "12345678290",
|
||||
"password":"test123456"
|
||||
}
|
||||
}' http://127.0.0.1:10008/account/register)
|
||||
check_error "$response2"
|
||||
userID2=$(echo $response2 | jq -r '.data.userID')
|
||||
echo "userID2: $userID2"
|
||||
|
||||
# Test login
|
||||
login_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
|
||||
"platform": 3,
|
||||
"areaCode":"+86",
|
||||
"phoneNumber": "12345678190",
|
||||
"password":"test123456"
|
||||
}' http://localhost:10008/account/login)
|
||||
check_error "$login_response"
|
||||
|
||||
# Test get admin token
|
||||
get_admin_token_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -d '{
|
||||
"secret": "123456",
|
||||
"platformID": 2,
|
||||
"userID": "imAdmin"
|
||||
}' http://127.0.0.1:10002/auth/get_admin_token)
|
||||
check_error "$get_admin_token_response"
|
||||
adminToken=$(echo $get_admin_token_response | jq -r '.data.token')
|
||||
echo "adminToken: $adminToken"
|
||||
|
||||
# Test send message
|
||||
send_msg_response=$(curl -X POST -H "Content-Type: application/json" -H "operationID: imAdmin" -H "token: $adminToken" -d '{
|
||||
"sendID": "'$userID1'",
|
||||
"recvID": "'$userID2'",
|
||||
"senderPlatformID": 3,
|
||||
"content": {
|
||||
"content": "hello!!"
|
||||
},
|
||||
"contentType": 101,
|
||||
"sessionType": 1
|
||||
}' http://127.0.0.1:10002/msg/send_msg)
|
||||
check_error "$send_msg_response"
|
||||
Reference in New Issue
Block a user