-
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
3 changed files
with
98 additions
and
1 deletion.
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,63 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Lint Go Code | ||
run: | | ||
go install golang.org/x/lint/golint@latest | ||
export PATH="$PATH:$HOME/go/bin" | ||
make lint | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Run Unit tests. | ||
run: make test-coverage | ||
|
||
- name: Upload Coverage report to CodeCov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
file: ./coverage.txt | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: [lint, test] | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Build | ||
run: make build |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
PROJECT_NAME := "github.com/LinCrayon/gin-gorm-oj" | ||
PKG := "$(PROJECT_NAME)" | ||
PKG_LIST := $(shell go list ${PKG}/...) | ||
GO_FILES := $(shell find . -name '*.go' | grep -v _test.go) | ||
|
||
.PHONY: all dep lint vet test test-coverage build clean | ||
|
||
all: build | ||
|
||
dep: ## Get the dependencies | ||
@go mod download | ||
|
||
lint: ## Lint Golang files | ||
@go install golang.org/x/lint/golint@latest | ||
@golint -set_exit_status ${PKG_LIST} | ||
|
||
vet: ## Run go vet | ||
@go vet ${PKG_LIST} | ||
|
||
test: ## Run unittests | ||
@go test -short ${PKG_LIST} | ||
|
||
test-coverage: ## Run tests with coverage | ||
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST} | ||
@cat cover.out >> coverage.txt | ||
|
||
build: dep ## Build the binary file | ||
@go get $(PROJECT_NAME) | ||
@go build -i -o build/main $(PKG) | ||
|
||
clean: ## Remove previous build | ||
@rm -f ./build | ||
|
||
help: ## Display this help screen | ||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |