-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 087f099
Showing
7 changed files
with
130 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,18 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
vendor/ | ||
|
||
**/.DS_Store | ||
.vscode |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Georgios Kampitakis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,22 @@ | ||
.PHONY: install-tools lint test test-verbose format help | ||
|
||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
install-tools: ## Install linting tools | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
go install mvdan.cc/gofumpt@latest | ||
go install github.com/segmentio/golines@latest | ||
|
||
lint: ## Run golangci linter | ||
golangci-lint run -c ./golangci.yml ./... | ||
|
||
format: ## Format code | ||
gofumpt -l -w -extra . | ||
golines . -w | ||
|
||
test: ## Run tests | ||
go test -race -count=1 -cover ./... | ||
|
||
test-verbose: ## Run tests with verbose output | ||
go test -race -count=1 -v -cover ./... |
Empty file.
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,45 @@ | ||
package coverage | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Run(t *testing.M, c float64, callbacks ...func(t *testing.M)) { | ||
var code int | ||
defer func() { | ||
os.Exit(code) | ||
}() | ||
|
||
code = t.Run() | ||
|
||
if testing.CoverMode() == "" { | ||
fmt.Printf("\nFAIL coverage is not enabled. You can enable by using `-cover`\n\n") | ||
code = 1 | ||
} else { | ||
coverage := testing.Coverage() | ||
if coverage*100 < c { | ||
code = 1 | ||
fmt.Printf("\nFAIL Coverage threshold not met %.1f >= %.1f for %s\n\n", c, coverage*100, packageName()) | ||
} | ||
} | ||
|
||
for _, callback := range callbacks { | ||
callback(t) | ||
} | ||
} | ||
|
||
func packageName() string { | ||
pc, _, _, _ := runtime.Caller(2) | ||
funcName := runtime.FuncForPC(pc).Name() | ||
lastSlash := strings.LastIndexByte(funcName, '/') | ||
if lastSlash < 0 { | ||
lastSlash = 0 | ||
} | ||
lastDot := strings.LastIndexByte(funcName[lastSlash:], '.') + lastSlash | ||
|
||
return funcName[:lastDot] | ||
} |
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,3 @@ | ||
module coverage | ||
|
||
go 1.19 |
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,21 @@ | ||
linters: | ||
enable: | ||
- unconvert | ||
- stylecheck | ||
- lll | ||
- unparam | ||
- goimports | ||
- unparam | ||
- gofumpt | ||
- revive | ||
- unconvert | ||
- gocognit | ||
|
||
disable: | ||
- errcheck | ||
|
||
linters-settings: | ||
lll: | ||
line-length: 130 | ||
gofumpt: | ||
extra-rules: true |