-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage. chore: add codacy coverage.
- Loading branch information
Showing
10 changed files
with
100 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
coverage: | ||
enabled: yes | ||
input: | ||
- ./coverage.out # 用于指定覆盖率报告文件的路径 | ||
parsers: | ||
- go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Codacy and Codecov Integration | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-report: | ||
runs-on: ubuntu-latest | ||
name: Build, Test, and Report Coverage | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.20" | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: ./test.sh 1 | ||
|
||
- name: Test Coverage | ||
run: ./test.sh 4 | ||
|
||
- name: Codacy Coverage Reporter | ||
uses: codacy/codacy-coverage-reporter-action@v1 | ||
with: | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
coverage-reports: coverage.out # Replace with the actual path to your coverage report file | ||
|
||
- name: Upload coverage to Codecov | ||
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
*.dylib | ||
./cmd/vasedb | ||
vasedb | ||
_temp | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
// trimDaemon 从 os.Args 中移除 "-daemon" 参数 | ||
func TrimDaemon(args []string) []string { | ||
var newArgs []string | ||
|
||
// 遍历 args 切片 | ||
for i := 1; i < len(args); i++ { | ||
// 巨坑无比,无法知道用户输入的参数是 -- 还是 - 开头 | ||
if args[i] == "-daemon" || args[i] == "--daemon" { | ||
// 当发现 "-daemon" 参数时,跳过当前参数 | ||
continue | ||
} | ||
newArgs = append(newArgs, args[i]) | ||
} | ||
|
||
return newArgs | ||
} | ||
|
||
func SplitArgs(args []string) []string { | ||
var newArgs []string | ||
// i = 1 避免处理 ./vasedb 本身 | ||
for i := 1; i < len(args); i++ { | ||
// 巨坑无比,如果没有这段代码 newArgs 元素中会出现 --port=2468 元素 | ||
// 而不是分割好的 [--port , 2468] 这样的元素,否则命令行解析错误 | ||
if strings.Contains(args[i], "=") && strings.Count(args[i], "=") == 1 { | ||
newArgs = append(newArgs, strings.Split(args[i], "=")...) | ||
} else { | ||
// 如果是 --port==8080 ,过滤掉 == 不合法过滤掉 | ||
if strings.Count(args[i], "=") > 1 { | ||
continue | ||
} | ||
newArgs = append(newArgs, strings.Split(args[i], "=")...) | ||
} | ||
} | ||
|
||
return newArgs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters