Merge branch 'master' of ssh://github.com/google/llvm-premerge-checks
This commit is contained in:
commit
4bb77853ca
4 changed files with 26 additions and 9 deletions
12
Jenkins/Phabricator-pipeline/Jenkinsfile
vendored
12
Jenkins/Phabricator-pipeline/Jenkinsfile
vendored
|
@ -86,6 +86,18 @@ pipeline {
|
||||||
echo e.toString()
|
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') {
|
stage('ninja check-all') {
|
||||||
|
|
|
@ -126,7 +126,7 @@ Invoke-WebRequest -uri 'https://raw.githubusercontent.com/google/llvm-premerge-c
|
||||||
|
|
||||||
## Testing scripts locally
|
## 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).
|
Within a container set environment variables similar to [pipeline](https://github.com/google/llvm-premerge-checks/blob/master/Jenkins/Phabricator-pipeline/Jenkinsfile).
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ echo "Running linters... ====================================="
|
||||||
|
|
||||||
cd "${WORKSPACE}"
|
cd "${WORKSPACE}"
|
||||||
# Let clang format apply patches --diff doesn't produces results in the format we want.
|
# 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
|
set +e
|
||||||
git diff -U0 --exit-code > "${TARGET_DIR}"/clang-format.patch
|
git diff -U0 --exit-code > "${TARGET_DIR}"/clang-format.patch
|
||||||
STATUS="${PIPESTATUS[0]}"
|
STATUS="${PIPESTATUS[0]}"
|
||||||
|
|
|
@ -74,11 +74,12 @@ class ApplyPatch:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print('Checking out master...')
|
revision_id, dependencies, base_revision = self._get_dependencies()
|
||||||
self.repo.git.checkout('master')
|
print('Checking out {}...'.format(base_revision))
|
||||||
|
self.repo.git.checkout(base_revision)
|
||||||
|
print('Revision is {}'.format(self.repo.head.commit.hexsha))
|
||||||
print('Cleanup...')
|
print('Cleanup...')
|
||||||
self.repo.git.clean('-fdx')
|
self.repo.git.clean('-fdx')
|
||||||
revision_id, dependencies = self._get_dependencies()
|
|
||||||
print('Analyzing {}'.format(diff_to_str(revision_id)))
|
print('Analyzing {}'.format(diff_to_str(revision_id)))
|
||||||
if len(dependencies) > 0:
|
if len(dependencies) > 0:
|
||||||
print('This diff depends on: {}'.format(diff_list_to_str(dependencies)))
|
print('This diff depends on: {}'.format(diff_list_to_str(dependencies)))
|
||||||
|
@ -116,10 +117,14 @@ class ApplyPatch:
|
||||||
return self.phab.differential.query(phids=phids)
|
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."""
|
"""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)
|
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']
|
dependency_ids = revision['auxiliary']['phabricator:depends-on']
|
||||||
revisions = self._get_revisions(phids=dependency_ids)
|
revisions = self._get_revisions(phids=dependency_ids)
|
||||||
diff_ids = [int(rev['id']) for rev in revisions]
|
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
|
# so we reverse the order before returning the list, so that they
|
||||||
# can be applied in this order
|
# can be applied in this order
|
||||||
diff_ids.reverse()
|
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):
|
def _apply_diff(self, diff_id: int, revision_id: int):
|
||||||
"""Download and apply a diff to the local working copy."""
|
"""Download and apply a diff to the local working copy."""
|
||||||
print('Applying diff {} for revision {}...'.format(diff_id, diff_to_str(revision_id)))
|
print('Applying diff {} for revision {}...'.format(diff_id, diff_to_str(revision_id)))
|
||||||
diff = self.phab.differential.getrawdiff(diffID=diff_id).response
|
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)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise Exception('Applying patch failed:\n{}'.format(proc.stdout + proc.stderr))
|
raise Exception('Applying patch failed:\n{}'.format(proc.stdout + proc.stderr))
|
||||||
|
|
Loading…
Add table
Reference in a new issue