From 272a61db6ab2d25a74e5a7ff5e459a890692a457 Mon Sep 17 00:00:00 2001 From: dmachard <5562930+dmachard@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:53:36 +0100 Subject: [PATCH] GHactions count tests --- .github/workflows/testing-go.yml | 26 +++++++++++++++++++++++++- Makefile | 3 ++- docs/development.md | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing-go.yml b/.github/workflows/testing-go.yml index ef03183d..93523927 100644 --- a/.github/workflows/testing-go.yml +++ b/.github/workflows/testing-go.yml @@ -116,4 +116,28 @@ jobs: cd prometheus-$PROM_VERSION.linux-amd64/ curl -u admin:changeme http://127.0.0.1:8081/metrics | ./promtool check metrics env: - PROM_VERSION: "2.47.0" \ No newline at end of file + PROM_VERSION: "2.47.0" + + count: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: "1.21" + + - id: count_tests + run: | + data=$(sudo go test -v ./collectors ./processors ./dnsutils ./netlib ./loggers ./transformers 2>&1 | grep -c RUN) + echo "Count of Tests: $data" + echo "data=$data" >> $GITHUB_OUTPUT + + - id: count_lines + run: | + data=$(find . -name "*.go" -exec grep -v "^$" {} \; -exec grep -v "//" {} \; | wc -l) + echo "Count of Lines: $data" + echo "data=$data" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/Makefile b/Makefile index 57e783dc..bed0cfd0 100644 --- a/Makefile +++ b/Makefile @@ -50,12 +50,13 @@ version: build lint: $(GOPATH)/bin/golangci-lint run --config=.golangci.yml ./... -test: +tests: @go test ./dnsutils/ -race -cover -v @go test ./netlib/ -race -cover -v @go test -timeout 30s ./transformers/ -race -cover -v @go test -timeout 30s ./collectors/ -race -cover -v @go test -timeout 90s ./loggers/ -race -cover -v + @go test -timeout 30s ./processors/ -race -cover -v clean: @go clean diff --git a/docs/development.md b/docs/development.md index b163bc9f..832e4bf4 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,7 +39,7 @@ make lint Execute testunits before to commit ```bash -sudo make test +sudo make tests ``` Execute a test for one specific testcase in a package