Skip to content

Commit

Permalink
Introducing Revapi into build system (#6381)
Browse files Browse the repository at this point in the history
* Introducing Revapi into build system. Currently it is configured to not fail the build (because it is comparing the 1.0.0-preview.N releases rather than 1.0.0). Once this versioning issue is fixed, we should flip this to fail the build.

* Add revapi versions to external-dependencies.txt

* Ignore packages that are under implementation.

* Fail build if there are API inconsistencies.

* Add versionFormat string to compare.

* Skip revapi in azure-core-test

* Use resource file in sdk-build-tools instead of having to resolve relative path based on pom.

* Revapi not needed for aggregate report.
  • Loading branch information
JonathanGiles authored and conniey committed Dec 7, 2019
1 parent a7775d6 commit fdf67a2
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 9 deletions.
89 changes: 89 additions & 0 deletions eng/code-quality-reports/src/main/resources/revapi/revapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[
{
"extension": "revapi.java",
"configuration": {
"filter": {
"packages": {
"regex": true,
"exclude": [ "com\\.azure\\..+\\.implementation(\\..+)?" ]
}
}
}
},
{
"extension": "revapi.semver.ignore",
"configuration": {
"enabled": true,
"versionIncreaseAllows": {
"major": "breaking",
"minor": "nonBreaking",
"patch": "equivalent"
},
"passThroughDifferences": [ "java.class.nonPublicPartOfAPI" ]
}
},
{
"extension": "revapi.ignore",
"configuration": [
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class org\\.reactivestreams\\.Publisher",
"justification": "This class is part of the reactive streams initiative in Java."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class reactor\\.util\\.context\\.Context",
"justification": "Reactor is allowed in the public API. Since we don't analyze dependencies, these show up as being unresolved."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class com\\.fasterxml\\.jackson\\.databind\\.ObjectMapper",
"exampleUseChainInNewApi": ".*com\\.azure\\.core\\.util\\.serializer\\.JacksonAdapter.*",
"justification": "We allow this in com.azure.core.util.serializer.JacksonAdapter."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class reactor\\.core(\\..+)?",
"justification": "Reactor is allowed in the public API. Since we don't analyze dependencies, these show up as being unresolved."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class com\\.azure\\.core(?!\\.implementation)(\\..+)?",
"justification": "com.azure.core.* classes are allowed in the public API. Since we don't analyze dependencies, these show up as being unresolved."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class (io|reactor)\\.netty\\..+",
"exampleUseChainInOldApi": ".*com\\.azure\\.core\\.http\\.netty\\.NettyAsyncHttpClientBuilder.*",
"justification": "Dependencies are not checked. io.netty and reactor.netty are allowed in azure-core-http-netty."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class okhttp3\\..+",
"exampleUseChainInOldApi": ".*com\\.azure\\.core\\.http\\.okhttp\\.OkHttpAsyncHttpClientBuilder.*",
"justification": "Dependencies are not checked. okhttp3 is allowed in azure-core-http-okhttp."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class com\\.azure\\.storage\\..+",
"exampleUseChainInOldApi": ".*com\\.azure\\.storage\\..*",
"justification": "Dependencies are not checked. azure-storage-common is used in the storage modules."
},
{
"regex": true,
"code": "java\\.missing\\.(oldClass|newClass)",
"new": "missing\\-class ((com\\.azure\\.messaging\\.eventhubs\\.models\\..+)|(com\\.azure\\.storage\\.blob\\.BlobContainerAsyncClient))",
"exampleUseChainInNewApi": ".*com\\.azure\\.messaging\\.eventhubs\\.checkpointstore\\.blob\\..*",
"justification": "azure-messaging-eventhubs and azure-storage-blob are used in the Event Hubs checkpoint store."
}
]
}
]
12 changes: 6 additions & 6 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ jobs:

- ${{ each artifact in parameters.Artifacts }}:
- script: |
python3 --version
python3 --version
python3 eng/versioning/set_versions.py --update-type all --build-type client --build-qualifier dev.$(Build.BuildNumber) --artifact-id ${{artifact.name}}
python3 eng/versioning/set_versions.py --update-type all --build-type data --build-qualifier dev.$(Build.BuildNumber) --artifact-id ${{artifact.name}}
condition: eq(variables['SetDevVersion'],'true')
displayName: Append dev package version suffix for ${{artifact.name}}
- script: |
python3 --version
python3 eng/versioning/update_versions.py --update-type all --build-type client
Expand Down Expand Up @@ -157,17 +157,17 @@ jobs:
displayName: 'Install all client libraries (for SpotBugs analysis)'
inputs:
mavenPomFile: pom.client.xml
options: '$(DefaultOptions) -DskipTests -Dgpg.skip -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Dspotbugs.skip=true -Dverify-readme'
options: '$(DefaultOptions) -DskipTests -Dgpg.skip -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -Dspotbugs.skip=true -Drevapi.skip=true -Dverify-readme'
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
goals: 'install'

# Run SpotBugs, CheckStyle and JavaDoc tools to ensure high code quality - these will fail the build if issues are found
# Run SpotBugs, CheckStyle, Revapi, and JavaDoc tools to ensure high code quality - these will fail the build if issues are found
- task: Maven@3
displayName: 'Run SpotBugs, CheckStyle, and JavaDoc'
displayName: 'Run SpotBugs, CheckStyle, Revapi, and JavaDoc'
inputs:
mavenPomFile: pom.client.xml
options: '-DskipTests -Dgpg.skip'
Expand All @@ -176,7 +176,7 @@ jobs:
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
goals: 'spotbugs:check checkstyle:checkstyle-aggregate javadoc:aggregate'
goals: 'spotbugs:check checkstyle:checkstyle-aggregate revapi:check javadoc:aggregate'

# We run a separate SpotBugs aggregate report step here to roll-up all the issues identified per-module
- task: Maven@3
Expand Down
9 changes: 9 additions & 0 deletions eng/spotbugs-aggregate-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@
</configuration>
</plugin>

<!-- This is not a module we need to run revapi on because there are no APIs shipped here. -->
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<version>0.11.2</version> <!-- {x-version-update;org.revapi:revapi-maven-plugin;external_dependency} -->
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
7 changes: 5 additions & 2 deletions eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ org.eclipse.jetty:jetty-server;9.4.11.v20180605
org.hamcrest:hamcrest-all;1.3
org.hamcrest:hamcrest-library;2.2
# https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea
# use 5.4.2 now since Version 5.5.2 as of 11.2019 fails to discover tests
# use 5.4.2 now since Version 5.5.2 as of 11.2019 fails to discover tests
# https://youtrack.jetbrains.com/issue/IDEA-223700
# org.junit:junit-bom;5.4.2 is a pom file that will add its dependencyManagement section to parent pom's which
# effectively means that each dependency needs to be listed here.
Expand Down Expand Up @@ -144,9 +144,12 @@ org.jacoco:jacoco-maven-plugin;0.8.4
org.jacoco:org.jacoco.agent;0.8.4
org.mockito:mockito-core;3.0.0
org.nanohttpd:nanohttpd;2.3.1
org.revapi:revapi-java;0.20.0
org.revapi:revapi-maven-plugin;0.11.2


# External Dependency Exceptions
# This section is for external dependencies whose versions were different than
# This section is for external dependencies whose versions were different than
# what was defined in the parent pom.
# Format;
# <some unique identifier, area name preferred>_groupId:artifactId;dependency-version
Expand Down
68 changes: 67 additions & 1 deletion pom.client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@
</execution>
</executions>
</plugin>

<!-- Performs test coverage analysis -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -340,6 +342,42 @@
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version> <!-- {x-version-update;org.codehaus.mojo:build-helper-maven-plugin;external_dependency} -->
</plugin>

<!-- Checks public surface area for breaking changes. -->
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<version>0.11.2</version> <!-- {x-version-update;org.revapi:revapi-maven-plugin;external_dependency} -->
<configuration>
<analysisConfigurationFiles>
<configurationFile>
<resource>revapi/revapi.json</resource>
</configurationFile>
</analysisConfigurationFiles>
<versionFormat>^\d+\.\d+\.\d+$</versionFormat>
<checkDependencies>false</checkDependencies>
<failBuildOnProblemsFound>true</failBuildOnProblemsFound>
</configuration>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>sdk-build-tools</artifactId>
<version>1.0.0</version> <!-- {x-version-update;com.azure:sdk-build-tools;external_dependency} -->
</dependency>
<dependency>
<groupId>org.revapi</groupId>
<artifactId>revapi-java</artifactId>
<version>0.20.0</version> <!-- {x-version-update;org.revapi:revapi-java;external_dependency} -->
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
Expand Down Expand Up @@ -515,7 +553,6 @@
</plugin>
</plugins>
</pluginManagement>

</build>

<dependencies>
Expand Down Expand Up @@ -645,8 +682,37 @@
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<version>0.11.2</version> <!-- {x-version-update;org.revapi:revapi-maven-plugin;external_dependency} -->
<configuration>
<analysisConfigurationFiles>
<configurationFile>
<resource>revapi/revapi.json</resource>
</configurationFile>
</analysisConfigurationFiles>
<versionFormat>^\d+\.\d+\.\d+$</versionFormat>
<checkDependencies>false</checkDependencies>
<failBuildOnProblemsFound>true</failBuildOnProblemsFound>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
<reportSet>
<inherited>false</inherited>
<reports>
<report>report-aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

<profiles>

<!-- Skip module-info.java on Java 8 -->
Expand Down
10 changes: 10 additions & 0 deletions sdk/core/azure-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@
</execution>
</executions>
</plugin>

<!-- This is not a module we want/expect external customers to consume. Skip breaking API checks. -->
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<version>0.11.2</version> <!-- {x-version-update;org.revapi:revapi-maven-plugin;external_dependency} -->
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit fdf67a2

Please sign in to comment.