From de22c7bd1f53110c99bd244c093076811d9aa377 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 7 Apr 2015 11:56:29 -0700 Subject: [PATCH] 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 --- .arcconfig | 4 ++- arcanist_util/__phutil_library_init__.php | 3 ++ .../__phutil_library_map__.php | 7 +++- .../config/FacebookArcanistConfiguration.php | 32 +++++++++++++++++++ .../cpp_linter/ArcanistCpplintLinter.php | 0 .../cpp_linter/FbcodeCppLinter.php | 0 .../cpp_linter/PfffCppLinter.php | 0 .../cpp_linter/cpplint.py | 0 .../lint_engine/FacebookFbcodeLintEngine.php | 0 .../FacebookFbcodeUnitTestEngine.php | 18 +++++++++++ build_tools/trigger_jenkins_test.sh | 19 ----------- linters/__phutil_library_init__.php | 3 -- 12 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 arcanist_util/__phutil_library_init__.php rename {linters => arcanist_util}/__phutil_library_map__.php (66%) create mode 100644 arcanist_util/config/FacebookArcanistConfiguration.php rename {linters => arcanist_util}/cpp_linter/ArcanistCpplintLinter.php (100%) rename {linters => arcanist_util}/cpp_linter/FbcodeCppLinter.php (100%) rename {linters => arcanist_util}/cpp_linter/PfffCppLinter.php (100%) rename {linters => arcanist_util}/cpp_linter/cpplint.py (100%) rename {linters => arcanist_util}/lint_engine/FacebookFbcodeLintEngine.php (100%) create mode 100644 arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php delete mode 100755 build_tools/trigger_jenkins_test.sh delete mode 100644 linters/__phutil_library_init__.php diff --git a/.arcconfig b/.arcconfig index 886b4437b2..f06f314723 100644 --- a/.arcconfig +++ b/.arcconfig @@ -3,10 +3,12 @@ "conduit_uri" : "https://reviews.facebook.net/", "copyright_holder" : "Facebook", "load" : [ - "linters" + "arcanist_util" ], "lint.engine" : "FacebookFbcodeLintEngine", "lint.engine.single.linter" : "FbcodeCppLinter", + "unit.engine" : "FacebookFbcodeUnitTestEngine", + "arcanist_configuration" : "FacebookArcanistConfiguration", "base" : "git:HEAD^, hg:.^", "git.default-relative-commit" : "HEAD^", "git:arc.feature.start.default" : "origin/master", diff --git a/arcanist_util/__phutil_library_init__.php b/arcanist_util/__phutil_library_init__.php new file mode 100644 index 0000000000..bc732cad60 --- /dev/null +++ b/arcanist_util/__phutil_library_init__.php @@ -0,0 +1,3 @@ + 2, 'class' => array( + 'ArcanistCpplintLinter' => 'cpp_linter/ArcanistCpplintLinter.php', + 'FacebookArcanistConfiguration' => 'config/FacebookArcanistConfiguration.php', 'FacebookFbcodeLintEngine' => 'lint_engine/FacebookFbcodeLintEngine.php', + 'FacebookFbcodeUnitTestEngine' => 'unit_engine/FacebookFbcodeUnitTestEngine.php', 'FbcodeCppLinter' => 'cpp_linter/FbcodeCppLinter.php', 'PfffCppLinter' => 'cpp_linter/PfffCppLinter.php', - 'ArcanistCpplintLinter' => 'cpp_linter/ArcanistCpplintLinter.php', ), 'function' => array( ), 'xmap' => array( + 'ArcanistCpplintLinter' => 'ArcanistLinter', + 'FacebookArcanistConfiguration' => 'ArcanistConfiguration', 'FacebookFbcodeLintEngine' => 'ArcanistLintEngine', + 'FacebookFbcodeUnitTestEngine' => 'ArcanistBaseUnitTestEngine', 'FbcodeCppLinter' => 'ArcanistLinter', 'PfffCppLinter' => 'ArcanistLinter', ), diff --git a/arcanist_util/config/FacebookArcanistConfiguration.php b/arcanist_util/config/FacebookArcanistConfiguration.php new file mode 100644 index 0000000000..10c5767fa2 --- /dev/null +++ b/arcanist_util/config/FacebookArcanistConfiguration.php @@ -0,0 +1,32 @@ +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"); + } + +} diff --git a/linters/cpp_linter/ArcanistCpplintLinter.php b/arcanist_util/cpp_linter/ArcanistCpplintLinter.php similarity index 100% rename from linters/cpp_linter/ArcanistCpplintLinter.php rename to arcanist_util/cpp_linter/ArcanistCpplintLinter.php diff --git a/linters/cpp_linter/FbcodeCppLinter.php b/arcanist_util/cpp_linter/FbcodeCppLinter.php similarity index 100% rename from linters/cpp_linter/FbcodeCppLinter.php rename to arcanist_util/cpp_linter/FbcodeCppLinter.php diff --git a/linters/cpp_linter/PfffCppLinter.php b/arcanist_util/cpp_linter/PfffCppLinter.php similarity index 100% rename from linters/cpp_linter/PfffCppLinter.php rename to arcanist_util/cpp_linter/PfffCppLinter.php diff --git a/linters/cpp_linter/cpplint.py b/arcanist_util/cpp_linter/cpplint.py similarity index 100% rename from linters/cpp_linter/cpplint.py rename to arcanist_util/cpp_linter/cpplint.py diff --git a/linters/lint_engine/FacebookFbcodeLintEngine.php b/arcanist_util/lint_engine/FacebookFbcodeLintEngine.php similarity index 100% rename from linters/lint_engine/FacebookFbcodeLintEngine.php rename to arcanist_util/lint_engine/FacebookFbcodeLintEngine.php diff --git a/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php b/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php new file mode 100644 index 0000000000..3639f11fc2 --- /dev/null +++ b/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php @@ -0,0 +1,18 @@ +setName("jenkins_async_test"); + $result->setResult(ArcanistUnitTestResult::RESULT_POSTPONED); + return array($result); + } +} diff --git a/build_tools/trigger_jenkins_test.sh b/build_tools/trigger_jenkins_test.sh deleted file mode 100755 index 52658f9d26..0000000000 --- a/build_tools/trigger_jenkins_test.sh +++ /dev/null @@ -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" diff --git a/linters/__phutil_library_init__.php b/linters/__phutil_library_init__.php deleted file mode 100644 index 4b8d3d1316..0000000000 --- a/linters/__phutil_library_init__.php +++ /dev/null @@ -1,3 +0,0 @@ -