From c2d0cede654de8d928ec5c17bbffea00e25b7e31 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sun, 28 Aug 2022 19:51:31 +0200 Subject: [PATCH] Add GitHub workflow for checking API compatibility (#2182) --- .github/workflows/build.yml | 4 +- .github/workflows/check-api-compatibility.yml | 50 +++++++++++++++++++ .github/workflows/codeql-analysis.yml | 2 +- metrics/pom.xml | 9 ++++ pom.xml | 33 +++++++++++- 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check-api-compatibility.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0008892e..cf07103b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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' diff --git a/.github/workflows/check-api-compatibility.yml b/.github/workflows/check-api-compatibility.yml new file mode 100644 index 00000000..aa70782b --- /dev/null +++ b/.github/workflows/check-api-compatibility.yml @@ -0,0 +1,50 @@ +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: 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: Checkout new version + uses: actions/checkout@v3 + + - name: Check API compatibility + id: check-compatibility + run: | + mvn --batch-mode --fail-at-end package japicmp:cmp -DskipTests + + - name: Upload API differences artifacts + uses: actions/upload-artifact@v3 + # Run on workflow success (in that case differences report might include added methods and classes) + # or when API compatibility check failed + if: success() || ( failure() && steps.check-compatibility.outcome == 'failure' ) + with: + name: api-differences + path: | + **/japicmp/default-cli.html + **/japicmp/default-cli.diff + # Plugin should always have created report files (though they might be empty) + if-no-files-found: error diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 17ed734a..10df305f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/metrics/pom.xml b/metrics/pom.xml index 4b41ac62..58d43bc4 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -44,6 +44,15 @@ + + com.github.siom79.japicmp + japicmp-maven-plugin + 0.15.7 + + + true + + org.apache.maven.plugins maven-deploy-plugin diff --git a/pom.xml b/pom.xml index 93da69b6..6d271b01 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ gson - extras + extras metrics proto @@ -111,6 +111,37 @@ maven-jar-plugin 3.2.2 + + + com.github.siom79.japicmp + japicmp-maven-plugin + 0.15.7 + + + + ${project.groupId} + ${project.artifactId} + + JAPICMP-OLD + + + + + ${project.build.directory}/${project.build.finalName}.${project.packaging} + + + + true + true + + com.google.gson.internal + + true + true + true + + +