Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: revapi configuration and helper scripts to detect API breaking…
… changes. (#1115) They are run by Inria server spoon3r, triggered by a Github webhook. Close #1156 #1023
- Loading branch information
Showing
6 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Revapi Analysis results | ||
|
||
Old API: **<#list analysis.oldApi.archives as archive>${archive.name}<#sep>, </#list>** | ||
|
||
New API: **<#list analysis.newApi.archives as archive>${archive.name}<#sep>, </#list>** | ||
|
||
Detected changes: ${reports?size}. | ||
|
||
<#list reports as report> | ||
<#list report.differences as diff> | ||
## Change ${report?index+1} | ||
|
||
| Name | Element | | ||
| :---: | :---: | | ||
| Old | ${report.oldElement!"none"} | | ||
| New | ${report.newElement!"none"} | | ||
| Code | ${diff.code} | | ||
| Description | ${diff.description!"none"} | | ||
| Breaking | <#list diff.classification?keys as compat>${compat?lower_case}: ${diff.classification?api.get(compat)?lower_case}<#sep>, </#list> | | ||
</#list> | ||
<#sep> | ||
|
||
</#sep> | ||
</#list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/python | ||
# Retrieve revapi report from target and publish it as PR comment | ||
# This script intends to be launched by a webhooks and take as parameter the hook payload | ||
# see: https://developer.github.com/v3/activity/events/types/#pullrequestevent | ||
|
||
import os, sys, json | ||
from github import * | ||
|
||
revapi_file = "./target/revapi_report.md" | ||
|
||
args = sys.argv | ||
|
||
def usage(): | ||
print "Usage: "+str(args[0])+ " <github_login> <github_token> <PR_payload_path>" | ||
exit(1) | ||
|
||
if (args.__len__() < 4): | ||
print "Error in the args number" | ||
usage() | ||
|
||
if (not(os.path.isfile(revapi_file))): | ||
print "Revapi report file cannot be found at the following location: "+revapi_file | ||
exit(1) | ||
|
||
if (not(os.path.isfile(args[3]))): | ||
print "JSON payload file cannot be found at the following location: "+args[3] | ||
exit(1) | ||
|
||
file_content = "" | ||
with open(revapi_file) as f: | ||
for line in f: | ||
file_content += line | ||
|
||
if (file_content == ""): | ||
print "Revapi report is empty" | ||
exit(1) | ||
|
||
login = args[1] | ||
token = args[2] | ||
|
||
try: | ||
gh = Github(login,token) | ||
except GithubException as e: | ||
print "Error while connecting to github, are you sure about your credentials?" | ||
print e | ||
exit(1) | ||
|
||
payload_string = "" | ||
with open(args[3]) as f: | ||
for line in f: | ||
payload_string += line | ||
|
||
if (payload_string == ""): | ||
print "Payload is empty" | ||
exit(1) | ||
|
||
payloadJSON = json.loads(payload_string) | ||
repo_name = payloadJSON['repository']['full_name'] | ||
pr_id = payloadJSON['pull_request']['number'] | ||
|
||
try: | ||
repo = gh.get_repo(repo_name,True) | ||
|
||
pr = repo.get_pull(pr_id) | ||
pr.create_issue_comment(file_content) | ||
except GithubException as e: | ||
print "Error while creating the PR comment." | ||
print e | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"revapi": { | ||
// use java module | ||
// Doc there: http://revapi.org/modules/revapi-java/extensions/java.html | ||
"java": { | ||
|
||
// filter rules to compare API | ||
"filter": { | ||
|
||
// specify which package to filter | ||
"packages": { | ||
"regex": true, | ||
"include": ["spoon\\..*"], | ||
"exclude": ["spoon\\..*\\.test(\\..*)?"] | ||
}, | ||
|
||
// Exclude all impl classes | ||
"classes": { | ||
"regex": true, | ||
"exclude": [".*Impl.*"] | ||
} | ||
|
||
}, | ||
"reportUsesFor": ["java.missing.newClass", "java.missing.oldClass"] | ||
}, | ||
|
||
"reporter" : { | ||
"text" : { | ||
"minSeverity": "BREAKING", | ||
"output" : "target/revapi_report.md", | ||
"template": "chore/revapi_tpl.ftl", | ||
"append": false | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters