From 086083e7407e9fe52461cae6c59d1a8bfee6bb04 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 9 Jan 2026 15:38:08 -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 0000000..65c13f9 --- /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 31ddf14..75a1f40 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\.db\:maxmind-db\:)\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 8de13c2..70a6169 100644 --- a/pom.xml +++ b/pom.xml @@ -177,6 +177,8 @@ UTF-8 + + 4.0.2 @@ -218,5 +220,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 + + + + + + +