Skip to content

Commit

Permalink
Detect breaking changes
Browse files Browse the repository at this point in the history
Adds a gradle task and github action to check for breaking changes made
to the APIs in server by running comparison against most resent snapshot
build on sonotype maven repository.

Uses japicmp to perform the comparison against the jar files, learn
more https://siom79.github.io/japicmp/

- Related opensearch-project#8982

Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Aug 1, 2023
1 parent 99f28cb commit e7dc3e0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/detect-breaking-change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Detect Breaking Changes"
on: [push, pull_request]
jobs:
detect-breaking-change:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 17

- uses: actions/checkout@v2

- uses: gradle/gradle-build-action@v2
with:
arguments: japicmp
build-root-directory: server

- if: failure()
run: cat server/build/reports/japi.txt
36 changes: 36 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ plugins {
id('opensearch.publish')
id('opensearch.internal-cluster-test')
id('opensearch.optional-dependencies')
id('me.champeau.gradle.japicmp') version '0.4.2'
}

publishing {
Expand Down Expand Up @@ -408,3 +409,38 @@ tasks.named("sourcesJar").configure {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}

/** Compares the current build against a snapshot build */
tasks.register("japicmp", me.champeau.gradle.japicmp.JapicmpTask) {
oldClasspath.from(files("${buildDir}/snapshot/opensearch-${version}.jar"))
newClasspath.from(tasks.named('jar'))
onlyModified = true
failOnModification = true
ignoreMissingClasses = true
txtOutputFile = layout.buildDirectory.file("reports/japi.txt")
dependsOn downloadSnapshot
}

/** Downloads latest snapshot from maven repository */
tasks.register("downloadSnapshot", Copy) {
def mavenSnapshotRepoUrl = "https://aws.oss.sonatype.org/content/repositories/snapshots/"
def groupId = "org.opensearch"
def artifactId = "opensearch"

repositories {
maven {
url mavenSnapshotRepoUrl
}
}

configurations {
snapshotArtifact
}

dependencies {
snapshotArtifact("${groupId}:${artifactId}:${version}:")
}

from configurations.snapshotArtifact
into "$buildDir/snapshot"
}

0 comments on commit e7dc3e0

Please sign in to comment.