From ce8eae80960d25079324cfcf4e9ef8f67178f0b1 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Fri, 16 Jun 2023 12:10:50 +0200 Subject: [PATCH] ci: migrate code quality tooling from Codecov to Sonar Cloud (#2598) * remove codecov and add sonarcloud * remove /tools folder * add sonarcloud properties * update README.md --- .github/workflows/test.yml | 83 ++++++++++++++++++++++++-------------- README.md | 72 +++++++++++++-------------------- sonar-project.properties | 19 +++++++++ tools/tools.go | 14 ------- 4 files changed, 99 insertions(+), 89 deletions(-) create mode 100644 sonar-project.properties delete mode 100644 tools/tools.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 409b7cc4a7d..21482ef3e55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,25 +12,35 @@ on: - "**/*.md" - "docs/**" -jobs: - cleanup-runs: - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" - runs-on: ubuntu-latest - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" +permissions: + contents: read - test-coverage-upload: +concurrency: + group: ci-${{ github.ref }}-tests + cancel-in-progress: true + +jobs: + tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.5.2 - - uses: technote-space/get-diff-action@v6.1.1 + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + check-latest: true + cache: true + cache-dependency-path: go.sum + - uses: technote-space/get-diff-action@v6.1.2 + id: git_diff with: PATTERNS: | - **/**.go + **/*.go go.mod go.sum + **/go.mod + **/go.sum + **/Makefile + Makefile - uses: actions/cache@v3.3.1 with: path: | @@ -39,29 +49,15 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} restore-keys: | ${{ runner.os }}-go- - - uses: actions/setup-go@v4 - with: - go-version: 1.20.x - name: test & coverage report creation + if: env.GIT_DIFF run: | - go test -v -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... $(go list ./... | grep -v -e '/tests/e2e') - - name: filter non-testable files - run: | - excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" - excludelist+=" $(find ./ -type f -name '*.pb.go')" - excludelist+=" $(find ./ -type f -name '*.pb.gw.go')" - excludelist+=" $(find ./cmd -type d)" - excludelist+=" $(find ./tests -type d)" - for filename in ${excludelist}; do - filename=${filename#".//"} - echo "Excluding ${filename} from coverage report..." - filename=$(echo "$filename" | sed 's/\//\\\//g') - sed -i.bak "/""$filename""/d" coverage.txt - done - - uses: codecov/codecov-action@v3.1.4 + go test -v -coverprofile=profile.out -covermode=atomic -coverpkg=./... $(go list ./... | grep -v -e '/tests/e2e') + - uses: actions/upload-artifact@v3 + if: env.GIT_DIFF with: - file: ./coverage.txt - fail_ci_if_error: true + name: "${{ github.sha }}-coverage" + path: ./profile.out test-e2e: runs-on: ubuntu-latest @@ -82,6 +78,31 @@ jobs: - name: Test E2E run: make test-e2e + repo-analysis: + runs-on: ubuntu-latest + needs: [tests] + steps: + - uses: actions/checkout@v3 + - uses: technote-space/get-diff-action@v6.1.2 + id: git_diff + with: + PATTERNS: | + **/*.go + go.mod + go.sum + **/go.mod + **/go.sum + - uses: actions/download-artifact@v3 + if: env.GIT_DIFF + with: + name: "${{ github.sha }}-coverage" + - name: sonarcloud + if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }} + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + liveness-test: runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/README.md b/README.md index 40541d3240c..6c3d3bd0d35 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,32 @@ -
- - -
- -
- -

Cosmos Hub (Gaia)

-

The Cosmos Hub is the first of an exploding number of interconnected blockchains that comprise theΒ Cosmos Network.

- - Tweet -
-
- -
- -
- -
+# Cosmos Hub (Gaia) + +![Banner!](https://miro.medium.com/max/2000/1*DHtmSfS_Efvuq8n2LAnhkA.png) + +[![Project Status: Active -- The project has reached a stable, usable state and is being actively +developed.](https://img.shields.io/badge/repo%20status-Active-green.svg)](https://www.repostatus.org/#active) +[![License: Apache-2.0](https://img.shields.io/github/license/cosmos/gaia.svg)](https://github.com/cosmos/gaia/blob/main/LICENSE) +[![Version](https://img.shields.io/github/tag/cosmos/gaia.svg)](https://github.com/cosmos/gaia/releases/latest) +[![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/gaia)](https://goreportcard.com/report/github.com/cosmos/gaia) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue?logo=go)](https://pkg.go.dev/github.com/cosmos/gaia) +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=cosmos_gaia&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=cosmos_gaia) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cosmos_gaia&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cosmos_gaia) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=cosmos_gaia&metric=coverage)](https://sonarcloud.io/summary/new_code?id=cosmos_gaia) +[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/cosmosnetwork) +[![Twitter](https://badgen.net/badge/icon/twitter?icon=twitter&label)](https://twitter.com/cosmoshub) + +The Cosmos Hub is the first of an exploding number of interconnected blockchains that comprise theΒ Cosmos Network.
-### πŸ€” β€” Why should you be interested in the Cosmos Hub +## πŸ€” β€” Why should you be interested in the Cosmos Hub ___ The Cosmos Hub is built using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) and compiled to a binary called `gaiad` (Gaia Daemon). The Cosmos Hub and other fully sovereign Cosmos SDK blockchains interact with one another using a protocol called [IBC](https://github.com/cosmos/ibc) that enables Inter-Blockchain Communication. In order to understand what the Cosmos Hub is you can read this [introductory explanation](https://hub.cosmos.network/main/hub-overview/overview.html). -| | | | | | -| --- | --- | --- | --- | --- | -| [![codecov](https://codecov.io/gh/cosmos/gaia/branch/master/graph/badge.svg)](https://codecov.io/gh/cosmos/gaia) | [![Go Report Card](https://goreportcard.com/badge/github.com/cosmos/gaia)](https://goreportcard.com/report/github.com/cosmos/gaia) | [![license](https://img.shields.io/github/license/cosmos/gaia.svg)](https://github.com/cosmos/gaia/blob/main/LICENSE) | [![LoC](https://tokei.rs/b1/github/cosmos/gaia)](https://github.com/cosmos/gaia) | [![GolangCI](https://golangci.com/badges/github.com/cosmos/gaia.svg)](https://golangci.com/r/github.com/cosmos/gaia) | - -

-### ⚑ β€” Documentation & Introduction +## ⚑ β€” Documentation & Introduction ___ @@ -41,54 +34,48 @@ Cosmos Hub is a blockchain network that operates on Proof-of-Stake consensus. Yo Alternatively, whether you're new to blockchain technology or interested in getting involved, the Cosmos Network [Course](https://tutorials.cosmos.network/academy/0-welcome/) will guide you through everything. The course walks you through the basics of blockchain technology, to staking, setting up your own node, and beyond. -

-### πŸ‘€Β β€” Node Operators +## πŸ‘€Β β€” Node Operators ___ If you're interested in running a node on the current Cosmos Hub, check out the docs to [Join the Cosmos Hub Mainnet](https://github.com/cosmos/gaia/blob/main/docs/hub-tutorials/join-mainnet.md). -

-### πŸ—£οΈΒ β€” Validators +## πŸ—£οΈΒ β€” Validators ___ If you want to participate and help secure Cosmos Hub, check out becoming a validator. Information on what a validator is and how to participate as one can be found at the [Validator FAQ](https://hub.cosmos.network/main/validators/validator-faq.html#). If you're running a validator node on the Cosmos Hub, reach out to a Janitor on the [Cosmos Developers Discord](https://discord.gg/cosmosnetwork) to join the `#cosmos-hub-validators-verified` channel. -

-### πŸ‘₯Β β€” Delegators +## πŸ‘₯Β β€” Delegators ___ If you still want to participate on the Cosmos Hub, check out becoming a delegator. Information on what a delegator is and how to participate as one can be found at the [Delegator FAQ](https://hub.cosmos.network/main/delegators/delegator-faq.html). -

-### πŸ‘₯ β€” Testnet +## πŸ‘₯ β€” Testnet ___ To participate in or utilize the current Cosmos Hub testnet, take a look at the [cosmos/testnets](https://github.com/cosmos/testnets) repository. This testnet is for the Theta Upgrade expected in Q1 2022. For future upgrades of the Cosmos Hub take a look at the [roadmap](https://github.com/cosmos/gaia/blob/main/docs/roadmap/cosmos-hub-roadmap-2.0.md). -

-### πŸŒΒ β€” Roadmap +## πŸŒΒ β€” Roadmap ___ For an overview of upcoming changes to the Cosmos Hub take a look at the [Roadmap](https://github.com/cosmos/gaia/blob/main/docs/roadmap/cosmos-hub-roadmap-2.0.md). -

-### πŸ—„οΈ β€” Archives & Genesis +## πŸ—„οΈ β€” Archives & Genesis ___ @@ -97,19 +84,17 @@ Mainnet is currently running as `cosmoshub-4`. Archives of the state of `cosmosh If you are looking for historical genesis files and other data [`cosmos/mainnet`](http://github.com/cosmos/mainnet) is an excellent resource. Snapshots are also available at [cosmos.quicksync.io](https://cosmos.quicksync.io). -

-### 🀝 β€” How to contribute +## 🀝 β€” How to contribute ___ Check out [contributing.md](CONTRIBUTING.md) for our guidelines & policies for how we develop the Cosmos Hub. Thank you to all those who have contributed! -

-### πŸ’¬ β€” Talk to us +## πŸ’¬ β€” Talk to us ___ @@ -124,10 +109,9 @@ We have active, helpful communities on Twitter, Discord, and Telegram. For updates on the Cosmos Hub team's activities follow us on the [Cosmos Hub Twitter](https://twitter.com/cosmoshub) account. -

-### πŸ‘ β€” Supporters +## πŸ‘ β€” Supporters ___ diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000000..e36432b374c --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +sonar.projectKey=cosmos_gaia +sonar.organization=cosmos + +sonar.projectName=Gaia + +sonar.sources=. +sonar.exclusions=**/*_test.go,tests/**,**/testutil/**,**/*.pb.go,**/*.pb.gw.go,test_helpers.go,docs/**,client/docs/**,contrib/**, +sonar.tests=. +sonar.test.inclusions=**/*_test.go,tests/**,**/testutil/** +sonar.go.coverage.reportPaths=coverage.out,*profile.out + +sonar.python.version=3 +sonar.sourceEncoding=UTF-8 +sonar.scm.provider=git + +# Exclude C/C++/Objective-C files from analysis +sonar.c.file.suffixes=- +sonar.cpp.file.suffixes=- +sonar.objc.file.suffixes=- \ No newline at end of file diff --git a/tools/tools.go b/tools/tools.go deleted file mode 100644 index a8180c6cf92..00000000000 --- a/tools/tools.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build tools -// +build tools - -// This file uses the recommended method for tracking developer tools in a Go -// module. -// -// REF: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module -package tools - -// DONTCOVER - -import ( - _ "github.com/golangci/golangci-lint/cmd/golangci-lint" -)