1
0
Fork 0

Merge branch 'master' of ssh://github.com/google/llvm-premerge-checks

This commit is contained in:
Christian Kühnel 2020-01-22 10:39:47 +00:00
commit 4bb77853ca
4 changed files with 26 additions and 9 deletions

View file

@ -86,6 +86,18 @@ pipeline {
echo e.toString()
}
}
/* To test the windows builds:
If the linux compile succeed, trigger a windows build.
This does NOT give any feedback on Phabricator on the
windows build.
Fire & Forget: Do not wait for the job to finish,
ingore the results
*/
build job: 'amd64_windows_vs2017', propagate: false, wait: false, parameters: [
[$class: 'StringParameterValue', name: 'DIFF_ID', value: "$DIFF_ID"],
[$class: 'StringParameterValue', name: 'PHID', value: "$PHID"],
]
}
}
stage('ninja check-all') {

View file

@ -126,7 +126,7 @@ Invoke-WebRequest -uri 'https://raw.githubusercontent.com/google/llvm-premerge-c
## Testing scripts locally
Build and run agent docker image `sudo build_run.sh agent-debian-testing-clang8-ssd /bin/bash`.
Build and run agent docker image `sudo ./containers/build_run.sh agent-debian-testing-clang8-ssd /bin/bash`.
Within a container set environment variables similar to [pipeline](https://github.com/google/llvm-premerge-checks/blob/master/Jenkins/Phabricator-pipeline/Jenkinsfile).

View file

@ -22,7 +22,7 @@ echo "Running linters... ====================================="
cd "${WORKSPACE}"
# Let clang format apply patches --diff doesn't produces results in the format we want.
git-clang-format --style=llvm
git-clang-format
set +e
git diff -U0 --exit-code > "${TARGET_DIR}"/clang-format.patch
STATUS="${PIPESTATUS[0]}"

View file

@ -74,11 +74,12 @@ class ApplyPatch:
"""
try:
print('Checking out master...')
self.repo.git.checkout('master')
revision_id, dependencies, base_revision = self._get_dependencies()
print('Checking out {}...'.format(base_revision))
self.repo.git.checkout(base_revision)
print('Revision is {}'.format(self.repo.head.commit.hexsha))
print('Cleanup...')
self.repo.git.clean('-fdx')
revision_id, dependencies = self._get_dependencies()
print('Analyzing {}'.format(diff_to_str(revision_id)))
if len(dependencies) > 0:
print('This diff depends on: {}'.format(diff_list_to_str(dependencies)))
@ -116,10 +117,14 @@ class ApplyPatch:
return self.phab.differential.query(phids=phids)
def _get_dependencies(self) -> List[int]:
def _get_dependencies(self) -> Tuple[int,List[int],str]:
"""Get all dependencies for the diff."""
revision_id = int(self._get_diff(self.diff_id).revisionID)
diff = self._get_diff(self.diff_id)
revision_id = int(diff.revisionID)
revision = self._get_revision(revision_id)
base_revision = diff['sourceControlBaseRevision']
if base_revision is None or len(base_revision) == 0:
base_revision = 'master'
dependency_ids = revision['auxiliary']['phabricator:depends-on']
revisions = self._get_revisions(phids=dependency_ids)
diff_ids = [int(rev['id']) for rev in revisions]
@ -127,13 +132,13 @@ class ApplyPatch:
# so we reverse the order before returning the list, so that they
# can be applied in this order
diff_ids.reverse()
return revision_id, diff_ids
return revision_id, diff_ids, base_revision
def _apply_diff(self, diff_id: int, revision_id: int):
"""Download and apply a diff to the local working copy."""
print('Applying diff {} for revision {}...'.format(diff_id, diff_to_str(revision_id)))
diff = self.phab.differential.getrawdiff(diffID=diff_id).response
proc = subprocess.run('patch -p1', input=diff, shell=True, text=True,
proc = subprocess.run('git apply', input=diff, shell=True, text=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if proc.returncode != 0:
raise Exception('Applying patch failed:\n{}'.format(proc.stdout + proc.stderr))