Add GitHub workflow for checking API compatibility (#2182)

This commit is contained in:
Marcono1234 2022-08-28 19:51:31 +02:00 committed by GitHub
parent f7a164d98b
commit c2d0cede65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 4 deletions

View File

@ -7,9 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

View File

@ -0,0 +1,50 @@
name: Check API compatibility
on: pull_request
jobs:
check-api-compatibility:
runs-on: ubuntu-latest
steps:
- name: Checkout old version
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.sha }}
path: 'gson-old-japicmp'
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Build old version
run: |
cd gson-old-japicmp
# Set dummy version
mvn --batch-mode org.codehaus.mojo:versions-maven-plugin:2.11.0:set -DnewVersion=JAPICMP-OLD
# Install artifacts with dummy version in local repository; used later by Maven plugin for comparison
mvn --batch-mode install -DskipTests
- name: Checkout new version
uses: actions/checkout@v3
- name: Check API compatibility
id: check-compatibility
run: |
mvn --batch-mode --fail-at-end package japicmp:cmp -DskipTests
- name: Upload API differences artifacts
uses: actions/upload-artifact@v3
# Run on workflow success (in that case differences report might include added methods and classes)
# or when API compatibility check failed
if: success() || ( failure() && steps.check-compatibility.outcome == 'failure' )
with:
name: api-differences
path: |
**/japicmp/default-cli.html
**/japicmp/default-cli.diff
# Plugin should always have created report files (though they might be empty)
if-no-files-found: error

View File

@ -25,7 +25,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning
- name: Initialize CodeQL

View File

@ -44,6 +44,15 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.15.7</version>
<configuration>
<!-- This module is not supposed to be consumed as library, so no need to check API -->
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>

33
pom.xml
View File

@ -20,7 +20,7 @@
<modules>
<module>gson</module>
<module>extras</module>
<module>extras</module>
<module>metrics</module>
<module>proto</module>
</modules>
@ -111,6 +111,37 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<!-- Plugin for checking source and binary compatibility; used by GitHub workflow -->
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.15.7</version>
<configuration>
<oldVersion>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<!-- This is set by the GitHub workflow -->
<version>JAPICMP-OLD</version>
</dependency>
</oldVersion>
<newVersion>
<file>
<path>${project.build.directory}/${project.build.finalName}.${project.packaging}</path>
</file>
</newVersion>
<parameter>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<excludes>
<exclude>com.google.gson.internal</exclude>
</excludes>
<onlyModified>true</onlyModified>
<skipXmlReport>true</skipXmlReport>
<reportOnlyFilename>true</reportOnlyFilename>
</parameter>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>