Skip to content

Commit c49cfb9

Browse files
authored
添加CI(#2)
2 parents bcb97ec + 5e48b33 commit c49cfb9

File tree

16 files changed

+447
-0
lines changed

16 files changed

+447
-0
lines changed

.CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**仅限中文**
11+
12+
在提之前请先查找[已有 issues](https://github.com/ecodeclub/eorm/issues),避免重复上报。
13+
14+
并且确保自己已经:
15+
- [ ] 阅读过文档
16+
- [ ] 阅读过注释
17+
- [ ] 阅读过例子
18+
19+
### 问题简要描述
20+
21+
### 复现步骤
22+
> 如果涉及到数据库表,你必须提供模型定义和表结构定义
23+
24+
### 错误日志或者截图
25+
26+
### 你期望的结果
27+
28+
### 你排查的结果,或者你觉得可行的修复方案
29+
> 可选。我们希望你能够尽量先排查问题,帮助我们减轻维护负担。这对于你个人能力提升同样是有帮助的。
30+
31+
### 你使用的是 mq-api 哪个版本?
32+
33+
### 你设置的的 Go 环境?
34+
> 上传 `go env` 的结果
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: feature
6+
assignees: ''
7+
8+
---
9+
10+
**仅限中文**
11+
12+
### 使用场景
13+
14+
### 行业分析
15+
> 如果你知道有框架提供了类似功能,可以在这里描述,并且给出文档或者例子
16+
17+
### 可行方案
18+
> 如果你有设计思路或者解决方案,请在这里提供。你可以提供多个方案,并且给出自己的选择
19+
20+
### 其它
21+
> 任何你觉得有利于解决问题的补充说明
22+
23+
### 你使用的是 mq-api 哪个版本?
24+
25+
### 你设置的的 Go 环境?
26+
> 上传 `go env` 的结果

.github/ISSUE_TEMPLATE/question.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Question
3+
about: Want to ask some questions
4+
title: ''
5+
labels: question
6+
---
7+
8+
**仅限中文**
9+
10+
在提之前请先查找[已有 issues](https://github.com/ecodeclub/eorm/issues),避免重复上报。
11+
12+
并且确保自己已经:
13+
- [ ] 阅读过文档
14+
- [ ] 阅读过注释
15+
- [ ] 阅读过例子
16+
17+
### 你的问题
18+
19+
### 你使用的是 mq-api 哪个版本?
20+
21+
### 你设置的的 Go 环境?
22+
> 上传 `go env` 的结果

.github/pre-commit

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
# Copyright 2021 ecodeclub
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# To use, store as .git/hooks/pre-commit inside your repository and make sure
17+
# it has execute permissions.
18+
#
19+
# This script does not handle file names that contain spaces.
20+
21+
# Pre-commit configuration
22+
23+
RESULT=$(make check)
24+
printf "执行检查中...\n"
25+
26+
if [ -n "$RESULT" ]; then
27+
echo >&2 "[ERROR]: 有文件发生变更,请将变更文件添加到本次提交中"
28+
exit 1
29+
fi
30+
31+
exit 0

.github/pre-push

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
# Copyright 2021 ecodeclub
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# git test pre-push hook
16+
#
17+
# To use, store as .git/hooks/pre-push inside your repository and make sure
18+
# it has execute permissions.
19+
#
20+
# This script does not handle file names that contain spaces.
21+
22+
# Pre-push configuration
23+
remote=$1
24+
url=$2
25+
echo >&2 "Try pushing $2 to $1"
26+
27+
TEST="go test ./... -race -cover -failfast"
28+
LINTER="golangci-lint run"
29+
30+
# Run test and return if failed
31+
printf "Running go test..."
32+
$TEST
33+
RESULT=$?
34+
if [ $RESULT -ne 0 ]; then
35+
echo >&2 "$TEST"
36+
echo >&2 "Check code to pass test."
37+
exit 1
38+
fi
39+
40+
# Run linter and return if failed
41+
printf "Running go linter..."
42+
$LINTER
43+
RESULT=$?
44+
if [ $RESULT -ne 0 ]; then
45+
echo >&2 "$LINTER"
46+
echo >&2 "Check code to pass linter."
47+
exit 1
48+
fi
49+
50+
exit 0

.github/workflows/go-fmt.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Format Go code
16+
17+
on:
18+
push:
19+
branches: [ main, dev]
20+
pull_request:
21+
branches: [ main, dev]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Set up Go
29+
uses: actions/setup-go@v3
30+
with:
31+
go-version: ">=1.18.0"
32+
33+
- name: Install goimports
34+
run: go install golang.org/x/tools/cmd/goimports@latest
35+
36+
- name: Check
37+
run: |
38+
make check
39+
if [ -n "$(git status --porcelain)" ]; then
40+
echo >&2 "错误: 请在本地运行命令'make check'后再提交."
41+
exit 1
42+
fi

.github/workflows/go.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Go
16+
17+
on:
18+
push:
19+
branches: [ main, dev]
20+
pull_request:
21+
branches: [ main, dev]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Set up Go
29+
uses: actions/setup-go@v2
30+
with:
31+
go-version: 1.18
32+
33+
- name: Build
34+
run: go build -v ./...
35+
36+
- name: Test
37+
run: go test -race -coverprofile=cover.out -v ./...
38+
39+
- name: Post Coverage
40+
uses: codecov/codecov-action@v2

.github/workflows/golangci-lint.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: golangci-lint
16+
on:
17+
push:
18+
tags:
19+
- v*
20+
branches:
21+
- master
22+
- main
23+
- dev
24+
pull_request:
25+
permissions:
26+
contents: read
27+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
28+
# pull-requests: read
29+
jobs:
30+
golangci:
31+
name: lint
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/setup-go@v3
35+
with:
36+
go-version: '1.20'
37+
- uses: actions/checkout@v3
38+
- name: golangci-lint
39+
uses: golangci/golangci-lint-action@v3
40+
with:
41+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
42+
version: v1.52.2
43+
44+
# Optional: working directory, useful for monorepos
45+
# working-directory: somedir
46+
47+
# Optional: golangci-lint command line arguments.
48+
args: --timeout=10m # --issues-exit-code=0
49+
50+
# Optional: show only new issues if it's a pull request. The default value is `false`.
51+
only-new-issues: true
52+
53+
# Optional: if set to true then the all caching functionality will be complete disabled,
54+
# takes precedence over all other caching options.
55+
# skip-cache: true
56+
57+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
58+
# skip-pkg-cache: true
59+
60+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
61+
# skip-build-cache: true
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2021 ecodeclub
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Integration Test
16+
17+
on:
18+
push:
19+
branches: [ main, dev]
20+
pull_request:
21+
branches: [ main, dev]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Set up Go
29+
uses: actions/setup-go@v2
30+
with:
31+
go-version: 1.18
32+
33+
- name: Test
34+
run: sudo sh ./script/integrate_test.sh

0 commit comments

Comments
 (0)