parent
806e0dd9d2
commit
124b7fd445
2 changed files with 26 additions and 11 deletions
3
Jenkins/Phabricator-pipeline/Jenkinsfile
vendored
3
Jenkins/Phabricator-pipeline/Jenkinsfile
vendored
|
@ -27,6 +27,7 @@ pipeline {
|
||||||
TARGET_DIR = "/mnt/nfs/results/${MY_BUILD_ID}"
|
TARGET_DIR = "/mnt/nfs/results/${MY_BUILD_ID}"
|
||||||
RESULT_URL = "http://results.llvm-merge-guard.org/${MY_BUILD_ID}"
|
RESULT_URL = "http://results.llvm-merge-guard.org/${MY_BUILD_ID}"
|
||||||
TEST_REPORT = "${WORKSPACE}/build/test-results.xml"
|
TEST_REPORT = "${WORKSPACE}/build/test-results.xml"
|
||||||
|
DIFF_JSON = "${WORKSPACE}/build/diff.json"
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage("build info"){
|
stage("build info"){
|
||||||
|
@ -48,6 +49,8 @@ pipeline {
|
||||||
stage('arc patch') {
|
stage('arc patch') {
|
||||||
steps {
|
steps {
|
||||||
sh "python3 ${SCRIPT_DIR}/phabtalk/apply_patch.py"
|
sh "python3 ${SCRIPT_DIR}/phabtalk/apply_patch.py"
|
||||||
|
// keep a copy of the answer from Phabricator for debugging
|
||||||
|
sh "cp ${DIFF_JSON} ${TARGET_DIR}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('CMake') {
|
stage('CMake') {
|
||||||
|
|
|
@ -16,41 +16,53 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from phabricator import Phabricator
|
from phabricator import Phabricator
|
||||||
|
import json
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
diff_id = os.environ['DIFF_ID']
|
diff_id = os.environ['DIFF_ID']
|
||||||
phid = os.environ['PHID']
|
phid = os.environ['PHID']
|
||||||
conduit_token = os.environ['CONDUIT_TOKEN']
|
conduit_token = os.environ['CONDUIT_TOKEN']
|
||||||
host = os.environ['PHABRICATOR_HOST']
|
host = os.environ['PHABRICATOR_HOST']
|
||||||
|
diff_json_path = os.environ['JSON_DIFF']
|
||||||
|
print('Applying patch for Phabricator diff {}'.format(diff_id))
|
||||||
phab = Phabricator(token=conduit_token, host=host+'/api/')
|
phab = Phabricator(token=conduit_token, host=host+'/api/')
|
||||||
phab.update_interfaces()
|
phab.update_interfaces()
|
||||||
|
|
||||||
_git_checkout(_get_parent_hash(diff_id, phab))
|
_git_checkout(_get_parent_hash(diff_id, phab, diff_json_path))
|
||||||
_apply_patch(diff_id, conduit_token, host)
|
_apply_patch(diff_id, conduit_token, host)
|
||||||
|
|
||||||
|
|
||||||
def _get_parent_hash(diff_id: str, phab:Phabricator) -> str:
|
def _get_parent_hash(diff_id: str, phab: Phabricator, diff_json_path: str) -> str:
|
||||||
diff = phab.differential.getdiff(diff_id=diff_id)
|
diff = phab.differential.getdiff(diff_id=diff_id)
|
||||||
|
# Keep a copy of the Phabricator answer for later usage in a json file
|
||||||
|
with open(diff_json_path,'w') as json_file:
|
||||||
|
json.dump(diff, json_file, sort_keys=True, indent=4)
|
||||||
return diff['sourceControlBaseRevision']
|
return diff['sourceControlBaseRevision']
|
||||||
|
|
||||||
|
|
||||||
def _git_checkout(git_hash:str):
|
def _git_checkout(git_hash: str):
|
||||||
try:
|
try:
|
||||||
print('Checking out git hash {}'.format(hash))
|
print('Checking out git hash {}'.format(git_hash))
|
||||||
subprocess.check_call('git reset --hard {}'.format(git_hash), shell=True)
|
subprocess.check_call('git reset --hard {}'.format(git_hash), stdout=sys.stdout,
|
||||||
|
stderr=sys.stderr, shell=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print('ERROR: checkout failed, using master instead.')
|
print('WARNING: checkout of hash failed, using master branch instead.')
|
||||||
subprocess.check_call('git checkout master', shell=True)
|
subprocess.check_call('git checkout master', stdout=sys.stdout, stderr=sys.stderr,
|
||||||
|
shell=True)
|
||||||
|
print('git checkout completed.')
|
||||||
|
|
||||||
|
|
||||||
def _apply_patch(diff_id: str, conduit_token: str, host: str):
|
def _apply_patch(diff_id: str, conduit_token: str, host: str):
|
||||||
print('running arc path...')
|
print('running arc patch...')
|
||||||
cmd = 'arc patch --nobranch --no-ansi --diff "{}" --nocommit '\
|
cmd = 'arc patch --nobranch --no-ansi --diff "{}" --nocommit '\
|
||||||
'--conduit-token "{}" --conduit-uri "{}"'.format(
|
'--conduit-token "{}" --conduit-uri "{}"'.format(
|
||||||
diff_id, conduit_token, host )
|
diff_id, conduit_token, host )
|
||||||
subprocess.call(cmd, shell=True)
|
try:
|
||||||
|
subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr, shell=True)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print('arc patch failed!')
|
||||||
|
raise
|
||||||
|
print('Patching completed.')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue