Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Jun 1, 2023
0 parents commit c7ed9c3
Show file tree
Hide file tree
Showing 4,294 changed files with 615,895 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
95 changes: 95 additions & 0 deletions .ci/open_source_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

version: "v2.0"
name: "开源检查"
label: []
variables: {}
on:
mr:
target-branches: [ "*" ]
stages:
- name: "开源检查"
label:
- "Build"
jobs:
job_AfK:
name: "构建环境-LINUX"
runs-on:
pool-name: "docker"
container:
image: "mirrors.tencent.com/ci/tlinux3_ci:2.3.0"
needs: {}
steps:
- checkout: self
- name: "敏感信息检查-部门RTX"
uses: "SensitiveRtxChecker@3.*"
- name: "腾讯代码分析(官方-代码分析工作组)"
uses: "CodeccCheckAtomDebug@4.*"
with:
beAutoLang: false
languages:
- "JS"
- "PYTHON"
- "TYPESCRIPT"
- "CSS"
- "JSON"
- "GO"
checkerSetType: "communityOpenScan"
tools:
- "PYLINT"
- "WOODPECKER_COMMITSCAN"
- "ESLINT"
- "SCC"
- "PECKER_SECURITY"
- "SENSITIVE"
- "DUPC"
- "IP_CHECK"
- "WOODPECKER_SENSITIVE"
- "HORUSPY"
- "XCHECK"
- "CCN"
asyncTask: false
asyncTaskId: ""
scriptType: "SHELL"
script: |-
# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷
# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.sh
# 确保build.sh能够编译代码
# cd path/to/build.sh
# sh build.sh
languageRuleSetMap: {}
checkerSetEnvType: "prod"
multiPipelineMark: ""
rtxReceiverType: "1"
botWebhookUrl: ""
botRemindRange: "2"
botRemindSeverity: "7"
botRemaindTools: []
emailReceiverType: "1"
emailCCReceiverList: []
instantReportStatus: "2"
reportDate: []
reportTime: ""
reportTools: []
toolScanType: "1" # 扫描方式。快速全量扫描[1] | 全量扫描[0] | 差异扫描[6] | MR/PR扫描[2],默认为1
diffBranch: ""
byFile: false
mrCommentEnable: true
prohibitIgnore: false
newDefectJudgeFromDate: ""
transferAuthorList: []
path: []
customPath: []
scanTestSource: false
openScanPrj: false
openScanFilterEnable: false
issueSystem: "TAPD"
issueSubSystem: ""
issueResolvers: []
issueReceivers: []
issueFindByVersion: ""
maxIssue: 1000
issueAutoCommit: false
check-out:
gates:
- template: open_source_gate.yml
timeout-hours: 10
37 changes: 37 additions & 0 deletions .ci/python_code_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: v2.0

stages:
- name: "python代码格式检查"
jobs:
code_format:
name: "python代码格式检查"
runs-on:
pool-name: docker #docker-on-devcloud、docker、local、agentless
container:
image: mirrors.tencent.com/ci/tlinux3_ci:2.0.0
steps:
- checkout: self
- name: "安装环境"
run: |-
pip install flake8 black=="20.8b1"
- name: "flake8"
run: |-
FLAKE8_RESULT=$(flake8 dbm-ui/backend --config=dbm-ui/backend/.flake8)
if [[ $FLAKE8_RESULT==0 ]]; then
echo "flake8 test passed"
else
echo ${FLAKE8_RESULT}
echo "flake8 test failed, please check if you have install pre-commit"
exit 1
fi
- name: "black"
run: |-
BLACK_RESULT=$(black dbm-ui/backend 2>&1)
if [[ $BLACK_RESULT =~ "reformatted" ]]; then
echo ${BLACK_RESULT}
echo "black test failed, please check if you have install pre-commit"
exit 1
else
echo "black test passed"
fi
56 changes: 56 additions & 0 deletions .ci/python_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: v2.0

on:
mr:
target-branches: [ "*" ]
paths:
- dbm-ui/backend/*

stages:
- name: "python单元测试"
jobs:
unit_test:
name: "单元测试"
runs-on:
pool-name: docker #docker-on-devcloud、docker、local、agentless
container:
image: mirrors.tencent.com/ci/tlinux3_ci:2.0.0
steps:
- checkout: self
- uses: "calculatehash@1.*"
id: "calculate"
with:
file_path: "dbm-ui/poetry.lock"
calculate_func: "md5"
- uses: cache@2.*
id: cache
with:
cacheKey: "poetry_pip_${{ steps.calculate.outputs.hash_value }}"
cachePaths: "/tmp/ci_py_venv"
restoreKeys: "poetry_pip_"
skipSaveWhenCacheHit: false
- name: "Mysql服务"
id: "mysql"
uses: "mysqlservice@1.*"
with:
imageName: "mysql:5.7"
port: "3306"
mysqlPw: "db_for_unit_test"
initCmd: "set names utf8mb4;"
- name: "Redis服务"
id: "redis"
uses: "redisservice@1.*"
with:
imageName: "redis:5.0.9"
redisPw: "redis_for_unit_test"
- name: "执行单元测试"
run: |-
source ./dbm-ui/scripts/ci/env.sh
export DB_HOST=${{ jobs.unit_test.steps.mysql.outputs.MYSQL_IP }}
export DBA_APP_BK_BIZ_ID=0
export DB_PASSWORD="db_for_unit_test"
export REDIS_HOST=${{ jobs.unit_test.steps.redis.outputs.REDIS_IP }}
export REDIS_PORT=${{ jobs.unit_test.steps.redis.outputs.REDIS_PORT }}
export REDIS_PASSWORD="redis_for_unit_test"
export BROKER_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/1"
./dbm-ui/scripts/ci/bk_ci.sh
23 changes: 23 additions & 0 deletions .ci/templates/open_source_gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
parameters:
- name: receivers
type: array
default: [ "${{ ci.actor }}" ]

gates:
- name: open-source-gate
rule:
- "CodeccCheckAtomDebug.all_risk <= 0"
- "CodeccCheckAtomDebug.high_med_new_issue <= 0"
- "CodeccCheckAtomDebug.ccn_new_max_value <= 55"
- "CodeccCheckAtomDebug.sensitive_defect <= 0"
- "CodeccCheckAtomDebug.dupc_average <= 15"
- "CodeccCheckAtomDebug.ccn_average <= 3.5"
- "CodeccCheckAtomDebug.ccn_funcmax <= 55"
- "CodeccCheckAtomDebug.pyLint_after_defect <= 0"
- "CodeccCheckAtomDebug.woodpecker_all_defect <= 0"
- "CodeccCheckAtomDebug.horuspy_all_defect <= 0"
- "CodeccCheckAtomDebug.go_serious_defect <= 0"
- "CodeccCheckAtomDebug.go_all_defect <= 100"
notify-on-fail:
- type: wework-message
receivers: ${{ parameters.receivers }}
17 changes: 17 additions & 0 deletions .code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
source:
# 文件或目录使用绝对路径,绝对路径按代码库根目录计算,以/开头。
# 提供产品代码库中编写的测试代码存放目录或文件名格式,以便后续代码统计环节进行排除等特殊处理
# 不要使用.*/等正则表达式屏蔽掉所有代码,会导致部门代码量骤减从而影响部门代码得分,还会导致Coverity扫不到任何代码而失败
# 请勿使用Tab键,将会导致yaml解析出错
test_source:
#用于匹配文件; 匹配方式为正则表达式。
filepath_regex: [".*/test.py"]
# 提供产品代码库中工具或框架自动生成的且在代码库中的代码,没有可为空。以便后续代码统计环节进行排除等特殊处理。
auto_generate_source:
# 自动生成代码文件的正则表达式,若无统一标识格式,可以指定具体目录,样例可参考test_source举例
filepath_regex: [".*/migrations/.*"]
# 提供产品代码库中直接以源码形式存在的第三方代码目录或代码文件名的正则表达。
# 此处备注的第三方代码在后续统计代码量环节会被排除,若代码库中不存在需要排除的第三方代码,该项配置标识可为空
third_party_source:
#第三方代码文件的正则表达式,若无统一标识格式,可以指定具体目录,样例可参考test_source举例
filepath_regex:
32 changes: 32 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# public
/.github @zhangzhw8 @gaohongsong @iSecloud
/docs @zhangzhw8 @gaohongsong @iSecloud
/*.md @zhangzhw8 @gaohongsong @iSecloud
/helm-charts @zhangzhw8 @gaohongsong @iSecloud

# dbm-ui
/dbm-ui @zhangzhw8 @gaohongsong @iSecloud
/dbm-ui/frontend @Daryl0819 @hLinx

# dbm-services common
/dbm-services/common @seanlook @xfwduke @lukemakeit @xiepaup @ymakedaq
/dbm-services/common/db-config @seanlook @xfwduke
/dbm-services/common/db-resource @ymakedaq @seanlook @xfwduke
/dbm-services/common/db-dns @omg-by @xiepaup @lukemakeit
/dbm-services/common/dbha @zyqlzr @xjxia

# bigdata
/dbm-services/bigdata @zhangrq5 @zvictorino
/dbm-services/es @zhangrq5 @zvictorino
/dbm-services/hdfs @zhangrq5 @zvictorino
/dbm-services/kafka @zhangrq5 @zvictorino

# mysql
/dbm-services/mysql @seanlook @xfwduke @yksitu @ymakedaq
/dbm-services/mysql/db-partition @fanfanyangyang @xfwduke @seanlook
/dbm-services/mysql/db-priv @fanfanyangyang @xfwduke @seanlook
/dbm-services/mysql/db-remote-service @xfwduke @seanlook
/dbm-services/mysql/db-simulation @seanlook @xfwduke @ymakedaq

# redis
/dbm-services/redis @lukemakeit @xiepaup @omg-by @mikluo @yyhenryyy @cuiguobin
50 changes: 50 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 参与者公约
## 我们的承诺
为建设开放友好的环境,我们贡献者和维护者承诺:不论年龄、体型、身体健全与否、民族、性征、性别认同与表征、经验水平、教育程度、社会地位、
国籍、相貌、种族、信仰、性取向,我们项目和社区的参与者皆免于骚扰。

## 我们的准则

有助于创造积极环境的行为包括但不限于:

- 措辞友好且包容
- 尊重不同的观点和经验
- 耐心接受有益批评
- 关注对社区最有利的事情
- 与社区其他成员友善相处

参与者不应采取的行为包括但不限于:

- 发布与性有关的言论或图像、不受欢迎地献殷勤
- 捣乱/煽动/造谣行为、侮辱/贬损的评论、人身及政治攻击
- 公开或私下骚扰
- 未经明确授权便发布他人的资料,如住址、电子邮箱等
- 其他有理由认定为违反职业操守的不当行为

## 我们的义务

项目维护者有义务诠释何谓“妥当行为”,并妥善公正地纠正已发生的不当行为。

项目维护者有权利和义务去删除、编辑、拒绝违背本行为标准的评论(comments)、提交(commits)、代码、wiki 编辑、问题(issues)等贡献;
项目维护者可暂时或永久地封禁任何他们认为行为不当、威胁、冒犯、有害的参与者。

## 适用范围

本行为标准适用于本项目。当有人代表本项目或本社区时,本标准亦适用于此人所处的公共平台。

代表本项目或本社区的情形包括但不限于:使用项目的官方电子邮件、通过官方媒体账号发布消息、作为指定代表参与在线或线下活动等。

代表本项目的行为可由项目维护者进一步定义及解释。

## 贯彻落实

违反行为准则的行为可以报告给本仓库的 OWNER,向项目团队举报滥用、
骚扰及不当行为。

维护团队将审议并调查全部投诉,妥善地予以必要的回应。项目团队有义务保密举报者信息。具体执行方针或将另行发布。

未切实遵守或执行本行为标准的项目维护人员,经项目负责人或其他成员决议,可能被暂时或永久地剥夺参与本项目的资格。

## 来源

本行为标准改编自参与者公约,版本 1.4 可在此查阅:https://www.contributor-covenant.org/zh-cn/version/1/4/code-of-conduct.html
66 changes: 66 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## 开发流程

建议按下图的流程来使用 Git (可使用 gtm 工具来快速实现)

![](gitflow.png)

## 所有的开发都必须基于 Issue
必须从最新的主分支或者目标功能分支切换出新的本地个人开发分支进行

### 请安装 pre-commit 以保证代码提交前符合基本的开发规范

### 单据类型

根据单据类型,可分为以下几种。创建单据时可根据实际开发内容进行选择。

单据类型虽然并不影响开发流程,但后续会作为研效的评判依据,因此请准确填写。如果实在拿不准,可以遵循一个简单的原则:问题修复用 `fix`,其他用 `feat`

| 类型 | 中文 | Emoji | 说明 |
| -------- | ---------- | ----- | ------------------------------------------------------------ |
| feat | 特性 || A new feature. Correlates with MINOR in SemVer |
| fix | 修复 | 🐛 | A bug fix. Correlates with PATCH in SemVer |
| docs | 文档 | 📚 | Documentation only changes |
| style | (代码)样式 | 💎 | Changes that do not affect the meaning of the code (white-space, formatting, etc) |
| refactor | 重构 | 📦 | A code change that neither fixes a bug nor adds a feature |
| perf | 性能优化 | 🚀 | A code change that improves performance |
| test | 测试 | 🚨 | Adding missing or correcting existing tests |
| chore | 琐事 | ♻️ | Changes to the build process or auxiliary tools and libraries such as documentation generation |



### 开发前准备
- 使用命令 gtm create 来创建或关联 Issue,此命令完成后会在 upstream 仓库中创建对应的 Branch 和 Pull Request
```
gtm c
```
- 按照提示执行以下命令开始开发
- 同步上游仓库分支
```
git fetch upstream
```
- 切换到功能开发分支,以 `feat/ipv6` 为例
```
git checkout feat/ipv6
```
- 推送分支到个人仓库
```
git push --set-upstream origin feat/ipv6
```
### 现在可以开始 coding 了
- 提交代码时,commit message 注意按规范进行书写
### 完成开发后
- 假如你本次开发有多个 commits,建议使用 `rebase` 来整理你的commits,原则上一个 Pull Request 只对应一条 commit记录
```
# git log --oneline 查询提交记录并找到需要 rebase 的目标 commit-id
git rebase -i [commit-id]
```
- 将本地分支推送到 origin 仓库
```
git push
```
- 使用 `gtm pr` 创建 origin -> upstream 的 Pull Request
```
gtm pr
```
Loading

0 comments on commit c7ed9c3

Please sign in to comment.