Skip to content

Commit

Permalink
Add GitHub workflow for checking API compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Aug 22, 2022
1 parent 517d3b1 commit db82555
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/check-api-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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: Checkout new version
uses: actions/checkout@v3

- 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: Check API compatibility
run: |
mvn --batch-mode --fail-at-end package japicmp:cmp -DskipTests
- name: Upload API differences artifacts
uses: actions/upload-artifact@v3
with:
name: api-differences
path: |
**/target/japicmp/default-cli.html
**/target/japicmp/default-cli.diff
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
32 changes: 31 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<modules>
<module>gson</module>
<module>extras</module>
<module>extras</module>
<module>metrics</module>
<module>proto</module>
</modules>
Expand Down Expand Up @@ -103,6 +103,36 @@
<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>
</parameter>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down

0 comments on commit db82555

Please sign in to comment.