2020-03-20 08:44:36 +01:00
|
|
|
// Copyright 2019 Google LLC
|
|
|
|
//
|
|
|
|
// Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// https://llvm.org/LICENSE.txt
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
def success = true
|
|
|
|
def failure_message = ""
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent { label 'linux' }
|
|
|
|
parameters {
|
|
|
|
string(name: 'DIFF_ID')
|
|
|
|
string(name: 'PHID')
|
2020-03-23 17:08:58 +01:00
|
|
|
string(name: 'REV_ID')
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
environment {
|
|
|
|
CONDUIT_TOKEN = credentials('phabricator-conduit-token')
|
|
|
|
PHABRICATOR_HOST = 'https://reviews.llvm.org'
|
2020-03-23 17:08:58 +01:00
|
|
|
LLVM_DIR = "${WORKSPACE}/llvm-project"
|
2020-03-20 08:44:36 +01:00
|
|
|
SCRIPT_DIR = "${WORKSPACE}/llvm-premerge-checks/scripts"
|
2020-03-23 17:08:58 +01:00
|
|
|
RESULT_DIR = "${WORKSPACE}/results"
|
|
|
|
PHAB_LOG = "${RESULT_DIR}/.phabricator-comment"
|
|
|
|
MY_BUILD_ID = "${JOB_BASE_NAME}-${BUILD_NUMBER}"
|
2020-03-23 17:14:03 +01:00
|
|
|
TARGET_DIR = "/mnt/nfs/results/${MY_BUILD_ID}"
|
|
|
|
RESULT_URL = "http://results.llvm-merge-guard.org/${MY_BUILD_ID}"
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
2020-04-07 14:44:13 +02:00
|
|
|
options {
|
|
|
|
timeout(time:2, unit:'HOURS')
|
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
stages {
|
|
|
|
stage("build info"){
|
|
|
|
steps {
|
2020-03-23 17:08:58 +01:00
|
|
|
echo "Building diff ${DIFF_ID} with PHID ${PHID} for Revision ${REV_ID}"
|
2020-03-20 08:44:36 +01:00
|
|
|
script {
|
2020-03-23 17:08:58 +01:00
|
|
|
currentBuild.displayName += " D${REV_ID}"
|
|
|
|
currentBuild.description = "<a href='https://reviews.llvm.org/D${REV_ID}'>D${REV_ID}</a>"
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
2020-03-23 17:22:49 +01:00
|
|
|
sh """
|
|
|
|
rm -rf ${RESULT_DIR}
|
|
|
|
mkdir -p ${RESULT_DIR}
|
|
|
|
"""
|
|
|
|
// Report versions of the installed packages.
|
|
|
|
sh """
|
|
|
|
echo Versions of various tools: > ${RESULT_DIR}/package_version.log
|
|
|
|
clang --version >> ${RESULT_DIR}/package_version.log
|
|
|
|
clang-tidy --version >> ${RESULT_DIR}/package_version.log
|
|
|
|
ld.lld --version >> ${RESULT_DIR}/package_version.log
|
|
|
|
dpkg -l >> ${RESULT_DIR}/package_version.log
|
|
|
|
"""
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-23 17:08:58 +01:00
|
|
|
stage("git checkout")
|
|
|
|
{
|
2020-03-20 08:44:36 +01:00
|
|
|
steps {
|
2020-03-23 17:08:58 +01:00
|
|
|
dir("${LLVM_DIR}")
|
|
|
|
{
|
2020-03-23 17:12:25 +01:00
|
|
|
git url: 'git@github.com:llvm-premerge-tests/llvm-project.git', branch: "phab-diff-${DIFF_ID}"
|
2020-03-23 17:08:58 +01:00
|
|
|
sh 'git clean -fdx'
|
|
|
|
sh 'git show -s'
|
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
dir("llvm-premerge-checks")
|
|
|
|
{
|
|
|
|
git url: 'https://github.com/google/llvm-premerge-checks.git'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('CMake') {
|
|
|
|
steps {
|
2020-03-23 17:22:49 +01:00
|
|
|
dir("${LLVM_DIR}")
|
|
|
|
{
|
|
|
|
script {
|
|
|
|
success = false
|
|
|
|
failure_message = "Failed to run cmake"
|
|
|
|
}
|
2020-03-23 17:25:24 +01:00
|
|
|
sh "${SCRIPT_DIR}/run_cmake.py detect"
|
2020-03-23 17:22:49 +01:00
|
|
|
script {
|
|
|
|
success = true
|
|
|
|
failure_message = ""
|
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('ninja all') {
|
|
|
|
steps {
|
2020-03-23 17:22:49 +01:00
|
|
|
dir("${LLVM_DIR}")
|
|
|
|
{
|
|
|
|
script {
|
|
|
|
try {
|
2020-03-23 17:25:24 +01:00
|
|
|
sh(script: "${SCRIPT_DIR}/run_ninja.py all")
|
2020-03-23 17:22:49 +01:00
|
|
|
} catch (e) {
|
|
|
|
success = false;
|
|
|
|
failure_message = "'ninja all' failed" // append as build might already be broken
|
|
|
|
echo e.toString()
|
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('ninja check-all') {
|
|
|
|
steps {
|
2020-03-23 17:22:49 +01:00
|
|
|
dir("${LLVM_DIR}")
|
|
|
|
{
|
|
|
|
script {
|
2020-05-06 17:24:05 +02:00
|
|
|
if (success) {
|
|
|
|
// only run tests if build has passed, see #176
|
|
|
|
try {
|
|
|
|
sh(script: "${SCRIPT_DIR}/run_ninja.py check-all")
|
|
|
|
} catch (e) {
|
|
|
|
success = false;
|
|
|
|
failure_message += "\n'ninja check-all' failed" // append as build might already be broken
|
|
|
|
echo e.toString()
|
|
|
|
}
|
2020-03-23 17:22:49 +01:00
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('linters') {
|
|
|
|
steps {
|
2020-03-23 17:22:49 +01:00
|
|
|
dir("${LLVM_DIR}")
|
|
|
|
{
|
|
|
|
script {
|
|
|
|
try {
|
2020-03-26 10:19:20 +01:00
|
|
|
sh(script: "${SCRIPT_DIR}/lint.sh HEAD~1 ${RESULT_DIR}")
|
2020-03-23 17:22:49 +01:00
|
|
|
} catch (e) {
|
|
|
|
success = false;
|
|
|
|
failure_message += "\nFailed to run linters" // append as build might already be broken
|
|
|
|
echo e.toString()
|
|
|
|
}
|
2020-03-20 08:44:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
script {
|
|
|
|
if (success) {
|
|
|
|
currentBuild.result = "SUCCESS"
|
|
|
|
} else {
|
|
|
|
currentBuild.result = "FAILURE"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "Console log is available at ${RESULT_URL}"
|
2020-03-23 17:08:58 +01:00
|
|
|
dir("${RESULT_DIR}") {
|
2020-03-20 08:44:36 +01:00
|
|
|
// copy console log to result folder
|
|
|
|
sh "wget -qO console-log.txt http://jenkins-ui.jenkins.svc.cluster.local:8080/job/${JOB_BASE_NAME}/${BUILD_NUMBER}/consoleText"
|
|
|
|
// keep a copy of the answer from Phabricator for debugging
|
|
|
|
// TODO: move all file copy operations here
|
|
|
|
sh """
|
|
|
|
set -eu
|
2020-03-23 17:08:58 +01:00
|
|
|
cp ${LLVM_DIR}/build/CMakeCache.txt . || :
|
2020-03-25 13:40:23 +01:00
|
|
|
cp ${LLVM_DIR}/build/test-results.xml . || :
|
2020-03-23 17:08:58 +01:00
|
|
|
mkdir -p ${TARGET_DIR}
|
|
|
|
cp * ${TARGET_DIR}
|
2020-03-20 08:44:36 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
/// send results to Phabricator
|
|
|
|
sh """${SCRIPT_DIR}/phabtalk/phabtalk.py "${PHID}" "${DIFF_ID}" \
|
|
|
|
--workspace "${WORKSPACE}" \
|
|
|
|
--conduit-token "${CONDUIT_TOKEN}" \
|
2020-03-23 17:08:58 +01:00
|
|
|
--test-result-file "${RESULT_DIR}/test-results.xml" \
|
2020-03-20 08:44:36 +01:00
|
|
|
--host "${PHABRICATOR_HOST}/api/" \
|
|
|
|
--buildresult ${currentBuild.result} \
|
2020-03-26 10:19:20 +01:00
|
|
|
--clang-format-patch "${RESULT_DIR}/clang-format.patch" \
|
|
|
|
--clang-tidy-result "${RESULT_DIR}/clang-tidy.txt" \
|
2020-03-20 08:44:36 +01:00
|
|
|
--clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \
|
|
|
|
--results-dir "${TARGET_DIR}" \
|
|
|
|
--results-url "${RESULT_URL}" \
|
|
|
|
--failures "${failure_message}" \
|
|
|
|
--name "linux"
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|