File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ .DEFAULT_GOAL := help
2+
3+ SHELL := /bin/bash
4+
5+ GO111MODULE := on
6+
7+ GOPKG := github.com/veraison/swid
8+
9+ GOLINT ?= golangci-lint
10+
11+ ifeq ($(MAKECMDGOALS ) ,lint)
12+ GOLINT_ARGS ?= run --timeout=3m
13+ else
14+ ifeq ($(MAKECMDGOALS),lint-extra)
15+ GOLINT_ARGS ?= run --timeout=3m --issues-exit-code=0 -E dupl -E gocritic -E gosimple -E lll -E prealloc
16+ endif
17+ endif
18+
19+ .PHONY : lint lint-extra
20+ lint lint-extra : ; $(GOLINT ) $(GOLINT_ARGS )
21+
22+ ifeq ($(MAKECMDGOALS ) ,test)
23+ GOTEST_ARGS ?= -v -race $(GOPKG )
24+ else
25+ ifeq ($(MAKECMDGOALS),test-cover)
26+ GOTEST_ARGS ?= -short -cover $(GOPKG )
27+ endif
28+ endif
29+
30+ COVER_THRESHOLD := $(shell grep '^name: cover' .github/workflows/ci-go-cover.yml | cut -c13-)
31+
32+ .PHONY : test test-cover
33+ test test-cover : ; go test $(GOTEST_ARGS )
34+
35+ presubmit :
36+ @echo
37+ @echo " >>> Check that the reported coverage figures are $( COVER_THRESHOLD) "
38+ @echo
39+ $(MAKE ) test-cover
40+ @echo
41+ @echo " >>> Fix any lint error"
42+ @echo
43+ $(MAKE ) lint
44+
45+ .PHONY : help
46+ help :
47+ @echo " Available targets:"
48+ @echo " * test: run unit tests for $( GOPKG) "
49+ @echo " * test-cover: run unit tests and measure coverage for $( GOPKG) "
50+ @echo " * lint: lint sources using default configuration"
51+ @echo " * lint-extra: lint sources using default configuration and some extra checkers"
52+ @echo " * presubmit: check you are ready to push your local branch to remote"
53+ @echo " * help: print this menu"
Original file line number Diff line number Diff line change @@ -5,3 +5,11 @@ The `swid` package provides a golang API for manipulating Software Identificatio
55## Resources
66
77* [ Package Documentation] ( https://pkg.go.dev/github.com/veraison/swid )
8+
9+ ## Developer tips
10+
11+ Before doing a PR (and routinely during the dev/test cycle) run
12+ ```
13+ make presubmit
14+ ```
15+ and check its output to make sure your code coverage figures are in line with the target and that there are no newly introduced lint problems.
You can’t perform that action at this time.
0 commit comments