Skip to content

Commit db82555

Browse files
committed
Add GitHub workflow for checking API compatibility
1 parent 517d3b1 commit db82555

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
- name: Set up JDK 11
12-
uses: actions/setup-java@v2
12+
uses: actions/setup-java@v3
1313
with:
1414
distribution: 'temurin'
1515
java-version: '11'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Check API compatibility
2+
3+
on: pull_request
4+
5+
jobs:
6+
check-api-compatibility:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout old version
11+
uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.event.pull_request.base.sha }}
14+
path: 'gson-old-japicmp'
15+
16+
- name: Checkout new version
17+
uses: actions/checkout@v3
18+
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: '11'
24+
cache: 'maven'
25+
26+
- name: Build old version
27+
run: |
28+
cd gson-old-japicmp
29+
# Set dummy version
30+
mvn --batch-mode org.codehaus.mojo:versions-maven-plugin:2.11.0:set -DnewVersion=JAPICMP-OLD
31+
# Install artifacts with dummy version in local repository; used later by Maven plugin for comparison
32+
mvn --batch-mode install -DskipTests
33+
34+
- name: Check API compatibility
35+
run: |
36+
mvn --batch-mode --fail-at-end package japicmp:cmp -DskipTests
37+
38+
- name: Upload API differences artifacts
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: api-differences
42+
path: |
43+
**/target/japicmp/default-cli.html
44+
**/target/japicmp/default-cli.diff

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2929

3030
# Initializes the CodeQL tools for scanning
3131
- name: Initialize CodeQL

metrics/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
<build>
4545
<pluginManagement>
4646
<plugins>
47+
<plugin>
48+
<groupId>com.github.siom79.japicmp</groupId>
49+
<artifactId>japicmp-maven-plugin</artifactId>
50+
<version>0.15.7</version>
51+
<configuration>
52+
<!-- This module is not supposed to be consumed as library, so no need to check API -->
53+
<skip>true</skip>
54+
</configuration>
55+
</plugin>
4756
<plugin>
4857
<groupId>org.apache.maven.plugins</groupId>
4958
<artifactId>maven-deploy-plugin</artifactId>

pom.xml

+31-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<modules>
2222
<module>gson</module>
23-
<module>extras</module>
23+
<module>extras</module>
2424
<module>metrics</module>
2525
<module>proto</module>
2626
</modules>
@@ -103,6 +103,36 @@
103103
<artifactId>maven-jar-plugin</artifactId>
104104
<version>3.2.2</version>
105105
</plugin>
106+
<!-- Plugin for checking source and binary compatibility; used by GitHub workflow -->
107+
<plugin>
108+
<groupId>com.github.siom79.japicmp</groupId>
109+
<artifactId>japicmp-maven-plugin</artifactId>
110+
<version>0.15.7</version>
111+
<configuration>
112+
<oldVersion>
113+
<dependency>
114+
<groupId>${project.groupId}</groupId>
115+
<artifactId>${project.artifactId}</artifactId>
116+
<!-- This is set by the GitHub workflow -->
117+
<version>JAPICMP-OLD</version>
118+
</dependency>
119+
</oldVersion>
120+
<newVersion>
121+
<file>
122+
<path>${project.build.directory}/${project.build.finalName}.${project.packaging}</path>
123+
</file>
124+
</newVersion>
125+
<parameter>
126+
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
127+
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
128+
<excludes>
129+
<exclude>com.google.gson.internal</exclude>
130+
</excludes>
131+
<onlyModified>true</onlyModified>
132+
<skipXmlReport>true</skipXmlReport>
133+
</parameter>
134+
</configuration>
135+
</plugin>
106136
</plugins>
107137
</pluginManagement>
108138
<plugins>

0 commit comments

Comments
 (0)