Skip to content

Commit 092560e

Browse files
oschwaldclaude
andcommitted
Add API compatibility checking with japicmp
This adds a GitHub Actions workflow that runs on PRs to detect breaking changes in the public API. The check uses japicmp with semantic versioning support, so it will only fail if breaking changes are detected without a major version bump. ENG-3367 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 60e9b5b commit 092560e

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

.github/workflows/api-compat.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: API Compatibility Check
2+
on:
3+
pull_request:
4+
permissions:
5+
contents: read
6+
jobs:
7+
api-compat:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
11+
with:
12+
submodules: true
13+
persist-credentials: false
14+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
15+
with:
16+
distribution: zulu
17+
java-version: 17
18+
cache: maven
19+
- name: Check API Compatibility
20+
run: mvn verify -P api-compat -DskipTests -Dgpg.skip=true

pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@
177177
</build>
178178
<properties>
179179
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
180+
<!-- Baseline version for API compatibility checking. Update after each release. -->
181+
<japicmp.baselineVersion>4.0.2</japicmp.baselineVersion>
180182
</properties>
181183
<profiles>
182184
<profile>
@@ -218,5 +220,66 @@
218220
</plugins>
219221
</build>
220222
</profile>
223+
<profile>
224+
<id>api-compat</id>
225+
<build>
226+
<plugins>
227+
<!-- Download baseline JAR directly from Maven Central for API comparison -->
228+
<plugin>
229+
<groupId>org.apache.maven.plugins</groupId>
230+
<artifactId>maven-antrun-plugin</artifactId>
231+
<version>3.1.0</version>
232+
<executions>
233+
<execution>
234+
<id>download-baseline</id>
235+
<phase>package</phase>
236+
<goals>
237+
<goal>run</goal>
238+
</goals>
239+
<configuration>
240+
<target>
241+
<mkdir dir="${project.build.directory}/japicmp"/>
242+
<get src="https://repo1.maven.org/maven2/com/maxmind/db/maxmind-db/${japicmp.baselineVersion}/maxmind-db-${japicmp.baselineVersion}.jar"
243+
dest="${project.build.directory}/japicmp/baseline.jar"
244+
skipexisting="false"/>
245+
</target>
246+
</configuration>
247+
</execution>
248+
</executions>
249+
</plugin>
250+
<plugin>
251+
<groupId>com.github.siom79.japicmp</groupId>
252+
<artifactId>japicmp-maven-plugin</artifactId>
253+
<version>0.25.1</version>
254+
<configuration>
255+
<oldVersion>
256+
<file>
257+
<path>${project.build.directory}/japicmp/baseline.jar</path>
258+
</file>
259+
</oldVersion>
260+
<newVersion>
261+
<file>
262+
<path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
263+
</file>
264+
</newVersion>
265+
<parameter>
266+
<accessModifier>public</accessModifier>
267+
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
268+
<onlyBinaryIncompatible>false</onlyBinaryIncompatible>
269+
<onlyModified>true</onlyModified>
270+
</parameter>
271+
</configuration>
272+
<executions>
273+
<execution>
274+
<phase>verify</phase>
275+
<goals>
276+
<goal>cmp</goal>
277+
</goals>
278+
</execution>
279+
</executions>
280+
</plugin>
281+
</plugins>
282+
</build>
283+
</profile>
221284
</profiles>
222285
</project>

0 commit comments

Comments
 (0)