Skip to content

Commit

Permalink
ci: add sonarcloud for go and js (#291)
Browse files Browse the repository at this point in the history
* ci: add sonarcloud for go and js

* add needs field

* Update .github/workflows/typescript.yml

Co-authored-by: DimitrisJim <[email protected]>

* update project name

* ignore Rust files

---------

Co-authored-by: DimitrisJim <[email protected]>
  • Loading branch information
crodriguezvega and DimitrisJim authored Mar 12, 2024
1 parent b84f236 commit b82084e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 24 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,21 @@ jobs:
working-directory: ./go
run: make test

coverage:
name: Code Coverage
analysis:
name: Go analysis
needs: [test]
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
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }}
uses: SonarSource/[email protected]
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

24 changes: 13 additions & 11 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ jobs:
working-directory: ./js
run: yarn && yarn test

coverage:
name: Code Coverage
analysis:
name: Typescript analysis
needs: [test]
runs-on: ubuntu-latest
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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: js
14 changes: 14 additions & 0 deletions go/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=ics23-go
sonar.organization=cosmos

sonar.projectName=ics23 - 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
14 changes: 14 additions & 0 deletions js/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=ics23-js
sonar.organization=cosmos

sonar.projectName=ics23 - 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
21 changes: 21 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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/**,rust/**,
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=-

0 comments on commit b82084e

Please sign in to comment.