Merge pull request #47 from pushbits/swagger

Exclude tests when generating API docs
This commit is contained in:
Raphael Eikenberg 2022-02-15 19:00:54 +01:00 committed by GitHub
commit 5654ecbbde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,20 +1,26 @@
OUTDIR := ./out # References:
# [1] Needed so the Go files of semgrep-rules do not interfere with static analysis
SEMGREP_MODFILE := ./tests/semgrep-rules/go.mod DOCS_DIR := ./docs
OUT_DIR := ./out
TESTS_DIR := ./tests
SEMGREP_MODFILE := $(TESTS_DIR)/semgrep-rules/go.mod
.PHONY: build .PHONY: build
build: build:
mkdir -p $(OUTDIR) mkdir -p $(OUT_DIR)
go build -ldflags="-w -s" -o $(OUTDIR)/pushbits ./cmd/pushbits go build -ldflags="-w -s" -o $(OUT_DIR)/pushbits ./cmd/pushbits
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf $(OUTDIR) rm -rf $(DOCS_DIR)
rm -rf $(OUT_DIR)
rm -rf $(SEMGREP_MODFILE) rm -rf $(SEMGREP_MODFILE)
.PHONY: test .PHONY: test
test: test:
touch $(SEMGREP_MODFILE) # Needed so the Go files of semgrep-rules do not interfere with static analysis touch $(SEMGREP_MODFILE) # See [1].
go fmt ./... go fmt ./...
go vet ./... go vet ./...
gocyclo -over 10 $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \)) gocyclo -over 10 $(shell find . -type f \( -iname '*.go' ! -path "./tests/semgrep-rules/*" \))
@ -22,7 +28,7 @@ test:
go test -v -cover ./... go test -v -cover ./...
gosec -exclude-dir=tests ./... gosec -exclude-dir=tests ./...
semgrep --lang=go --config=tests/semgrep-rules/go --metrics=off semgrep --lang=go --config=tests/semgrep-rules/go --metrics=off
rm -rf $(SEMGREP_MODFILE) rm -rf $(SEMGREP_MODFILE) # See [1].
@printf '\n%s\n' "> Test successful" @printf '\n%s\n' "> Test successful"
.PHONY: setup .PHONY: setup
@ -36,4 +42,4 @@ setup:
.PHONY: swag .PHONY: swag
swag: swag:
swag init --parseDependency=true -d . -g cmd/pushbits/main.go swag init --parseDependency=true --exclude $(TESTS_DIR) -g cmd/pushbits/main.go