From 7cc2338201feaa8372543ec03c6463b7a7acc6dd Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Fri, 9 Jan 2026 15:38:12 -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 | 19 +++++++++ dev-bin/release.sh | 3 ++ pom.xml | 66 ++++++++++++++++++++++++++++++++ 3 files changed, 88 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..559e473e --- /dev/null +++ b/.github/workflows/api-compat.yml @@ -0,0 +1,19 @@ +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: + 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 eec49397..6cf9b64c 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\.minfraud\:minfraud\:)\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 3a516045..b12ac333 100644 --- a/pom.xml +++ b/pom.xml @@ -277,6 +277,8 @@ UTF-8 + + 4.0.0 @@ -305,4 +307,68 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + 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 + + + + + + + +