2021-12-15 01:25:02 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
package CliRunners;
|
2022-02-09 18:40:51 +00:00
|
|
|
use Hydra::Helper::Exec;
|
2021-12-15 01:25:02 +00:00
|
|
|
our @ISA = qw(Exporter);
|
|
|
|
our @EXPORT = qw(
|
2022-01-10 21:47:04 +00:00
|
|
|
evalFails
|
|
|
|
evalSucceeds
|
|
|
|
runBuild
|
|
|
|
sendNotifications
|
|
|
|
);
|
2021-12-15 01:25:02 +00:00
|
|
|
|
|
|
|
sub evalSucceeds {
|
|
|
|
my ($jobset) = @_;
|
|
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
2024-04-12 15:33:27 +00:00
|
|
|
$jobset->discard_changes({ '+columns' => {'errormsg' => 'errormsg'} }); # refresh from DB
|
2022-01-10 21:46:19 +00:00
|
|
|
if ($res) {
|
|
|
|
chomp $stdout; chomp $stderr;
|
2022-01-21 20:17:47 +00:00
|
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
2022-01-11 18:10:43 +00:00
|
|
|
print STDERR "Evaluation unexpectedly failed for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
|
2022-01-10 21:46:19 +00:00
|
|
|
print STDERR "STDOUT: $stdout\n" if $stdout ne "";
|
|
|
|
print STDERR "STDERR: $stderr\n" if $stderr ne "";
|
|
|
|
}
|
2021-12-15 01:25:02 +00:00
|
|
|
return !$res;
|
|
|
|
}
|
|
|
|
|
2022-01-10 21:47:04 +00:00
|
|
|
sub evalFails {
|
|
|
|
my ($jobset) = @_;
|
|
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-eval-jobset", $jobset->project->name, $jobset->name));
|
2024-04-12 15:33:27 +00:00
|
|
|
$jobset->discard_changes({ '+columns' => {'errormsg' => 'errormsg'} }); # refresh from DB
|
2022-01-10 21:47:04 +00:00
|
|
|
if (!$res) {
|
|
|
|
chomp $stdout; chomp $stderr;
|
2022-01-21 20:17:47 +00:00
|
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
2022-01-11 18:10:43 +00:00
|
|
|
print STDERR "Evaluation unexpectedly succeeded for jobset ".$jobset->project->name.":".$jobset->name.": \n".$jobset->errormsg."\n" if $jobset->errormsg;
|
2022-01-10 21:47:04 +00:00
|
|
|
print STDERR "STDOUT: $stdout\n" if $stdout ne "";
|
|
|
|
print STDERR "STDERR: $stderr\n" if $stderr ne "";
|
|
|
|
}
|
|
|
|
return !!$res;
|
|
|
|
}
|
|
|
|
|
2021-12-15 01:25:02 +00:00
|
|
|
sub runBuild {
|
|
|
|
my ($build) = @_;
|
|
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-queue-runner", "-vvvv", "--build-one", $build->id));
|
|
|
|
if ($res) {
|
2022-01-21 20:17:47 +00:00
|
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
2021-12-15 01:25:02 +00:00
|
|
|
print STDERR "Queue runner stdout: $stdout\n" if $stdout ne "";
|
|
|
|
print STDERR "Queue runner stderr: $stderr\n" if $stderr ne "";
|
|
|
|
}
|
|
|
|
return !$res;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sendNotifications() {
|
|
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ("hydra-notify", "--queued-only"));
|
|
|
|
if ($res) {
|
2022-01-21 20:17:47 +00:00
|
|
|
utf8::decode($stdout) or die "Invalid unicode in stdout.";
|
|
|
|
utf8::decode($stderr) or die "Invalid unicode in stderr.";
|
2021-12-15 01:25:02 +00:00
|
|
|
print STDERR "hydra notify stdout: $stdout\n" if $stdout ne "";
|
|
|
|
print STDERR "hydra notify stderr: $stderr\n" if $stderr ne "";
|
|
|
|
}
|
|
|
|
return !$res;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|