generated from devnw/oss-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update workflows and add makefile
- Loading branch information
1 parent
c1ffcf6
commit f229905
Showing
5 changed files
with
128 additions
and
17 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
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,97 @@ | ||
all: build tidy lint fmt test | ||
|
||
#------------------------------------------------------------------------- | ||
# Variables | ||
# ------------------------------------------------------------------------ | ||
env=CGO_ENABLED=0 | ||
|
||
pyenv=.venv/bin | ||
|
||
#------------------------------------------------------------------------- | ||
# Targets | ||
#------------------------------------------------------------------------- | ||
deps: | ||
python3 -m venv .venv | ||
|
||
$(pyenv)/pip install --upgrade pre-commit | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
go install github.com/goreleaser/goreleaser@latest | ||
|
||
test: lint | ||
CGO_ENABLED=1 go test -cover -failfast -race ./... | ||
|
||
fuzz: | ||
@fuzzTime=$${FUZZ_TIME:-10}; \ | ||
files=$$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' .); \ | ||
for file in $$files; do \ | ||
funcs=$$(grep -o 'func Fuzz\w*' $$file | sed 's/func //'); \ | ||
for func in $$funcs; do \ | ||
echo "Fuzzing $$func in $$file"; \ | ||
parentDir=$$(dirname $$file); \ | ||
go test $$parentDir -run=$$func -fuzz=$$func -fuzztime=$${fuzzTime}s; \ | ||
if [ $$? -ne 0 ]; then \ | ||
echo "Fuzzing $$func in $$file failed"; \ | ||
exit 1; \ | ||
fi; \ | ||
done; \ | ||
done | ||
|
||
|
||
|
||
lint: tidy | ||
golangci-lint run | ||
$(pyenv)/pre-commit run --all-files | ||
|
||
build: update upgrade tidy lint test | ||
$(env) go build ./... | ||
|
||
release-dev: build-ci | ||
goreleaser release --rm-dist --snapshot | ||
|
||
upgrade: | ||
$(pyenv)/pre-commit autoupdate | ||
go get -u ./... | ||
|
||
update: | ||
git submodule update --recursive | ||
|
||
fmt: | ||
gofmt -s -w . | ||
|
||
tidy: fmt | ||
go mod tidy | ||
|
||
clean: | ||
rm -rf dist | ||
rm -rf coverage | ||
|
||
#------------------------------------------------------------------------- | ||
# CI targets | ||
#------------------------------------------------------------------------- | ||
test-ci: deps tidy lint | ||
CGO_ENABLED=1 go test \ | ||
-cover \ | ||
-covermode=atomic \ | ||
-coverprofile=coverage.txt \ | ||
-failfast \ | ||
-race ./... | ||
make fuzz FUZZ_TIME=10 | ||
|
||
build-ci: test-ci | ||
$(env) go build ./... | ||
|
||
|
||
release-ci: build-ci | ||
goreleaser release --rm-dist | ||
|
||
#------------------------------------------------------------------------- | ||
# Force targets | ||
#------------------------------------------------------------------------- | ||
|
||
FORCE: | ||
|
||
#------------------------------------------------------------------------- | ||
# Phony targets | ||
#------------------------------------------------------------------------- | ||
|
||
.PHONY: build test lint fuzz |