-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(ci): enable code coverage on Sonarcloud #1518
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
.github/workflows/ci-test-go.yml
Outdated
@@ -101,6 +101,15 @@ jobs: | |||
run: | | |||
go install gotest.tools/gotestsum@latest | |||
make test-unit | |||
|
|||
- name: Analyze with SonarCloud | |||
if: ${{ always() && inputs.run-tests && inputs.project-directory == '.' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this is working for the parent go module we can do the same for each submodule.
sonar.projectKey=testcontainers_testcontainers-go | ||
|
||
sonar.projectName=testcontainers-go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine that for modulegen, it could be :
sonar.projectKey=testcontainers_testcontainers-go_modulegen
sonar.projectName=testcontainers-go/modulegen
For examples/bigtable it could be :
sonar.projectKey=testcontainers_testcontainers-go_examples_bigtable
sonar.projectName=testcontainers-go/examples/bigtable
Let me check internally with other maintainers how it's done in their language projects. Will ping you back here once I have it clear how to proceed with Sonarqube, as it'd be a great improvement seeing the code coverage alongside the "defects" it finds (although I dislike a bit how the Go rules are processed). |
I'm going to create the secret in the project to make this work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment about the used flags. I also added the SONAR_TOKEN secret to the repo, probably won't work until this is PR merged because of forks 🤷
Signed-off-by: Matthieu MOREL <[email protected]>
There seems to be an option to share secrets with pull request from forks. Have you read this ? |
I'm not sure if that will work for PRs from forks not from the organisation: https://community.sonarsource.com/t/sonar-token-permissions-in-pull-request-github-actions/90614/9 I'll double check with other maintainers now |
@mmorel-35 it seems that .NET uses it but only for merges to develop or main branches: https://github.com/testcontainers/testcontainers-dotnet/blob/develop/.github/workflows/cicd.yml#L74 I think we should go with the same approach for the moment |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Hi @mdelapenya , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks again for your work here!
Merging it now |
Hi @mdelapenya , |
I've just disabled the automatic analysis from the service. It's unfortunate that they do not provide a graceful alternative, like not failing that hard 🤷♂️ |
…containerd-1.7.5 * main: chore: always generate the examples including a explicit image (#1611) chore: support linting all modules locally (#1609) ci(sonarcloud): run only when not root-less (#1608) remove extra equal in sonar.organization (#1607) chore(ci): enable code coverage on Sonarcloud (#1518) docs: use Go testable examples in modules (#1603)
* main: chore: always generate the examples including a explicit image (testcontainers#1611) chore: support linting all modules locally (testcontainers#1609) ci(sonarcloud): run only when not root-less (testcontainers#1608) remove extra equal in sonar.organization (testcontainers#1607) chore(ci): enable code coverage on Sonarcloud (testcontainers#1518) docs: use Go testable examples in modules (testcontainers#1603) ci(lint): enable errorlint linter (testcontainers#1604) ci(lint): enable gocritic linter (testcontainers#1605) chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault (testcontainers#1566) ci(security): setup codeql scan (testcontainers#1606) chore(deps): bump github.com/cyphar/filepath-securejoin (testcontainers#1601) chore: generate Go examples for new modules (testcontainers#1600) chore: generate Go examples for new modules (testcontainers#1600)
Hi @mdelapenya,
It seems like sonar requires a SONAR_TOKEN secret, I tried to compare with testcontainers-donet and testcontainers-node that reports code coverage on their sonarcloud reports but I couldn’t find anything comparable as they are not using the sonarcloud action to upload their test results.
I tried to provide my own SONAR_TOKEN but it seems it not possible to use it in a fork repository.
Any idea ? Or you prefer to keep things as it is now ?