Skip to content

Commit

Permalink
Merge branch 'feature/chenqi99/openai' into 'master'
Browse files Browse the repository at this point in the history
Feature/chenqi99/openai

See merge request leyanapi/leyanapi-backend!404
  • Loading branch information
wangzhen committed Aug 15, 2024
2 parents 78b2196 + 7f6234e commit 79b2d0f
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 140 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/nancal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: nancal site deploy

on:
workflow_dispatch
# pull_request:
# branches: [ "main" ]
# push:
# branches: [ "main" ]

jobs:
build-and-deploy:
runs-on: nancal
defaults:
run:
working-directory: /home/nancal/rd/project/deeptest
steps:
- name: checkout backend codes
run: git pull

- name: checkout frontend codes
run: git pull
working-directory: /home/nancal/rd/project/deeptest-ui

- name: make server
run: ENV=dp make compile_server_linux

- name: make agent
run: ENV=dp make compile_agent_linux

- name: make ui
run: make compile_ui_nancal

- name: copy files
run: |
mkdir -p /home/nancal/rd/server
cp -f bin/linux/deeptest-server /home/nancal/rd/server/
cp -f client/bin/linux/deeptest-agent /home/nancal/rd/server/
rm -rf /home/nancal/rd/server/deeptest-ui
cp -fr client/ui /home/nancal/rd/server/deeptest-ui
- name: start service
run: |
ps -ef | grep 'deeptest-' | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9
cd /home/nancal/rd/server
RUNNER_TRACKING_ID="" && nohup ./deeptest-server > server.log 2>&1 &
RUNNER_TRACKING_ID="" && nohup ./deeptest-agent > agent.log 2>&1 &
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ client/icon/ly

client/src/app/package-ly.json

client/node_modules
client-ly/node_modules
client-ly/out
client-ly/.webpack
Expand Down
121 changes: 69 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,26 @@ GIT_HASH=`git show -s --format=%H`
BUILD_CMD_UNIX=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'"
BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'"

default: compile_ui_web win64 win32 linux mac
web: compile_ui_web win64-web win32-web linux-web mac-web

# 非客户端版本打包
win64: prepare compile_agent_win64 compile_server_win64 zip_web_win64
win32: prepare compile_agent_win32 compile_server_win32 zip_web_win32
linux: prepare compile_agent_linux compile_server_linux zip_web_linux
mac: prepare compile_agent_mac compile_server_mac zip_web_mac
# 非客户端版本打包,需先运行 make compile_ui_web
win64-web: prepare compile_agent_win64 compile_server_win64 zip_win64_web
win32-web: prepare compile_agent_win32 compile_server_win32 zip_win32_web
linux-web: prepare compile_agent_linux compile_server_linux zip_linux_web
mac-web: prepare compile_agent_mac compile_server_mac zip_mac_web

# 客户端版本打包
dp-win64: prepare build_gui_win64 compile_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade
dp-win32: prepare build_gui_win32 compile_launcher_win32 compile_server_win32 copy_files_win32 zip_win32 zip_win32_upgrade
dp-linux: prepare build_gui_linux compile_server_linux copy_files_linux zip_linux zip_linux_upgrade
dp-mac: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade
# 客户端版本打包,需先运行 make compile_ui_<target>
dp-win64-client: prepare build_gui_win64 compile_launcher_win64 compile_server_win64 copy_files_win64 zip_win64_client zip_win64_upgrade
dp-win32-client: prepare build_gui_win32 compile_launcher_win32 compile_server_win32 copy_files_win32 zip_win32_client zip_win32_upgrade
dp-linux-client: prepare build_gui_linux compile_server_linux copy_files_linux zip_linux_client zip_linux_upgrade
dp-mac-client: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac_client zip_mac_upgrade
dp-mac-test-client: compile_ui_client_test build_gui_mac

# 乐研 打包
ly-win64: prepare compile_ly_ui_client build_gui_win64 compile_ly_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade
ly-win32: prepare compile_ly_ui_client build_gui_win32 compile_ly_launcher_win32 compile_server_win32 copy_files_win32 zip_win32 zip_win32_upgrade
ly-linux: prepare compile_ly_ui_client build_gui_linux compile_server_linux copy_files_linux zip_linux zip_linux_upgrade
ly-mac: prepare compile_ly_ui_client build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade
ly-win64-client: prepare compile_ly_ui_client build_gui_win64 compile_ly_launcher_win64 compile_server_win64 copy_files_win64 zip_win64_client zip_win64_upgrade
ly-win32-client: prepare compile_ly_ui_client build_gui_win32 compile_ly_launcher_win32 compile_server_win32 copy_files_win32 zip_win32_client zip_win32_upgrade
ly-linux-client: prepare compile_ly_ui_client build_gui_linux compile_server_linux copy_files_linux zip_linux_client zip_linux_upgrade
ly-mac-client: prepare compile_ly_ui_client build_gui_mac compile_server_mac copy_files_mac zip_mac_client zip_mac_upgrade

prepare: init_client_project update_version

Expand All @@ -83,15 +84,20 @@ gen_version_file:

compile_ui:
@cd ui && yarn build --dest ../client/ui && cd ..
compile_ui_web:
@cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/client/ui && cd ../leyanapi-backend
compile_ui_demo:
compile_ui_demo: # DeepTest测试
@cd ../deeptest-ui && yarn build:demo --dest ../deeptest/client/ui && cd ../deeptest
compile_ui_nancal: # 内网测试
@cd ../deeptest-ui && yarn build:nancal --dest ../deeptest/client/ui && cd ../deeptest
compile_ui_client:
@cd ui && yarn build --dest ../client/ui && cd ..
@rm -rf client/ui && cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd ..
compile_ui_client_test:
@rm -rf client/ui && cd ../leyanapi-frontend && yarn build:clientTest --dest ../leyanapi-backend/client/ui && cd ..
compile_ly_ui_client:
@cd ../leyanapi-frontend && yarn build:client && cd ../leyanapi-backend

compile_ui_web:
@cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/bin/deeptest-ui && cd ../leyanapi-backend

# launcher
compile_launcher_win64:
@echo 'start compile win64 launcher'
Expand Down Expand Up @@ -241,109 +247,109 @@ copy_files_mac:
@echo 'start copy files darwin'

# zip web files
zip_web_win64:
zip_win64_web:
@echo 'start zip win64'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip

@cp -rf config ${BIN_DIR}win64/
@cp -rf ${CLIENT_BIN_DIR}win32/deeptest-agent.exe ${BIN_DIR}win64/
@rm -rf ${BIN_DIR}win64/deeptest-ui && mkdir ${BIN_DIR}win64/deeptest-ui
@cp -rf client/ui/* ${BIN_DIR}win64/deeptest-ui
@rm -rf ${BIN_DIR}win64/deeptest-ui
@cp -rf bin/deeptest-ui ${BIN_DIR}win64

@cd ${BIN_DIR}win64/ && \
zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip ./* && \
md5sum ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip.md5 && \
cd ../..; \

zip_web_win32:
zip_win32_web:
@echo 'start zip win32'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip

@cp -rf config ${BIN_DIR}win32/
@cp -rf ${CLIENT_BIN_DIR}win32/deeptest-agent.exe ${BIN_DIR}win32/
@rm -rf ${BIN_DIR}win32/deeptest-ui && mkdir ${BIN_DIR}win32/deeptest-ui
@cp -rf client/ui/* ${BIN_DIR}win32/deeptest-ui
@rm -rf ${BIN_DIR}win32/deeptest-ui
@cp -rf bin/deeptest-ui ${BIN_DIR}win32

@cd ${BIN_DIR}win32/ && \
zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip ./* && \
md5sum ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip.md5 && \
cd ../..; \

zip_web_linux:
zip_linux_web:
@echo 'start zip linux'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip

@cp -rf config ${BIN_DIR}linux/
@cp -rf ${CLIENT_BIN_DIR}linux/deeptest-agent ${BIN_DIR}linux/
@rm -rf ${BIN_DIR}linux/deeptest-ui && mkdir ${BIN_DIR}linux/deeptest-ui
@cp -rf client/ui/* ${BIN_DIR}linux/deeptest-ui
@rm -rf ${BIN_DIR}linux/deeptest-ui
@cp -rf bin/deeptest-ui ${BIN_DIR}linux

@cd ${BIN_DIR}linux/ && \
zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip ./* && \
md5sum ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip.md5 && \
cd ../..; \

zip_web_mac:
zip_mac_web:
@echo 'start zip darwin'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip

@cp -rf config ${BIN_DIR}darwin/
@cp -rf ${CLIENT_BIN_DIR}darwin/deeptest-agent ${BIN_DIR}darwin/
@rm -rf ${BIN_DIR}darwin/deeptest-ui && mkdir ${BIN_DIR}darwin/deeptest-ui
@cp -rf client/ui/* ${BIN_DIR}darwin/deeptest-ui
@rm -rf ${BIN_DIR}darwin/deeptest-ui
@cp -rf bin/deeptest-ui ${BIN_DIR}darwin

@cd ${BIN_DIR}darwin/ && \
zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip ./* && \
zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip ./* -x Leyan* && \
md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip.md5 && \
cd ../..; \

# zip client files
zip_win64:
zip_win64_client:
@echo 'start zip win64'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}.zip
@mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip
@cd ${CLIENT_OUT_DIR_EXECUTABLE}win64 && \
zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}win64/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}.zip.md5 && \
zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip ./* -x Leyan* && \
md5sum ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip.md5 && \
cd ../../..; \

zip_win32:
zip_win32_client:
@echo 'start zip win32'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}.zip
@mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip
@cd ${CLIENT_OUT_DIR_EXECUTABLE}win32 && \
zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}win32/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}.zip.md5 && \
zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip ./* -x Leyan* && \
md5sum ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip.md5 && \
cd ../../..; \

zip_linux:
zip_linux_client:
@echo 'start zip linux'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}.zip
@mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip
@cd ${CLIENT_OUT_DIR_EXECUTABLE}linux && \
zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}linux/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}.zip.md5 && \
zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip ./* -x Leyan* && \
md5sum ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip.md5 && \
cd ../../..; \

zip_mac:
zip_mac_client:
@echo 'start zip darwin'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}.zip
@mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip
@cd ${CLIENT_OUT_DIR_EXECUTABLE}darwin && \
zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}.zip.md5 && \
zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip ./* -x Leyan* && \
md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip.md5 && \
cd ../../..; \

# zip upgrade package
Expand Down Expand Up @@ -385,6 +391,17 @@ upload_to:
@qshell qupload2 --src-dir=${QINIU_DIR} --bucket=download --thread-count=10 --log-file=qshell.log \
--skip-path-prefixes=ztf,zd,zv,zmanager,driver --rescan-local --overwrite --check-hash

zip_server:
@cp bin/win64/${PROJECT}-server.exe ${QINIU_DIST_DIR}win64/

@cp bin/win32/${PROJECT}-server.exe ${QINIU_DIST_DIR}win32/
@cp bin/linux/${PROJECT}-server ${QINIU_DIST_DIR}linux/

# zip -r /Users/aaron/work/qiniu/deeptest/3.0/darwin/deeptest-server.zip config bin/deeptest-ui bin/darwin/deeptest-server
@zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-server.zip \
bin/darwin/${PROJECT}-server config client/ui && \
md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-upgrade.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-upgrade.zip.md5 && \

DEMO_BIN=/home/lighthouse/rd/server/deeptest

Expand Down
2 changes: 1 addition & 1 deletion backend-config
Submodule backend-config updated from e39b7c to 1ea412
4 changes: 3 additions & 1 deletion client/forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module.exports = {
{
name: '@electron-forge/maker-squirrel',
config: {
name: pkg?.name || 'deeptest'
name: pkg?.name || 'deeptest',
authors: 'AaronChen',
description: 'DeepTest Electron Client'
}
},
{
Expand Down
25 changes: 12 additions & 13 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,26 @@
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "Aaron Chen",
"email": "[email protected]"
},
"author": "Aaron Chen",
"license": "GPL3",
"config": {
"forge": "./forge.config.js"
},
"devDependencies": {
"@electron-forge/cli": "^6.4.1",
"@electron-forge/maker-deb": "^6.4.1",
"@electron-forge/maker-rpm": "^6.4.1",
"@electron-forge/maker-squirrel": "^6.4.1",
"@electron-forge/maker-zip": "^6.4.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.4.1",
"@electron-forge/plugin-webpack": "^6.4.1",
"electron": "30.0.9",
"electron-packager": "17.1.2",

"@electron-forge/cli": "7.4.0",
"@electron-forge/maker-deb": "7.4.0",
"@electron-forge/maker-rpm": "7.4.0",
"@electron-forge/maker-squirrel": "7.4.0",
"@electron-forge/maker-zip": "7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "7.4.0",
"@electron-forge/plugin-webpack": "7.4.0",

"@timfish/forge-externals-plugin": "^0.2.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"css-loader": "^6.5.1",
"electron": "26.1.0",
"electron-packager": "15.4.0",
"node-loader": "^2.0.0",
"style-loader": "^3.3.1"
},
Expand Down
15 changes: 12 additions & 3 deletions client/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ export class DeepTestApp {
app.commandLine.appendSwitch('disable-site-isolation-trials')
app.commandLine.appendSwitch('disable-features','BlockInsecurePrivateNetworkRequests')
this._windows = new Map();

// 需要启动本地 Agent 服务,之后再会启动 UI 服务
(async () => {
port = await getUsefulPort(portAgent,56999);

logInfo(`>> starting deeptest agent on port ${port}`);

startAgent(port).then((agentUrl)=> {
if (agentUrl) logInfo(`>> deeptest server started successfully on : ${agentUrl}`);
if (agentUrl) logInfo(`>> deeptest agent started successfully at ${agentUrl}`);
this.bindElectronEvents();
}).catch((err) => {
logErr('>> agent started failed, err: ' + err);
logErr('>> deeptest agent started failed on port ${port}, err: ' + err);
process.exit(1);
})
})()
Expand Down Expand Up @@ -95,13 +99,16 @@ export class DeepTestApp {
mainWin.show()

this._windows.set('main', mainWin);

// 最终都是返回 http地址,远端 或者 本地http服务
const uiPort = process.env.UI_SERVER_PORT || await getUsefulPort(portClient,55999);
const url = await startUIService(uiPort);
await mainWin.loadURL(url);

// 通知渲染进程,agent服务端口
mainWin.webContents.send(electronMsgUsePort, {uiPort,agentPort:port});
const data = {uiPort, agentPort: port}
logInfo(`send event to webpage, uiPort=${data.uiPort}, agentPort=${data.agentPort}`)
mainWin.webContents.send(electronMsgUsePort, data);

// 读取服务配置
const confPath = path.join(os.homedir(), App, 'conf.yaml');
Expand Down Expand Up @@ -196,6 +203,7 @@ export class DeepTestApp {
// this.buildAppMenu();
this.openOrCreateWindow()
this.setAboutPanel();

// 使用默认的快捷键,和常用的快捷键有冲突
// globalShortcut.register('CommandOrControl+D', () => {
// const mainWin = this._windows.get('main');
Expand Down Expand Up @@ -234,6 +242,7 @@ export class DeepTestApp {
// createWindow();
// }
});

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
Expand Down
Loading

0 comments on commit 79b2d0f

Please sign in to comment.