Integrate Jenkins with Phabricator

Summary:
After this diff, when a user submits a diff from Facebook's VPN
network, we'll automatically trigger a jenkins test. Once jenkins test
is done, we'll update the diff with test results.

Test Plan:
Made sure that jenkins build is triggered on `arc diff` and
that result is reflected back on the diff

Reviewers: sdong, rven, kradhakrishnan, anthony, yhchiang

Reviewed By: anthony

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D36555
This commit is contained in:
Igor Canadi 2015-04-07 11:56:29 -07:00
parent f12614070f
commit de22c7bd1f
12 changed files with 62 additions and 24 deletions

View File

@ -3,10 +3,12 @@
"conduit_uri" : "https://reviews.facebook.net/", "conduit_uri" : "https://reviews.facebook.net/",
"copyright_holder" : "Facebook", "copyright_holder" : "Facebook",
"load" : [ "load" : [
"linters" "arcanist_util"
], ],
"lint.engine" : "FacebookFbcodeLintEngine", "lint.engine" : "FacebookFbcodeLintEngine",
"lint.engine.single.linter" : "FbcodeCppLinter", "lint.engine.single.linter" : "FbcodeCppLinter",
"unit.engine" : "FacebookFbcodeUnitTestEngine",
"arcanist_configuration" : "FacebookArcanistConfiguration",
"base" : "git:HEAD^, hg:.^", "base" : "git:HEAD^, hg:.^",
"git.default-relative-commit" : "HEAD^", "git.default-relative-commit" : "HEAD^",
"git:arc.feature.start.default" : "origin/master", "git:arc.feature.start.default" : "origin/master",

View File

@ -0,0 +1,3 @@
<?php
phutil_register_library('arcanist_util', __FILE__);

View File

@ -10,17 +10,22 @@ phutil_register_library_map(array(
'__library_version__' => 2, '__library_version__' => 2,
'class' => 'class' =>
array( array(
'ArcanistCpplintLinter' => 'cpp_linter/ArcanistCpplintLinter.php',
'FacebookArcanistConfiguration' => 'config/FacebookArcanistConfiguration.php',
'FacebookFbcodeLintEngine' => 'lint_engine/FacebookFbcodeLintEngine.php', 'FacebookFbcodeLintEngine' => 'lint_engine/FacebookFbcodeLintEngine.php',
'FacebookFbcodeUnitTestEngine' => 'unit_engine/FacebookFbcodeUnitTestEngine.php',
'FbcodeCppLinter' => 'cpp_linter/FbcodeCppLinter.php', 'FbcodeCppLinter' => 'cpp_linter/FbcodeCppLinter.php',
'PfffCppLinter' => 'cpp_linter/PfffCppLinter.php', 'PfffCppLinter' => 'cpp_linter/PfffCppLinter.php',
'ArcanistCpplintLinter' => 'cpp_linter/ArcanistCpplintLinter.php',
), ),
'function' => 'function' =>
array( array(
), ),
'xmap' => 'xmap' =>
array( array(
'ArcanistCpplintLinter' => 'ArcanistLinter',
'FacebookArcanistConfiguration' => 'ArcanistConfiguration',
'FacebookFbcodeLintEngine' => 'ArcanistLintEngine', 'FacebookFbcodeLintEngine' => 'ArcanistLintEngine',
'FacebookFbcodeUnitTestEngine' => 'ArcanistBaseUnitTestEngine',
'FbcodeCppLinter' => 'ArcanistLinter', 'FbcodeCppLinter' => 'ArcanistLinter',
'PfffCppLinter' => 'ArcanistLinter', 'PfffCppLinter' => 'ArcanistLinter',
), ),

View File

@ -0,0 +1,32 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
class FacebookArcanistConfiguration extends ArcanistConfiguration {
public function didRunWorkflow($command,
ArcanistBaseWorkflow $workflow,
$error_code) {
if ($command == 'diff' && !$workflow->isRawDiffSource()) {
$this->maybePushToJenkins($workflow);
}
}
//////////////////////////////////////////////////////////////////////
/* Send off builds to jenkins */
function maybePushToJenkins($workflow) {
$diffID = $workflow->getDiffID();
if ($diffID === null) {
return;
}
$results = $workflow->getTestResults();
if (!$results) {
return;
}
$url = "https://ci-builds.fb.com/view/rocksdb/job/rocksdb_diff_check/"
."buildWithParameters?token=AUTH&DIFF_ID=$diffID";
system("curl --noproxy '*' \"$url\" > /dev/null 2>&1");
}
}

View File

@ -0,0 +1,18 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
class FacebookFbcodeUnitTestEngine extends ArcanistBaseUnitTestEngine {
public function run() {
// Here we create a new unit test "jenkins_async_test" and promise we'll
// update the results later.
// Jenkins updates the results using `arc call-conduit
// differential.updateunitresults` call. If you change the name here, also
// make sure to change the name in Jenkins script that updates the test
// result -- they have to be the same.
$result = new ArcanistUnitTestResult();
$result->setName("jenkins_async_test");
$result->setResult(ArcanistUnitTestResult::RESULT_POSTPONED);
return array($result);
}
}

View File

@ -1,19 +0,0 @@
#!/bin/bash
# usage:
# * trigger_jenkins_test.sh -- without parameters, submits the current patch to Jenkins for testing
# * trigger_jenkins_test.sh D12345 -- submits diff D12345
if [[ $# == 0 ]]; then
diff=$(git log -1 --pretty=%b | perl -nle \
'm!^Differential Revision: https://reviews\.facebook\.net/(D\d+)$! and print $1')
else
diff=$1
fi
diff_len=`expr length "$diff"`
if [[ $diff_len < 6 ]] ; then
echo "I don't think your diff ID ($diff) is correct"
exit 1
fi
echo "Submitting build of diff $diff to Jenkins"
curl "https://ci-builds.fb.com/view/rocksdb/job/rocksdb_diff_check/buildWithParameters?token=AUTH&DIFF=$diff"

View File

@ -1,3 +0,0 @@
<?php
phutil_register_library('linters', __FILE__);