diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml new file mode 100644 index 0000000000..2fccf9467d --- /dev/null +++ b/.github/workflows/pr-lint.yml @@ -0,0 +1,16 @@ +name: pr-lint +on: [pull_request] +jobs: + PR-format-check: + runs-on: ubuntu-latest + steps: + - name: Check PR naming convention + run: | + title="${{ github.event.pull_request.title }}" + pattern="^(feat|fix|docs|style|refactor|perf|test|chore|revert|build|ci): .*" + if [[ ! $title =~ $pattern ]]; then + echo "PR title does not match naming convention. Example: 'feat: 添加新功能'.\ + You can refer to this address for details:\ + https://github.com/TencentBlueKing/bk-bcs/blob/master/docs/specification/commit-spec.md" + exit 1 + fi \ No newline at end of file diff --git a/docs/specification/commit-spec.md b/docs/specification/commit-spec.md index 2337d0f44b..905d195eae 100644 --- a/docs/specification/commit-spec.md +++ b/docs/specification/commit-spec.md @@ -2,24 +2,28 @@ ## 代码检查建议 -BCS团队默认使用gometalinter进行代码检查,为了提高Merge效率,请提交前先使用[gometalinter](https://github.com/alecthomas/gometalinter)进行检查。 +BCS团队默认使用golangci-lint进行代码检查,为了提高Merge效率,请提交前先使用[golangci-lint](https://github.com/golangci/golangci-lint)进行检查。 ## commit相关格式 -个人分支提交commit消息格式 +个人分支提交commit消息格式,英文冒号,后跟英文空格 ``` -type:messsge issue +type: messsge issue ``` * type 范围信息 - * feature 新功能 - * fix 错误修复 + * feat 添加新功能/新特性 + * fix 错误修复,bug修复 * docs 文档更改 - * style (格式化,缺少半冒号等;没有代码更改) - * refactor 代码重构重构 + * style 代码格式化,如空格、缩进、缺少半冒号等;没有代码更改 + * refactor 代码重构,没有添加新功能或bug修复 + * perf 添加代码进行性能测试或性能优化 * test 添加缺失的测试,重构测试;没有生产代码更改 * chore 构建脚本,任务等相关代码 + * revert 回滚某次提交 + * build 构建系统或外部依赖项的更改(如webpack,npm,go.mod等) + * ci 持续集成相关的变动 * message 本次提交的描述 * issue 本次提交关联的issue id