From 7ce169519b1720ea03bea50383fd5f834fe115c9 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 9 Jan 2026 15:38:10 -0800 Subject: [PATCH] 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 --- .github/workflows/api-compat.yml | 20 ++++++++++ dev-bin/release.sh | 3 ++ pom.xml | 63 ++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 .github/workflows/api-compat.yml diff --git a/.github/workflows/api-compat.yml b/.github/workflows/api-compat.yml new file mode 100644 index 00000000..65c13f99 --- /dev/null +++ b/.github/workflows/api-compat.yml @@ -0,0 +1,20 @@ +name: API Compatibility Check +on: + pull_request: +permissions: + contents: read +jobs: + api-compat: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + submodules: true + persist-credentials: false + - uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 + with: + distribution: zulu + java-version: 17 + cache: maven + - name: Check API Compatibility + run: mvn verify -P api-compat -DskipTests -Dgpg.skip=true diff --git a/dev-bin/release.sh b/dev-bin/release.sh index 65f7f62d..1052094b 100755 --- a/dev-bin/release.sh +++ b/dev-bin/release.sh @@ -134,6 +134,9 @@ mvn versions:set -DnewVersion="$version" perl -pi -e "s/(?<=)[^<]*/$version/" README.md perl -pi -e "s/(?<=com\.maxmind\.geoip2\:geoip2\:)\d+\.\d+\.\d+([\w\-]+)?/$version/" README.md +# Update japicmp.baselineVersion for API compatibility checking +perl -pi -e "s/()[^<]*(<\/japicmp\.baselineVersion>)/\${1}$version\${2}/" pom.xml + cat README.md >>$page git diff diff --git a/pom.xml b/pom.xml index b6926848..09807306 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,8 @@ UTF-8 + + 5.0.2 @@ -304,5 +306,66 @@ + + api-compat + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + download-baseline + package + + run + + + + + + + + + + + + com.github.siom79.japicmp + japicmp-maven-plugin + 0.25.1 + + + + ${project.build.directory}/japicmp/baseline.jar + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + + + + public + true + false + true + + + + + verify + + cmp + + + + + + +