-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 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,29 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "v*.*.*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Test | ||
run: make cover | ||
|
||
- name: Coverage report | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
file: ./cover.out |
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,47 @@ | ||
PACKAGES=`go list ./... | grep -E -v 'example|proto'` | ||
FORMAT_FILES=`find . -type f -name '*.go' | grep -E -v '_generated.go|.pb.go'` | ||
XGO_OK=$(shell type xgo > /dev/null 2>&1 && echo $$?) | ||
|
||
xgo: | ||
@if [ "${XGO_OK}" != "0" ]; then \ | ||
echo "installing xgo for unit test"; \ | ||
go install github.com/xhd2015/xgo/cmd/xgo@latest; \ | ||
fi | ||
|
||
tidy: | ||
go mod tidy | ||
|
||
cover: xgo tidy | ||
xgo test -failfast ${PACKAGES} -coverprofile=cover.out -covermode=count | ||
|
||
|
||
test: tidy | ||
xgo test -race -failfast ${PACKAGES} | ||
|
||
report: | ||
@echo ">>>static checking" | ||
@go vet ./... | ||
@echo "done\n" | ||
@echo ">>>detecting ineffectual assignments" | ||
@ineffassign ./... | ||
@echo "done\n" | ||
@echo ">>>detecting icyclomatic complexities over 10 and average" | ||
@gocyclo -over 10 -avg -ignore '_test|vendor' . || true | ||
@echo "done\n" | ||
|
||
MOD=$(shell cat go.mod | grep ^module -m 1 | awk '{ print $$2; }' || '') | ||
FILE_LIST=$(shell find . -type f -name '*.go' | grep -E -v '_generated.go|.pb.go') | ||
|
||
.PHONY: fmt | ||
fmt: | ||
@echo ${MOD} | ||
@for item in ${FILE_LIST} ; \ | ||
do \ | ||
if [ -z ${MOD} ]; then \ | ||
goimports -d -w $$item ; \ | ||
else \ | ||
goimports -d -w -local "${MOD}" $$item ; \ | ||
fi \ | ||
done | ||
|
||
|