From b7375e9388d95c417782f796f0378361a8023e7b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 13:29:03 +0100 Subject: [PATCH 1/5] ci: add sonarcloud for go and js --- .github/workflows/go.yml | 24 +++++++++++------------- .github/workflows/typescript.yml | 24 +++++++++++++----------- go/sonar-project.properties | 14 ++++++++++++++ js/sonar-project.properties | 14 ++++++++++++++ sonar-project.properties | 21 +++++++++++++++++++++ 5 files changed, 73 insertions(+), 24 deletions(-) create mode 100644 go/sonar-project.properties create mode 100644 js/sonar-project.properties create mode 100644 sonar-project.properties diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0cf4a039..2ce85545 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,22 +43,20 @@ jobs: working-directory: ./go run: make test - coverage: - name: Code Coverage + analysis: + name: Go analysis runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 with: - go-version: "1.21" - - name: Run coverage - working-directory: ./go - run: go test -race -coverprofile=coverage.txt -covermode=atomic - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: SonarCloud Scan + if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} + uses: SonarSource/sonarcloud-github-action@v2.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: - token: ${{ secrets.CODECOV_TOKEN }} - files: go/coverage.txt - flags: go - fail_ci_if_error: true + projectBaseDir: go diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index b902177b..62a936cf 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -25,18 +25,20 @@ jobs: working-directory: ./js run: yarn && yarn test - coverage: - name: Code Coverage + analysis: + name: Go analysis runs-on: ubuntu-latest + needs: [tests] steps: - uses: actions/checkout@v4 - - name: Generate code coverage - working-directory: ./js - run: yarn && yarn coverage - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - files: js/coverage/lcov.info - flags: typescript - fail_ci_if_error: true + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + - name: sonarcloud + if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} + uses: SonarSource/sonarcloud-github-action@v2.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + projectBaseDir: js diff --git a/go/sonar-project.properties b/go/sonar-project.properties new file mode 100644 index 00000000..71e3ff5f --- /dev/null +++ b/go/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.projectKey=ics23-go +sonar.organization=cosmos + +sonar.projectName=ibc-go - Go +sonar.project.monorepo.enabled=true + +sonar.sources=. +sonar.exclusions=**/*_test.go,**/testdata/**, +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=coverage.out + +sonar.sourceEncoding=UTF-8 +sonar.scm.provider=git \ No newline at end of file diff --git a/js/sonar-project.properties b/js/sonar-project.properties new file mode 100644 index 00000000..8fd3cfcf --- /dev/null +++ b/js/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.projectKey=ics23-js +sonar.organization=cosmos + +sonar.projectName=ibc-go - Js +sonar.project.monorepo.enabled=true + +sonar.sources=. +sonar.exclusions=**/*_test.go,**/node_modules/**, +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=coverage.out + +sonar.sourceEncoding=UTF-8 +sonar.scm.provider=git \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..9350c56c --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,21 @@ +sonar-projects.propertiessonar.projectKey=cosmos_ics23 +sonar.organization=cosmos + +sonar.projectName=ics23 +sonar.project.monorepo.enabled=true + +sonar.sources=. +sonar.exclusions=**/*_test.go,**/testdata/**,scripts/**, +sonar.tests=. +sonar.test.inclusions=**/*_test.go,**/testdata/** +sonar.go.coverage.reportPaths=go/coverage.txt +sonar.javascript.lcov.reportPaths=js/coverage/lcov.info + +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 From b63f1c71bfdc023134581fdcff0623ded183908b Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 13:42:37 +0100 Subject: [PATCH 2/5] add needs field --- .github/workflows/go.yml | 3 ++- .github/workflows/typescript.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2ce85545..49ee0bb0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -45,13 +45,14 @@ jobs: analysis: name: Go analysis + needs: [test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 - - name: SonarCloud Scan + - name: sonarcloud if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} uses: SonarSource/sonarcloud-github-action@v2.1.1 env: diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 62a936cf..164dee27 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -27,8 +27,8 @@ jobs: analysis: name: Go analysis + needs: [test] runs-on: ubuntu-latest - needs: [tests] steps: - uses: actions/checkout@v4 with: From 67d509c273d653b7c9c0c0d1446319f4b84f527d Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 19:59:27 +0100 Subject: [PATCH 3/5] Update .github/workflows/typescript.yml Co-authored-by: DimitrisJim --- .github/workflows/typescript.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 164dee27..55bc9270 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -26,7 +26,7 @@ jobs: run: yarn && yarn test analysis: - name: Go analysis + name: Typescript analysis needs: [test] runs-on: ubuntu-latest steps: From 8fda5ea6e0333c675dfb713a55bc02cfb178f394 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 20:10:24 +0100 Subject: [PATCH 4/5] update project name --- go/sonar-project.properties | 2 +- js/sonar-project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/sonar-project.properties b/go/sonar-project.properties index 71e3ff5f..51c69fb8 100644 --- a/go/sonar-project.properties +++ b/go/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=ics23-go sonar.organization=cosmos -sonar.projectName=ibc-go - Go +sonar.projectName=ics23 - Go sonar.project.monorepo.enabled=true sonar.sources=. diff --git a/js/sonar-project.properties b/js/sonar-project.properties index 8fd3cfcf..e5833b62 100644 --- a/js/sonar-project.properties +++ b/js/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=ics23-js sonar.organization=cosmos -sonar.projectName=ibc-go - Js +sonar.projectName=ics23 - JS sonar.project.monorepo.enabled=true sonar.sources=. From ba62a91a68bbcc6ced851c0f82581756c507b5fe Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 8 Mar 2024 20:14:18 +0100 Subject: [PATCH 5/5] ignore Rust files --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 9350c56c..3044ca15 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,7 +5,7 @@ sonar.projectName=ics23 sonar.project.monorepo.enabled=true sonar.sources=. -sonar.exclusions=**/*_test.go,**/testdata/**,scripts/**, +sonar.exclusions=**/*_test.go,**/testdata/**,scripts/**,rust/**, sonar.tests=. sonar.test.inclusions=**/*_test.go,**/testdata/** sonar.go.coverage.reportPaths=go/coverage.txt