Skip to content
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

Sonarqube including coverage on each PR. #6111

Merged
merged 12 commits into from
Jun 7, 2022
Merged

Conversation

michaelkaye
Copy link
Contributor

@michaelkaye michaelkaye commented May 20, 2022

Changes:

  • remove a lot of post-pr.yml tests (integration and sonarqube) as these run on each PR now
  • Leave behind the UI test as that is not part of 'code coverage'
  • Ignore a number of tests that were failing during the testing process - sonar coverage only works when tests run fine; so ensure we only have fine tests.
    • NB: some of these tests may run fine locally, or may be able to be reintroduced with some tweaks; however at this point I'm explicitly ignoring any test that has failed, so we can start having a reliable test run - i know this is removing some probably good tests, and that is an explicit goal.
  • Update configuration to use a new sonarcloud.io project for uploads; this enables the PR notifications to be set correctly.

Once merged, we'll want to update the list of required checks before merging is OK; at the moment some of the checks are not being run or have been combined; this is global across the project and needs to occur after merging to develop.

After merge I suggest everyone updates their branches against latest develop before attempting a PR merge.

A concern might be usage of the macos runner to get the integration tests running each time. There's not much we can do about that at present.

@michaelkaye michaelkaye force-pushed the michaelk/sonarqube_fixes branch 2 times, most recently from 2f50c6d to 5e3046c Compare May 25, 2022 11:33
@michaelkaye michaelkaye force-pushed the michaelk/sonarqube_fixes branch from 5e3046c to 02797a1 Compare May 25, 2022 11:39
@michaelkaye michaelkaye changed the title DO NOT MERGE: sonarqube GHA testing Sonarqube including coverage on each PR. May 25, 2022
@element-hq element-hq deleted a comment from sonarqubecloud bot May 25, 2022
@michaelkaye
Copy link
Contributor Author

Kudos, SonarCloud Quality Gate passed! Quality Gate passed

Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell A 0 Code Smells

No Coverage information No Coverage information 0.0% 0.0% Duplication

Unsure why this has no coverage marked on it yet; coverage is available in the sonarcloud.io UI.

@michaelkaye
Copy link
Contributor Author

Though, given the whole macos thing; I might attempt to use a linux runner and see if it reliably fails, or if the failure rate that caused us to use the macos runner was related to tests that we have since ignored.

@michaelkaye
Copy link
Contributor Author

"Build android tests" is now covered by generic tests - we run them as well as build them now.

"Run unit tests" is now covered by "Runs all tests" - we combined them with the integration tests.

@michaelkaye michaelkaye marked this pull request as ready for review May 25, 2022 12:09
@michaelkaye
Copy link
Contributor Author

Test coverage (even with all the ignored tests) is now at 10% ish - a big improvement on the ~2% we were earlier reporting.

@@ -18,11 +21,13 @@ def initializeReport(report, projects, classExcludes) {
switch (project) {
case { project.plugins.hasPlugin("com.android.application") }:
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/gplayDebug")
androidSourceDirs.add("${project.buildDir}/generated/source/kapt/gplayDebug")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this we have some generated files with coverage percentages but no source to look at. Maybe we should ignore them from the coverage instead?

Copy link
Contributor

@ouchadam ouchadam May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be for ignoring all generated code (since we're technically not the author~)

Can be a separate PR after clearing our exclusions with the team

@michaelkaye
Copy link
Contributor Author

Though, given the whole macos thing; I might attempt to use a linux runner and see if it reliably fails, or if the failure rate that caused us to use the macos runner was related to tests that we have since ignored.

Failed at the first attempt.

@michaelkaye michaelkaye requested a review from ouchadam May 25, 2022 12:56
@michaelkaye michaelkaye force-pushed the michaelk/sonarqube_fixes branch from 02797a1 to ba109a4 Compare May 25, 2022 12:57
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few remarks

@@ -12,73 +12,57 @@ env:
-Porg.gradle.parallel=false

jobs:
# Build Android Tests
build-android-tests:
name: Build Android Tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just disable this job, in case we need to easily enable it again for some reason?

Copy link
Contributor Author

@michaelkaye michaelkaye May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can leave it in but commented out; but it will be in github history anyway ?

Have left it in as commented out code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks. Yes, still visible in the git history, but a bit more hidden, so probably quite lost.
I was wondering if something like this exists: if: never() to disable a job.

property "sonar.projectName", "Element-Android"
property "sonar.projectKey", "im.vector.app.android"
property "sonar.projectName", "element-android"
property "sonar.projectKey", "vector-im_element-android"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the Sonar URL has changed? If yes, there are 3 lines to update in the file README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have replaced with newly generated links - the existing ones seemed to be legacy versions

@ouchadam
Copy link
Contributor

I'm not sure why these tasks are getting stuck 🤔
2022-05-27T12:52:05,242987086+01:00

@ouchadam ouchadam closed this May 27, 2022
@ouchadam ouchadam reopened this May 27, 2022
@ouchadam
Copy link
Contributor

closed/reopened to see if the actions list will resync

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can be merged.

@ouchadam ouchadam force-pushed the michaelk/sonarqube_fixes branch from e46ea39 to d18e7ad Compare May 30, 2022 09:07
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@michaelkaye
Copy link
Contributor Author

I'm not sure why these tasks are getting stuck thinking 2022-05-27T12:52:05,242987086+01:00

They're stuck because they're an expected result (from the repository required tests) but are not being generated (the tests all run in one go rather than separately)

@michaelkaye
Copy link
Contributor Author

Admin-merging through the missing "build android tests" and "run unit tests" as they're now covered by "runs all tests" which handles both unit and connected tests.

@michaelkaye michaelkaye merged commit 10125f4 into develop Jun 7, 2022
@michaelkaye michaelkaye deleted the michaelk/sonarqube_fixes branch June 7, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants