From aed056fde309ff6e88e066d5f612eab1121f0491 Mon Sep 17 00:00:00 2001
From: milen <94537774+taratorio@users.noreply.github.com>
Date: Mon, 29 Apr 2024 14:46:31 +0300
Subject: [PATCH] use sonar for code coverage badge (#10107)
- use sonar badge for code coverage
- remove unnecessary "Coverage" GitHub action and unnecessary duplicate
test run on "devel" CI for it
- the existing coverage job + badge didn't seem to be accurate (wasn't
taking into account `erigon-lib` sub-module)
---
.github/workflows/coverage.yml | 53 ----------------------------------
.gitignore | 1 -
Makefile | 5 ----
README.md | 4 +--
4 files changed, 1 insertion(+), 62 deletions(-)
delete mode 100644 .github/workflows/coverage.yml
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
deleted file mode 100644
index 79664e92656..00000000000
--- a/.github/workflows/coverage.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-name: Coverage
-on:
- push:
- branches:
- - devel
-
-jobs:
- coverage:
- runs-on: ubuntu-22.04
-
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v4
- with:
- go-version: '1.21'
-
- - name: install dependencies on Linux
- if: runner.os == 'Linux'
- run: sudo apt update && sudo apt install build-essential
-
- - name: run coverage
- run: echo "COVERAGE=$(make coverage)" >> $GITHUB_ENV
-
- - name: set badge color
- shell: bash
- run: |
- if [ ${{ env.COVERAGE }} -lt 40 ]
- then
- echo "BADGE_COLOR=800000" >> $GITHUB_ENV
- elif [ ${{ env.COVERAGE }} -lt 75 ]
- then
- echo "BADGE_COLOR=696969" >> $GITHUB_ENV
- else
- echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
- fi
-
- - name: create badge
- uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
- with:
- label: Coverage
- status: ${{ env.COVERAGE }}
- color: ${{ env.BADGE_COLOR }}
- path: badge.svg
-
- - name: upload badge to gist
- if: >
- github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' ||
- github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel'
- uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
- with:
- token: ${{ secrets.GIST_TOKEN }}
- gistURL: https://gist.githubusercontent.com/revitteth/ee38e9beb22353eef6b88f2ad6ed7aa9
- file: badge.svg
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index ee5b55826b2..6badb620637 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,7 +78,6 @@ go.work*
docker-compose.*.yml
.env
coverage.out
-coverage-total.out
dist
__debug_bin
diff --git a/Makefile b/Makefile
index 5d1c2a23b04..537458dc794 100644
--- a/Makefile
+++ b/Makefile
@@ -342,11 +342,6 @@ user_macos:
sudo dscl . -append /Groups/admin GroupMembership $(ERIGON_USER)
sudo -u $(ERIGON_USER) mkdir -p /Users/$(ERIGON_USER)/.local/share
-## coverage: run code coverage report and output total coverage %
-.PHONY: coverage
-coverage:
- @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
hive:
diff --git a/README.md b/README.md
index 3cfac3d5ac0..d5c249062d5 100644
--- a/README.md
+++ b/README.md
@@ -7,9 +7,7 @@ by default.
An accessible and complete version of the documentation is available at **[erigon.gitbook.io](https://erigon.gitbook.io)**.
-![Build status](https://github.com/ledgerwatch/erigon/actions/workflows/ci.yml/badge.svg)
-
-![Coverage](https://gist.githubusercontent.com/revitteth/ee38e9beb22353eef6b88f2ad6ed7aa9/raw/badge.svg)
+![Build status](https://github.com/ledgerwatch/erigon/actions/workflows/ci.yml/badge.svg) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ledgerwatch_erigon&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ledgerwatch_erigon)