function getSteps($applyDiff, $diffID, $username, $test) { assert(strlen($username) > 0); assert(strlen($test) > 0); if ($applyDiff) { assert(strlen($diffID) > 0); assert(is_numeric($diffID)); $arcrc_content = PHP_OS == "Darwin" ? exec("cat ~/.arcrc | gzip -f | base64") : exec("cat ~/.arcrc | gzip -f | base64 -w0"); assert(strlen($arcrc_content) > 0); // Sandcastle machines don't have arc setup. We copy the user certificate // and authenticate using that in Sandcastle. $setup = array("name" => "Setup arcrc", "shell" => "echo " . $arcrc_content . " | base64 --decode" . " | gzip -d > ~/.arcrc", "user" => "root"); // arc demands certain permission on its config. // also fix the sticky bit issue in sandcastle $fix_permission = array("name" => "Fix environment", "shell" => "chmod 600 ~/.arcrc && chmod +t /dev/shm", "user" => "root"); // Construct the steps in the order of execution. $steps[] = $setup; $steps[] = $fix_permission; } // fbcode is a sub-repo. We cannot patch until we add it to ignore otherwise // Git thinks it is an uncommited change. $fix_git_ignore = array("name" => "Fix git ignore", "shell" => "echo fbcode >> .git/info/exclude", "user" => "root"); $steps[] = $fix_git_ignore; // This will be the command used to execute particular type of tests. $cmd = ""; if ($applyDiff) { // Patch the code (keep your fingures crossed). $patch = array("name" => "Patch " . $diffID, "shell" => "HTTPS_PROXY=fwdproxy:8080 arc --arcrc-file ~/.arcrc " . "patch --nocommit --diff " . $diffID, "user" => "root"); $steps[] = $patch; updateTestStatus($diffID, $test); $cmd = buildUpdateTestStatusCmd($diffID, $test, "running") . "; "; } // Run the actual command. $cmd = $cmd . "J=\$(nproc) ./build_tools/precommit_checker.py " . $test . "; exit_code=\$?; "; if ($applyDiff) { $cmd = $cmd . "([[ \$exit_code -eq 0 ]] &&" . buildUpdateTestStatusCmd($diffID, $test, "pass") . ")" . "||" . buildUpdateTestStatusCmd($diffID, $test, "fail") . "; "; } // shell command to sort the tests based on exit code and print // the output of the log files. $cat_sorted_logs = "\n while read code log_file;\n do echo \"################ cat \$log_file [exit_code : \$code] ################\";\n cat \$log_file;\n done < <(tail -n +2 LOG | sort -k7,7n -k4,4gr | awk '{print \$7,\$NF}')"; // Shell command to cat all log files $cat_all_logs = "for f in `ls t/!(run-*)`; do echo \$f;cat \$f; done"; // If LOG file exist use it to cat log files sorted by exit code, otherwise // cat everything $logs_cmd = "if [ -f LOG ]; then {$cat_sorted_logs}; else {$cat_all_logs}; fi"; $cmd = $cmd . " cat /tmp/precommit-check.log" . "; shopt -s extglob; {$logs_cmd}" . "; shopt -u extglob; [[ \$exit_code -eq 0 ]]"; assert(strlen($cmd) > 0); $run_test = array("name" => "Run " . $test, "shell" => $cmd, "user" => "root", "parser" => "python build_tools/error_filter.py " . $test); $steps[] = $run_test; if ($applyDiff) { // Clean up the user arc config we are using. $cleanup = array("name" => "Arc cleanup", "shell" => "rm -f ~/.arcrc", "user" => "root"); $steps[] = $cleanup; } assert(count($steps) > 0); return $steps; }
function getSteps($applyDiff, $diffID, $username, $test) { assert(strlen($username) > 0); assert(strlen($test) > 0); if ($applyDiff) { assert(strlen($diffID) > 0); assert(is_numeric($diffID)); $arcrc_content = exec("cat ~/.arcrc | gzip -f | base64 -w0"); assert(strlen($arcrc_content) > 0); // Sandcastle machines don't have arc setup. We copy the user certificate // and authenticate using that in Sandcastle. $setup = array("name" => "Setup arcrc", "shell" => "echo " . $arcrc_content . " | base64 --decode" . " | gzip -d > ~/.arcrc", "user" => "root"); // arc demands certain permission on its config. $fix_permission = array("name" => "Fix environment", "shell" => "chmod 600 ~/.arcrc", "user" => "root"); // Construct the steps in the order of execution. $steps[] = $setup; $steps[] = $fix_permission; } // fbcode is a sub-repo. We cannot patch until we add it to ignore otherwise // Git thinks it is an uncommited change. $fix_git_ignore = array("name" => "Fix git ignore", "shell" => "echo fbcode >> .git/info/exclude", "user" => "root"); $steps[] = $fix_git_ignore; // This will be the command used to execute particular type of tests. $cmd = ""; if ($applyDiff) { // Patch the code (keep your fingures crossed). $patch = array("name" => "Patch " . $diffID, "shell" => "HTTPS_PROXY=fwdproxy:8080 arc --arcrc-file ~/.arcrc " . "patch --nocommit --diff " . $diffID, "user" => "root"); $steps[] = $patch; updateTestStatus($diffID, $test); $cmd = buildUpdateTestStatusCmd($diffID, $test, "running") . "; "; } // Run the actual command. $cmd = $cmd . "./build_tools/precommit_checker.py " . $test . "; exit_code=\$?; "; if ($applyDiff) { $cmd = $cmd . "([[ \$exit_code -eq 0 ]] &&" . buildUpdateTestStatusCmd($diffID, $test, "pass") . ")" . "||" . buildUpdateTestStatusCmd($diffID, $test, "fail") . "; "; } $cmd = $cmd . " cat /tmp/precommit-check.log" . "; for f in `ls t/log-*`; do echo \$f; cat \$f; done;" . "[[ \$exit_code -eq 0 ]]"; assert(strlen($cmd) > 0); $run_test = array("name" => "Run " . $test, "shell" => $cmd, "user" => "root"); $steps[] = $run_test; if ($applyDiff) { // Clean up the user arc config we are using. $cleanup = array("name" => "Arc cleanup", "shell" => "rm -f ~/.arcrc", "user" => "root"); $steps[] = $cleanup; } assert(count($steps) > 0); return $steps; }