From dd87f2f1307932bbee620fdb0bd11b52add327a8 Mon Sep 17 00:00:00 2001 From: taratorio <94537774+taratorio@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:36:50 +0300 Subject: [PATCH 1/3] sonar: fix warnings --- .github/workflows/ci.yml | 2 ++ sonar-project.properties | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b673ef98f73..3dc6eb30694 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v4 with: go-version: '1.20' diff --git a/sonar-project.properties b/sonar-project.properties index e15c7f49a0c..11d339bd817 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,3 +19,6 @@ sonar.go.coverage.reportPaths=coverage-erigon.out,coverage-erigon-lib.out sonar.c.file.suffixes=- sonar.cpp.file.suffixes=- sonar.objc.file.suffixes=- + +# Specify whether to scan python files in the repo following python 2 or 3 rules +sonar.python.version=3.12 From 54a313464fce465f579593ebb10fd897c3994651 Mon Sep 17 00:00:00 2001 From: taratorio <94537774+taratorio@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:10:43 +0300 Subject: [PATCH 2/3] exclusions --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 11d339bd817..0f84a9a471e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=ledgerwatch sonar.projectName=erigon sonar.sources=. -sonar.exclusions=**/*.pb.go,cmd/rpcdaemon/graphql/graph/generated.go +sonar.exclusions=**/*.pb.go,**/gen_*.go,**/graphql/graph/generated.go,**/*.sol,common/compiler/*.v.py sonar.tests=. sonar.test.inclusions=**/*_test.go,tests/** From e22b711dd28ca0ce341f7286ddebe8f3f68e62f9 Mon Sep 17 00:00:00 2001 From: taratorio <94537774+taratorio@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:41:16 +0300 Subject: [PATCH 3/3] fix sonar not finding erigon-lib coverage --- .gitignore | 3 +-- Makefile | 4 ++-- erigon-lib/.gitignore | 2 ++ erigon-lib/Makefile | 2 +- sonar-project.properties | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c5ea52bf092..ee5b55826b2 100644 --- a/.gitignore +++ b/.gitignore @@ -78,8 +78,7 @@ go.work* docker-compose.*.yml .env coverage.out -coverage-erigon.out -coverage-erigon-lib.out +coverage-total.out dist __debug_bin diff --git a/Makefile b/Makefile index 7312ae250ed..c55caf5a3cd 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ test-erigon-ext: ## test: run unit tests with a 100s timeout test: test-erigon-lib - $(GOTEST) --timeout 10m -coverprofile=coverage-erigon.out + $(GOTEST) --timeout 10m -coverprofile=coverage.out test3: test-erigon-lib $(GOTEST) --timeout 10m -tags $(BUILD_TAGS),e3 @@ -313,7 +313,7 @@ user_macos: ## coverage: run code coverage report and output total coverage % .PHONY: coverage coverage: - @go test -coverprofile=coverage.out ./... > /dev/null 2>&1 && go tool cover -func coverage.out | grep total | awk '{print substr($$3, 1, length($$3)-1)}' + @go test -coverprofile=coverage-total.out ./... > /dev/null 2>&1 && go tool cover -func coverage-total.out | grep total | awk '{print substr($$3, 1, length($$3)-1)}' ## hive: run hive test suite locally using docker e.g. OUTPUT_DIR=~/results/hive SIM=ethereum/engine make hive .PHONY: hive diff --git a/erigon-lib/.gitignore b/erigon-lib/.gitignore index 1155933ce5d..5025f8f6724 100644 --- a/erigon-lib/.gitignore +++ b/erigon-lib/.gitignore @@ -73,3 +73,5 @@ libmdbx/build/* tests/testdata/* go.work* + +coverage.out diff --git a/erigon-lib/Makefile b/erigon-lib/Makefile index 3a1e4a8837a..54151bb86d2 100644 --- a/erigon-lib/Makefile +++ b/erigon-lib/Makefile @@ -97,7 +97,7 @@ lint-deps: lintci-deps lint-licenses-deps lint: lintci lint-licenses lint-mod-tidy test: - $(GOTEST) --count 1 -p 2 -coverprofile=coverage-erigon-lib.out ./... + $(GOTEST) --count 1 -p 2 -coverprofile=coverage.out ./... test-no-fuzz: $(GOTEST_NOFUZZ) --count 1 -p 2 ./... diff --git a/sonar-project.properties b/sonar-project.properties index 0f84a9a471e..3cd8180ebf5 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,7 +8,7 @@ sonar.exclusions=**/*.pb.go,**/gen_*.go,**/graphql/graph/generated.go,**/*.sol,c sonar.tests=. sonar.test.inclusions=**/*_test.go,tests/** -sonar.go.coverage.reportPaths=coverage-erigon.out,coverage-erigon-lib.out +sonar.go.coverage.reportPaths=coverage.out,erigon-lib/coverage.out # The only way to get an accurate analysis of C/C++/Objective-C files is # by using the SonarSource build-wrapper and setting the property "sonar.cfamily.build-wrapper-output"