diff --git a/.travis.yml b/.travis.yml index 77e7395118c..1e7786a0104 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ jdk: install: - # download deps with maven - mvn dependency:resolve - - pip install --user CommonMark requests + - pip install --user CommonMark requests pygithub - sudo apt-get install xmlstarlet script: | diff --git a/chore/revapi_tpl.ftl b/chore/revapi_tpl.ftl new file mode 100644 index 00000000000..627cb7b09f7 --- /dev/null +++ b/chore/revapi_tpl.ftl @@ -0,0 +1,24 @@ +# Revapi Analysis results + +Old API: **<#list analysis.oldApi.archives as archive>${archive.name}<#sep>, ** + +New API: **<#list analysis.newApi.archives as archive>${archive.name}<#sep>, ** + +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>, | + +<#sep> + + + \ No newline at end of file diff --git a/chore/revapy.py b/chore/revapy.py new file mode 100644 index 00000000000..cd195c4493a --- /dev/null +++ b/chore/revapy.py @@ -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])+ " " + 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) diff --git a/pom.xml b/pom.xml index 1dce23aa4b0..ec55bf84ab8 100644 --- a/pom.xml +++ b/pom.xml @@ -177,6 +177,11 @@ Maven Repository for JDT Compiler release http://spoon.gforge.inria.fr/repositories/releases + + gforge.inria.fr-snapshot + Maven Repository for Spoon Snapshots + http://spoon.gforge.inria.fr/repositories/snapshots + @@ -482,8 +487,35 @@ + + + org.revapi + revapi-maven-plugin + + 0.8.1 + + + org.revapi + revapi-java + 0.13.1 + + + org.revapi + revapi-reporter-text + 0.7.0 + + + + false + LATEST + + ${project.basedir}/revapi.json + + + +