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

chore: add sonarcloud reporting for aggregate test coverage in gax, api-common and showcase #1482

Merged
merged 46 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d7c919a
chore: add aggregate test coverage collection for showcase and gax
mpeddada1 Mar 2, 2023
135022c
add profile to collect test coverage
mpeddada1 Mar 2, 2023
d2be02f
add fmt-maven-plugin
mpeddada1 Mar 2, 2023
22cda89
add maven compiler version property
mpeddada1 Mar 2, 2023
cd0de15
skip fmt
mpeddada1 Mar 2, 2023
cddb9f2
add version to fmt plugin
mpeddada1 Mar 2, 2023
c116da1
add jar plugin to showcase
mpeddada1 Mar 2, 2023
208cfff
add jar plugin to gapic-showcase
mpeddada1 Mar 2, 2023
02ef0cb
empty commit to rerun builds
mpeddada1 Mar 2, 2023
7f720b8
empty commit
mpeddada1 Mar 3, 2023
68557fe
fix syntax in dep declaration
mpeddada1 Mar 3, 2023
57ddf93
remove spaces
mpeddada1 Mar 3, 2023
fcc5257
add README for coverage-report module
mpeddada1 Mar 6, 2023
45a0987
replace monorepo with repsitory in README
mpeddada1 Mar 6, 2023
47cf349
add profile to specify modules
mpeddada1 Mar 10, 2023
e61d6ea
chore: add sonarcloud reporting for showcase test coverage
mpeddada1 Mar 13, 2023
83f085d
Merge branch 'main' into sonar-coverage
mpeddada1 Mar 13, 2023
d4ba320
fix yaml syntax
mpeddada1 Mar 13, 2023
b856e7f
Merge branch 'sonar-coverage' of github.com:googleapis/gapic-generato…
mpeddada1 Mar 13, 2023
f574ec8
fix spacing
mpeddada1 Mar 13, 2023
61bb283
comment out previous step
mpeddada1 Mar 13, 2023
6c54fbe
avoid calling clean in mvn command
mpeddada1 Mar 13, 2023
644edc8
modify syntax:
mpeddada1 Mar 13, 2023
afcf7b1
omit yaml formatting
mpeddada1 Mar 13, 2023
cff1fa4
install and run showcase server
mpeddada1 Mar 13, 2023
b9db44f
set SHOWCASE VERSION env variable
mpeddada1 Mar 13, 2023
75a51ec
use forked repo for verification
mpeddada1 Mar 13, 2023
6972c9f
undo change
mpeddada1 Mar 13, 2023
7aab6ca
uncomment previous build step and temporarily address syntax error
mpeddada1 Mar 14, 2023
34869ff
omit mvn clean
mpeddada1 Mar 14, 2023
0d342c8
add mvn clean install
mpeddada1 Mar 14, 2023
5aa2013
call mvn install
mpeddada1 Mar 14, 2023
36d1633
remove mvn clean install
mpeddada1 Mar 14, 2023
6f7ead4
comment out unit test job
mpeddada1 Mar 14, 2023
63cec27
update SNAPSHOT versions
mpeddada1 Mar 14, 2023
efc6ecc
add clean
mpeddada1 Mar 14, 2023
9d676c0
add unit test step
mpeddada1 Mar 14, 2023
03fd1b9
fix syntax
mpeddada1 Mar 14, 2023
74fbf20
fix syntax
mpeddada1 Mar 14, 2023
7e4202a
rebase with main
mpeddada1 Mar 16, 2023
6264511
clean up pom.xml
mpeddada1 Mar 16, 2023
5a662a1
add api-common coverage
mpeddada1 Mar 21, 2023
1ab860b
fix pom syntax
mpeddada1 Mar 21, 2023
bcd8299
update screenshots in README
mpeddada1 Mar 21, 2023
27afb2e
fix renovate version comments
mpeddada1 Mar 21, 2023
4b60a61
Merge branch 'sonar-coverage' of github.com:googleapis/gapic-generato…
mpeddada1 Mar 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: SonarCloud Build
env:
Copy link
Collaborator

@blakeli0 blakeli0 Mar 20, 2023

Choose a reason for hiding this comment

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

We have showcase version here and in ci-maven.yaml as well, I'm not very familiar with Github actions, is it possible to configure a shared SHOWCASE_VERSION?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is! According to the docs, shared variables can be created by doing Settings > secrets and variables > Actions > Manage environments. However, I'm not able to see the Settings tab for this repo so I think it requires some special permissions?

Copy link
Member

Choose a reason for hiding this comment

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

If we are going to have hermetic builds, the version needs to be stored in source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thank you. Managing the variables in Settings may not be the best solution in that case. I'm inclined to keep the duplicate showcase_versions until an alternate solution becomes available in favor of making the builds self-contained and maintaining visibility into the showcase version we are testing against. Open to hearing more thoughts on this though.

SHOWCASE_VERSION: 0.25.0
on:
push:
branches:
Expand Down Expand Up @@ -41,3 +43,39 @@ jobs:
-Dsonar.organization=googleapis \
-Dsonar.host.url=https://sonarcloud.io

- name: Install showcase server
run: |
sudo mkdir -p /usr/src/showcase
sudo chown -R ${USER} /usr/src/
curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz
cd /usr/src/showcase/
tar -xf showcase-*
./gapic-showcase run &
cd -
- name: Build and analyze Showcase Integration Tests Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn -B clean verify -Dcheckstyle.skip \
-DskipUnitTests \
-Penable-integration-tests \
-DenableTestCoverage \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=googleapis_gapic-generator-java_integration_tests \
-Dsonar.organization=googleapis \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.projectName=java_showcase_integration_tests
- name: Build and analyze Showcase Unit Tests Coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn -B clean test -Dcheckstyle.skip \
-DenableTestCoverage \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=googleapis_gapic-generator-java_unit_tests \
-Dsonar.organization=googleapis \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.projectName=java_showcase_unit_tests
mpeddada1 marked this conversation as resolved.
Show resolved Hide resolved

15 changes: 15 additions & 0 deletions api-common-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,19 @@
</plugin>
</plugins>
</build>

<!-- Skip api-common when analyzing showcase test coverage on SonarCloud -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we skip api-common? It's also a handwritten runtime dependency of client libraries, same as gax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the test coverage of showcase is restricted to the showcase and gax modules because of how heavily dependent GAPIC clients are on gax (which contains a lot of the transport logic). In terms of development, a feature or a bug fix oftentimes has a corresponding change in gax.

However, an argument can be made in support of api-common being included. The coverage report for showcase is to provide insights into how much of the core code the showcase tests are exercising, observe coverage drop/rise as we continue developing and also help us determine if it is safe to replace the existing handwritten integration tests. Given this purpose, do we think having a combined test coverage of api-common, gax-java and showcase tells a more complete story?

cc/ @burkedavison

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me. If it's part of the 'platform runtime', let's include it. In the future this may also include java-core if we have a handwritten layer on top of showcase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! Will look into adding this in as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, updated the README and PR description as well.

<profiles>
<profile>
<id>showcase-sonar-analysis</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
</profile>
</profiles>
</project>
6 changes: 3 additions & 3 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
<version>2.23.4-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
<version>2.23.4-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<version>0.108.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
<version>0.108.4-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
</dependencies>

Expand Down
1 change: 0 additions & 1 deletion gapic-generator-java-pom-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
</build>
</profile>
</profiles>

<repositories>
<repository>
<id>google-maven-central-copy</id>
Expand Down
13 changes: 13 additions & 0 deletions gapic-generator-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@
</plugins>
</build>
</profile>

<!-- Skip gapic-generator-java when analyzing showcase test coverage on SonarCloud -->
<profile>
<id>showcase-sonar-analysis</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
</profile>
</profiles>

<build>
Expand Down
15 changes: 15 additions & 0 deletions java-common-protos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,19 @@
</plugin>
</plugins>
</reporting>

<!-- Skip google-common-protos when analyzing showcase test coverage on SonarCloud -->
<profiles>
<profile>
<id>showcase-sonar-analysis</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
</profile>
</profiles>
</project>
15 changes: 15 additions & 0 deletions java-iam/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,19 @@
</plugin>
</plugins>
</reporting>

<!-- Skip java-iam when analyzing showcase test coverage on SonarCloud -->
<profiles>
<profile>
<id>showcase-sonar-analysis</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<properties>
<sonar.skip>true</sonar.skip>
</properties>
</profile>
</profiles>
</project>
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<module>showcase</module>
<module>coverage-report</module>
</modules>
<properties>
<sonar.coverage.jacoco.xmlReportPaths>${maven.multiModuleProjectDirectory}/coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
</profile>
</profiles>

Expand Down