:)
This commit is contained in:
parent
cc3ae846f4
commit
d6e70b7760
|
@ -105,6 +105,7 @@ function runner($msg) {
|
|||
'number' => $in->number,
|
||||
'target_branch' => $in->pull_request->base->ref,
|
||||
'patch_url' => $in->pull_request->patch_url,
|
||||
'head_sha' => $in->pull_request->head->sha,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ function outrunner($msg) {
|
|||
try {
|
||||
runner($msg);
|
||||
} catch (\GHE\ExecException $e) {
|
||||
var_dump($msg);
|
||||
// var_dump($msg);
|
||||
var_dump($e->getMessage());
|
||||
var_dump($e->getCode());
|
||||
var_dump($e->getOutput());
|
||||
|
@ -48,6 +48,22 @@ function runner($msg) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
$head_sha = $in->pr->head_sha;
|
||||
|
||||
$ghclient = gh_client();
|
||||
|
||||
echo "marking PR as pending\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$in->repo->owner,
|
||||
$in->repo->name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'pending',
|
||||
'context' => 'grahamcofborg-eval',
|
||||
]
|
||||
);
|
||||
|
||||
$against_name = "origin/" . $in->pr->target_branch;
|
||||
echo "Building against $against_name\n";
|
||||
$co = new GHE\Checkout(WORKING_DIR, "mr-est");
|
||||
|
@ -60,9 +76,27 @@ function runner($msg) {
|
|||
$against = GHE\Exec::exec('git rev-parse %s', [$against_name]);
|
||||
echo " $against_name is $against[0]\n";
|
||||
|
||||
$prev_darwin_stdenv = identify_stdenv("x86_64-darwin");
|
||||
$prev_linux_stdenv = identify_stdenv("x86_64-linux");
|
||||
echo "starting stdenvs:\n";
|
||||
echo " - darwin: $prev_darwin_stdenv\n";
|
||||
echo " - linux: $prev_linux_stdenv\n";
|
||||
|
||||
try {
|
||||
$co->applyPatches($pname, $in->pr->patch_url);
|
||||
} catch (GHE\ExecException $e) {
|
||||
echo "marking PR as failed to apply patches\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$in->repo->owner,
|
||||
$in->repo->name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'error',
|
||||
'description' => "failed to apply patches to $against_name",
|
||||
'context' => 'grahamcofborg-eval',
|
||||
]
|
||||
);
|
||||
|
||||
echo "Received ExecException applying patches, likely due to conflicts:\n";
|
||||
var_dump($e->getCode());
|
||||
var_dump($e->getMessage());
|
||||
|
@ -72,16 +106,128 @@ function runner($msg) {
|
|||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
GHE\Exec::exec('nix-env --file . --query --available --json > /dev/null 2>&1');
|
||||
} catch (GHE\ExecException $e) {
|
||||
echo "marking PR as failed to evaluate\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$in->repo->owner,
|
||||
$in->repo->name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'failure',
|
||||
'description' => 'Failed to evaluate packages',
|
||||
'context' => 'grahamcofborg-eval',
|
||||
]
|
||||
);
|
||||
|
||||
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_darwin_stdenv = identify_stdenv("x86_64-darwin");
|
||||
$new_linux_stdenv = identify_stdenv("x86_64-linux");
|
||||
echo "new stdenvs:\n";
|
||||
echo " - darwin: $new_darwin_stdenv\n";
|
||||
echo " - linux: $new_linux_stdenv\n";
|
||||
|
||||
|
||||
$current = GHE\Exec::exec('git rev-parse HEAD');
|
||||
echo " currently at ${current[0]}\n";
|
||||
|
||||
try_eval($ghclient, $in->repo->owner, $in->repo->name, $head_sha,
|
||||
'nixos-options',
|
||||
'nix-instantiate ./nixos/release.nix -A options', []);
|
||||
|
||||
try_eval($ghclient, $in->repo->owner, $in->repo->name, $head_sha,
|
||||
'nixos-manual',
|
||||
'nix-instantiate ./nixos/release.nix -A manual', []);
|
||||
|
||||
try_eval($ghclient, $in->repo->owner, $in->repo->name, $head_sha,
|
||||
'nixpkgs-manual',
|
||||
'nix-instantiate ./pkgs/top-level/release.nix -A manual', []);
|
||||
|
||||
try_eval($ghclient, $in->repo->owner, $in->repo->name, $head_sha,
|
||||
'nixpkgs-tarball',
|
||||
'nix-instantiate ./pkgs/top-level/release.nix -A tarball', []);
|
||||
|
||||
try_eval($ghclient, $in->repo->owner, $in->repo->name, $head_sha,
|
||||
'nixpkgs-unstable-jobset',
|
||||
'nix-instantiate ./pkgs/top-level/release.nix -A unstable', []);
|
||||
|
||||
reply_to_issue($in->repo, $in->pr,
|
||||
$new_darwin_stdenv !== $prev_darwin_stdenv,
|
||||
$new_linux_stdenv !== $prev_linux_stdenv,
|
||||
$against[0], $current[0]);
|
||||
|
||||
echo "marking PR as success\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$in->repo->owner,
|
||||
$in->repo->name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'success',
|
||||
'description' => 'Evaluation checks OK',
|
||||
'context' => 'grahamcofborg-eval',
|
||||
]
|
||||
);
|
||||
|
||||
reply_to_issue($in->repo, $in->pr, $against[0], $current[0]);
|
||||
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
|
||||
return true;
|
||||
}
|
||||
|
||||
function reply_to_issue($repo, $pr, $prev, $current) {
|
||||
function try_eval($ghclient, $owner, $name, $sha, $eval_name, $cmd, $args) {
|
||||
echo "Starting $eval_name on $sha\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$owner,
|
||||
$name,
|
||||
$sha,
|
||||
[
|
||||
'state' => 'pending',
|
||||
'context' => 'grahamcofborg-eval-' . $eval_name,
|
||||
]
|
||||
);
|
||||
|
||||
try {
|
||||
GHE\Exec::exec($cmd, $args);
|
||||
} catch (GHE\ExecException $e) {
|
||||
echo "Failed to run $eval_name on $sha\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$owner,
|
||||
$name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'failure',
|
||||
'description' => 'Failed to evaluate ' . $eval_name,
|
||||
'context' => 'grahamcofborg-eval-' . $eval_name,
|
||||
]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
echo "Success running $eval_name on $sha\n";
|
||||
$ghclient->api('repository')->statuses()->create(
|
||||
$owner,
|
||||
$name,
|
||||
$head_sha,
|
||||
[
|
||||
'state' => 'success',
|
||||
'description' => 'Evaluation of $eval_name is OK',
|
||||
'context' => 'grahamcofborg-eval-' . $eval_name,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function identify_stdenv($arch) {
|
||||
$lines = GHE\Exec::exec('nix-instantiate . -A stdenv --argstr system %s 2>&1',
|
||||
[$arch]);
|
||||
echo "fetching stdenv for $arch:\n";
|
||||
var_dump($lines);
|
||||
return array_pop($lines);
|
||||
}
|
||||
|
||||
function reply_to_issue($repo, $pr, $darwin_changed, $linux_changed, $prev, $current) {
|
||||
$client = gh_client();
|
||||
|
||||
echo "current labels:\n";
|
||||
|
@ -100,8 +246,17 @@ function reply_to_issue($repo, $pr, $prev, $current) {
|
|||
]
|
||||
);
|
||||
|
||||
var_dump($output);
|
||||
|
||||
$labels = GHE\RebuildTagClassifier::parseAndLabel($output);
|
||||
|
||||
if ($darwin_changed) {
|
||||
$labels[] = '10.rebuild-darwin-stdenv';
|
||||
}
|
||||
if ($linux_changed) {
|
||||
$labels[] = '10.rebuild-linux-stdenv';
|
||||
}
|
||||
|
||||
foreach ($labels as $label) {
|
||||
if (in_array($label, $already_there)) {
|
||||
echo "already labeled $label\n";
|
||||
|
|
|
@ -20,6 +20,7 @@ class ACL {
|
|||
'grahamc',
|
||||
'lnl7',
|
||||
'mic92',
|
||||
'orivej',
|
||||
'shlevy',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class Checkout {
|
|||
$guard = $this->guard($bname);
|
||||
if (!is_dir($bname)) {
|
||||
echo "Cloning https://github.com/" . $repo_name . "/pull/" . $id . " to $bname\n";
|
||||
Exec::exec('git clone --reference-if-able %s %s %s',
|
||||
Exec::exec('git clone --shared --reference-if-able %s %s %s',
|
||||
[
|
||||
$pname,
|
||||
$clone_url,
|
||||
|
|
|
@ -52,6 +52,10 @@ class EventClassifier {
|
|||
return "delete";
|
||||
}
|
||||
|
||||
if (self::isProjectEvent($payload)) {
|
||||
return "project";
|
||||
}
|
||||
|
||||
if (self::isProjectCardEvent($payload)) {
|
||||
return "project_card";
|
||||
}
|
||||
|
@ -153,6 +157,10 @@ class EventClassifier {
|
|||
&& !isset($payload->master_branch);
|
||||
}
|
||||
|
||||
public static function isProjectEvent($payload) {
|
||||
return isset($payload->project);
|
||||
}
|
||||
|
||||
public static function isProjectCardEvent($payload) {
|
||||
return isset($payload->project_card);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue