Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DB_PASSWORD='123456'
DB_DATABASE='yice-performance'

# devops 的默认用户名和密码
DEVOPS_USERNAME="admin@dtstack.com"
DEVOPS_USERNAME="admin"
DEVOPS_PASSWORD="123456"
# devops 接口请求时默认的 cookie
DEVOPS_COOKIE=""
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 14

- name: Setup pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 6.35.1

Expand All @@ -38,5 +38,8 @@ jobs:
- name: Run test
run: pnpm test

- name: Run check-types
run: pnpm check-types

- name: Run build
run: pnpm build
13 changes: 12 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
before_script:
- echo $CI_COMMIT_REF_NAME
- whoami
- npm config set registry https://registry.npmmirror.com/
- pnpm install --reporter=silent

stages:
- prettier
- eslint
- stylelint
- check-types
- test
- build

Expand Down Expand Up @@ -36,10 +38,19 @@ stylelint:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~ /master/

# 创建 MR 时执行;master 分支有 push 时执行
check-types:
stage: check-types
needs: [prettier, eslint, stylelint]
script:
- pnpm check-types;
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~ /master/

# 创建 MR 时执行;master 分支有 push 时执行
test:
stage: test
needs: [prettier, eslint, stylelint]
needs: [check-types]
script:
- pnpm test;
rules:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.md
dist
*.less
.turbo
5 changes: 0 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.insertFinalNewline": true,
"[typescriptreact]": {
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.2.2](///compare/v2.2.1...v2.2.2) (2024-11-20)


### Bug Fixes

* use new fetchData's params when autoRefresh 69baf39

### [2.2.1](///compare/v2.2.0...v2.2.1) (2024-11-19)


### Bug Fixes

* use real time when send emails 7c69162

## [2.2.0](///compare/v2.1.2...v2.2.0) (2024-09-10)


### Features

* add pm2-logrotate for split logs by day f40eedd
* some optimize 6d0668e
* support 63x 70x f7a6dfa

### [2.1.2](///compare/v2.1.1...v2.1.2) (2024-07-16)


Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ cd yice-performance
> 易测检测系统和我司内部的 devops 系统深度绑定,用于检测我司需要登录的一些页面,但不影响评分功能的实现参考。


## 常见问题

### 1. yice-server 容器无法启动

  可能是 `docker` 版本较低,建议升级到 docker v24 及以上,升级前应当备份。

### 2. gcc 版本过低

  主机部署时建议使用 Ubuntu。
  主机模式部署时 CentOS7 上启动服务时报错:Error: /lib64/libstdc++.so.6: version 'CXXABI_1.3.9' not found,这是因为 CentOS7 的 gcc 版本过低,需要升级到 gcc-4.8.5 以上,执行下方命令可以看到没有 CXXABI_1.3.9。

``` shell
strings /lib64/libstdc++.so.6 | grep CXXABI
```

### 3. MacOS M 系列 arm 芯片本地安装 canvas 时失败

   [email protected] [email protected] 代理开增强模式,可以正常安装依赖并启动。出现报错时,可以考虑使用这个依赖版本组合。


## 趋势

[![Stargazers over time](https://starchart.cc/dtstack/yice-performance.svg)](https://starchart.cc/dtstack/yice-performance)
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"cron-parser": "^4.8.1",
"dingtalk-robot-sender": "^1.2.0",
"dotenv": "^16.3.1",
"jsdom": "^22.1.0",
"jsdom": "21.1.2",
"lighthouse": "9.6.8",
"mysql": "^2.18.1",
"mysql2": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class DevopsController {
@HttpCode(HttpStatus.OK)
@Get('getDevopsUrl')
async getDevopsUrl(@Query() query: getStagesReqDto) {
return await this.devopsService.getDevopsUrl(query?.shiliId);
return await this.devopsService.getDevopsUrl(+query?.shiliId);
}

@ApiOperation({ summary: '获取 devops 项目列表' })
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/devops/dto/devops.req.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class getShiLisReqDto {

export class getStagesReqDto {
@ApiPropertyOptional({ required: false, description: 'devops实例id' })
shiliId: number;
shiliId: string;
}

export class getHistoriesReqDto {
Expand Down
36 changes: 32 additions & 4 deletions apps/server/src/modules/devops/services/devops.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,38 @@ export class DevopsService {
// 5、获取实例下的详情 url, 相当于同时做了 2, 3, 4
async getDevopsUrl(shiliId: number) {
try {
const stages = await this.getStages(shiliId);
const histories = await this.getHistories({ shiliId, stageId: stages?.[0]?.id });
const history = await this.getHistory(histories?.[0]?.id);
return history;
// 主机环境
if (shiliId > 99_999) {
// 主机环境,写死地址
// hostList 的 value 需要和 hostUrlList 的 value 同步修改
const hostUrlList = [
{
label: '7.0.x',
value: 100_000,
url: 'http://70x.dtstack.cn',
loginUrl: 'http://70x.dtstack.cn/uic/#/',
},
{
label: '6.3.x',
value: 100_001,
url: 'http://63x.dtstack.cn',
loginUrl: 'http://63x.dtstack.cn/uic/#/',
},
];
const portalfront = hostUrlList.find((item) => item.value === shiliId)?.url;
return {
portalfront,
loginUrl: `${portalfront}/uic/#/`,
username: process.env.DEVOPS_USERNAME,
password: process.env.DEVOPS_PASSWORD,
};
} else {
// devops 环境
const stages = await this.getStages(shiliId);
const histories = await this.getHistories({ shiliId, stageId: stages?.[0]?.id });
const history = await this.getHistory(histories?.[0]?.id);
return history;
}
} catch (error) {
console.log(`请求 devops 接口失败, DEVOPS_COOKIE: ${process.env.DEVOPS_COOKIE}`);
throw new HttpException('请求 devops 接口失败', HttpStatus.OK);
Expand Down
23 changes: 10 additions & 13 deletions apps/server/src/modules/email/controllers/email.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ApiOperation } from '@nestjs/swagger';

import { ChartService } from '@/modules/chart/services/chart.service';
import { ProjectService } from '@/modules/project/services/project.service';
import { lastMonthRange, lastWeekRange } from '@/utils';
import { getLastMonthRange, getLastWeekRange } from '@/utils';
import { EmailService } from '../services/email.service';

@Controller('email')
Expand Down Expand Up @@ -34,17 +34,17 @@ export class EmailController {
const { projectId, name, emails } = project;
if (emails?.split(',').length) {
try {
console.log(
`\nprojectId: ${projectId}, ${name}, 开始发送【单个子产品】的数据周报到指定邮箱`
);
await this.sendProject({ projectId, emails });
} catch (error) {}
console.log(
`\nprojectId: ${projectId}, ${name}, 发送【单个子产品】的数据周报到指定邮箱`
);
}
});
}
async handleSendAll() {
if (process.env.DEFAULT_EMAIL) {
console.log('\n发送【所有子产品】的数据周报到指定邮箱');
console.log('\n开始发送【所有子产品】的数据周报到指定邮箱');
await this.sendAll({ emails: process.env.DEFAULT_EMAIL });
}
}
Expand All @@ -68,8 +68,8 @@ export class EmailController {
}

async generatePromise(project) {
const [startTime, endTime] = lastWeekRange;
const [startMonthTime, endMonthTime] = lastMonthRange;
const [startTime, endTime] = getLastWeekRange();
const [startMonthTime, endMonthTime] = getLastMonthRange();
const projectChartData = await this.chartService.projectChart({
projectId: project.projectId,
startTime,
Expand Down Expand Up @@ -102,8 +102,8 @@ export class EmailController {
throw new Error('DEFAULT_EMAIL 未配置邮箱');
}

const [startTime, endTime] = lastWeekRange;
const [startMonthTime, endMonthTime] = lastMonthRange;
const [startTime, endTime] = getLastWeekRange();
const [startMonthTime, endMonthTime] = getLastMonthRange();
let projectList = await this.projectService.findAll();
projectList = projectList.filter((project) => project.name !== '汇总');

Expand Down Expand Up @@ -143,10 +143,7 @@ export class EmailController {
return result;
}
} catch (error) {
throw new HttpException(
`尝试发送【所有子产品】的数据周报失败, ${error}`,
HttpStatus.OK
);
throw new HttpException(`发送【所有子产品】的数据周报失败, ${error}`, HttpStatus.OK);
}
}
}
16 changes: 8 additions & 8 deletions apps/server/src/modules/email/services/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { MailerService } from '@nestjs-modules/mailer';
import { IFileSizeChartData, IProjectChartData } from 'typing';

import { lastWeekRange } from '@/utils';
import { getLastWeekRange } from '@/utils';
import { renderChart } from '@/utils/echarts';

@Injectable()
Expand All @@ -14,7 +14,7 @@ export class EmailService {
projectChartData: IProjectChartData,
fileSizeChartData: IFileSizeChartData
) {
const [_, __, startTime, endTime] = lastWeekRange;
const [_, __, startTime, endTime] = getLastWeekRange();
const { projectId, name, emails } = project;

if (emails?.split(',')?.length) {
Expand All @@ -32,32 +32,32 @@ export class EmailService {
return result;
} catch (error) {
console.log(
`\nprojectId: ${projectId}, ${name}, 尝试发送【单个子产品】的数据周报失败`,
`\nprojectId: ${projectId}, ${name}, 发送【单个子产品】的数据周报失败`,
error
);
throw new HttpException('尝试发送单个子产品的数据周报失败', HttpStatus.OK);
throw new HttpException('发送单个子产品的数据周报失败', HttpStatus.OK);
}
}
}

// 定时发送所有子产品的数据周报到指定邮箱
async sendMailAllProject(emails, chartDataList = []) {
const [_, __, startTime, endTime] = lastWeekRange;
const [_, __, startTime, endTime] = getLastWeekRange();

if (emails?.split(',')?.length) {
const html = renderChart(chartDataList);
try {
const result = await this.mailerService.sendMail({
to: emails?.split(','),
subject: `【数栈子产品】易测数据周报(${startTime}~${endTime})`, // 标题
subject: `【所有子产品】易测数据周报(${startTime}~${endTime})`, // 标题
html,
});

console.log('\n发送【所有子产品】的数据周报成功', result);
return result;
} catch (error) {
console.log('\n尝试发送【所有子产品】的数据周报失败', error);
throw new HttpException('尝试发送【所有子产品】的数据周报失败', HttpStatus.OK);
console.log('\n发送【所有子产品】的数据周报失败', error);
throw new HttpException('发送【所有子产品】的数据周报失败', HttpStatus.OK);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/modules/task/dto/task.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class TaskDto {
readonly createAt?: Date;

@IsOptional()
// eslint-disable-next-line camelcase
@IsUrl({ protocols: ['http', 'https'], require_protocol: true }, { message: '检测地址无效' })
@MaxLength(2048, { message: '检测地址最大长度为2048' })
@ApiPropertyOptional({ description: '检测地址' })
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/task/services/task.run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class TaskRunService {
.printSql()
.execute();

console.log(`taskId: ${taskId}, 数据整理完成,已落库`);
console.log(`taskId: ${taskId}, 数据整理完成,已落库。本次检测完成`);
} catch (error) {
status = TASK_STATUS.FAIL;
failReason = error;
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/modules/version/dto/version.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class VersionDto {
@MaxLength(64, { message: '版本名称最大长度为64' })
readonly name: string;

// eslint-disable-next-line camelcase
@IsUrl({ protocols: ['http', 'https'], require_protocol: true }, { message: '检测地址无效' })
@IsNotEmpty({ message: '检测地址不能为空' })
@ApiPropertyOptional({ description: '检测地址' })
Expand Down
19 changes: 0 additions & 19 deletions apps/server/src/mysql/some.sql

This file was deleted.

Loading
Loading