You've already forked prometheus-fail2ban-exporter
fix(ci): add coverage
Some checks failed
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Waiting to run
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 21s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Failing after 50s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 1m34s
Lint Markdown files / Run markdown linter (push) Successful in 33s
Some checks failed
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Waiting to run
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 21s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Failing after 50s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 1m34s
Lint Markdown files / Run markdown linter (push) Successful in 33s
This commit is contained in:
@@ -40,3 +40,18 @@ jobs:
|
|||||||
- env:
|
- env:
|
||||||
GOPROXY: ${{ vars.GOPROXY }}
|
GOPROXY: ${{ vars.GOPROXY }}
|
||||||
run: make test/unit
|
run: make test/unit
|
||||||
|
- id: coverage
|
||||||
|
name: Check coverage
|
||||||
|
run: |
|
||||||
|
coverage="$(make test/coverage | grep total | awk '{ print substr($3, 1, length($3)-1); }')"
|
||||||
|
echo "total_coverage=$coverage" >> $GITHUB_OUTPUT
|
||||||
|
echo "Total coverage: ${coverage}%"
|
||||||
|
- name: Fail if coverage is to low
|
||||||
|
run: |
|
||||||
|
threshold=50
|
||||||
|
total_coverage=${{ steps.coverage.outputs.total_coverage }}
|
||||||
|
|
||||||
|
if (( ${total_coverage%.*} < ${threshold} )); then
|
||||||
|
echo "ERROR: Coverage (${total_coverage}%) is below the threshold (${threshold}%)." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
prometheus-fail2ban-exporter
|
prometheus-fail2ban-exporter
|
||||||
coverage.txt
|
coverage.*
|
||||||
dist
|
dist
|
||||||
6
Makefile
6
Makefile
@@ -40,7 +40,7 @@ PHONY+=test/unit
|
|||||||
test/unit:
|
test/unit:
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOPROXY=$(shell go env GOPROXY) \
|
GOPROXY=$(shell go env GOPROXY) \
|
||||||
go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./...
|
go test -v -p 1 -coverprofile=coverage.out -covermode=count -timeout 1200s ./...
|
||||||
|
|
||||||
PHONY+=test/integration
|
PHONY+=test/integration
|
||||||
test/integration:
|
test/integration:
|
||||||
@@ -49,10 +49,10 @@ test/integration:
|
|||||||
go test -v -p 1 -count=1 -timeout 1200s ./it/...
|
go test -v -p 1 -count=1 -timeout 1200s ./it/...
|
||||||
|
|
||||||
PHONY+=test/coverage
|
PHONY+=test/coverage
|
||||||
test/coverage: test/unit
|
test/coverage:
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOPROXY=$(shell go env GOPROXY) \
|
GOPROXY=$(shell go env GOPROXY) \
|
||||||
go tool cover -html=coverage.txt
|
go tool cover -func=coverage.out
|
||||||
|
|
||||||
# GOLANGCI-LINT
|
# GOLANGCI-LINT
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user