Skip to content

Commit

Permalink
Generate compatibility report
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo committed Dec 26, 2023
1 parent e776b2f commit b0a1fa5
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ jobs:
with:
arguments: check --info --scan

# ================================
# COMPATIBILITY REPORT
# ================================
- name: Compatibility report
run: cat ./result-lazy/build/reports/japicmp/report.md >> $GITHUB_STEP_SUMMARY

# ================================
# ANALYZE
# ================================
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
plugins {
alias libs.plugins.spotless apply false
alias libs.plugins.sonarqube apply false
alias libs.plugins.download
alias libs.plugins.nexus.publish
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
description = Lazy Results
group = com.leakyabstractions
version = 0.6.1.0-SNAPSHOT
previousVersion = 0.6.0.0

homepage = https://dev.leakyabstractions.com/result-lazy/
githubId = leakyabstractions/result-lazy
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[versions]
assertj = "3.24.2"
download = "5.5.0"
google-java-format = "1.18.1"
jacoco = "0.8.10"
japicmp = "0.4.2"
junit = "5.10.1"
nexus-publish = "2.0.0-rc-1"
result-api = "0.1.0.2"
Expand All @@ -24,6 +26,8 @@ test-implementation = [ "assertj-core", "junit-jupiter-api", "result-core", "res
test-runtime = [ "junit-jupiter-engine" ]

[plugins]
download = { id = "de.undercouch.download", version.ref = "download" }
japicmp = { id = "me.champeau.gradle.japicmp", version.ref = "japicmp" }
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" }
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
1 change: 1 addition & 0 deletions result-lazy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ apply from: project.file('spotless.gradle')
apply from: project.file('test.gradle')
apply from: project.file('jacoco.gradle')
apply from: project.file('sonarqube.gradle')
apply from: project.file('japicmp.gradle')
apply from: project.file('javadoc.gradle')
apply from: project.file('publish.gradle')

Expand Down
96 changes: 96 additions & 0 deletions result-lazy/japicmp.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("me.champeau.gradle:japicmp-gradle-plugin:${libs.plugins.japicmp.get().version}")
}
}

import me.champeau.gradle.japicmp.JapicmpTask

// Configure compatibility check
tasks.register("japicmp", JapicmpTask) {
final repoBaseUrl = "https://repo1.maven.org/maven2"
final previousUrl = "${repoBaseUrl}/${project.group.replaceAll('\\.', '/')}/${artifactId}/${previousVersion}/${artifactId}-${previousVersion}.jar"
final previousJar = layout.buildDirectory.file('japicmp/previous.jar')
final mdReport = layout.buildDirectory.file('reports/japicmp/report.md')
final textReport = layout.buildDirectory.file('reports/japicmp/report.txt')
final htmlReport = layout.buildDirectory.file('reports/japicmp/report.html')
oldArchives.from(previousJar)
newClasspath.from(tasks.named('jar'))
txtOutputFile = textReport
htmlOutputFile = htmlReport
ignoreMissingClasses = true
onlyModified = true
failOnModification = false
failOnSourceIncompatibility = false
doFirst {
download.run {
src previousUrl
dest previousJar.get().getAsFile()
overwrite false
quiet true
}
}
doLast {
final markdown = textReport.get().getAsFile().text
.replaceAll('NEW (\\w*):', '**New $1**:')
.replaceAll('REMOVED (\\w*):', '**Removed $1**:')
.replaceAll('MODIFIED (\\w*):', '**Modified $1**:')
.replaceAll('UNCHANGED (\\w*):', '**Unchanged $1**:')
.replaceAll('(<?[a-zA-Z]+\\.(\\w+\\.)+\\w*)(<[\\w\\.\\,\\? <>]*>>?)*', '`$1`')
.replaceAll('(\\d+[\\.\\d]*)', '`$1`')
.replaceAll('([_A-Z]*)\\(\\-\\)', '<del>$1</del>')
.replaceAll('([_A-Z]*)\\(\\+\\)', '<ins>$1</ins>')
.replace([' of against ' : " of `$version` against `$previousVersion`.\n",
'\nNo changes.' : '- :information_source: No changes.',
'<-' : ' :arrow_backward: ',
'===!' : ':information_source::bangbang:',
'+++!' : ':new::bangbang:',
'---!' : ':wastebasket::bangbang:',
'***!' : ':warning::bangbang:',
'===*' : ':information_source::exclamation:',
'+++*' : ':new::exclamation:',
'---*' : ':wastebasket::exclamation:',
'****' : ':warning::exclamation:',
'=== ' : ':information_source:',
'+++ ' : ':new:',
'--- ' : ':wastebasket:',
'*** ' : ':warning:',
'n.a.' : ':question:',
'CLASS FILE FORMAT VERSION:': '**Class file format version**:',
'GENERIC TEMPLATES:' : '**Generic templates**:',
'SUPERCLASS' : 'superclass',
'INTERFACE' : 'interface',
'EXCEPTION' : 'exception',
'CLASS' : 'class',
'ANNOTATION' : 'annotation',
'METHOD' : 'method',
'FIELD' : 'field',
'PUBLIC' : 'public',
'PROTECTED' : 'protected',
'PRIVATE' : 'private',
'ABSTRACT' : 'abstract',
'FINAL' : 'final',
'STATIC' : 'static',
'TRANSIENT' : 'transient',
'\t\t\t' : ' - ',
'\t\t' : ' - ',
'\t' : '- ',
])
mdReport.get().getAsFile().text = "\n### Compatibility Report\n\n" + markdown.replace('\n:', '\n\n#### :')
textReport.get().getAsFile().text = textReport.get().getAsFile().text
.replace(' of against ', " of $version against $previousVersion\n")
htmlReport.get().getAsFile().text = htmlReport.get().getAsFile().text.replace([
'<td>Old:</td><td>n.a.</td>': "<td>Old:</td><td>$previousVersion</td>",
'<td>New:</td><td>n.a.' : "<td>New:</td><td>$version</td>"
])
logger.quiet(textReport.get().getAsFile().text)
}
}

check.finalizedBy japicmp

0 comments on commit b0a1fa5

Please sign in to comment.