forked from lix-project/hydra
* Some renaming.
This commit is contained in:
parent
e1373fa1c3
commit
f72367407a
|
@ -32,26 +32,27 @@ sub fetchInputs {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub checkJob {
|
# Check whether to add the build described by $buildInfo.
|
||||||
my ($project, $jobset, $inputInfo, $nixExprInput, $job, $currentBuilds) = @_;
|
sub checkBuild {
|
||||||
|
my ($project, $jobset, $inputInfo, $nixExprInput, $buildInfo, $currentBuilds) = @_;
|
||||||
|
|
||||||
my $jobName = $job->{jobName};
|
my $jobName = $buildInfo->{jobName};
|
||||||
my $drvPath = $job->{drvPath};
|
my $drvPath = $buildInfo->{drvPath};
|
||||||
my $outPath = $job->{outPath};
|
my $outPath = $buildInfo->{outPath};
|
||||||
|
|
||||||
my $priority = 100;
|
my $priority = 100;
|
||||||
$priority = int($job->{schedulingPriority})
|
$priority = int($buildInfo->{schedulingPriority})
|
||||||
if $job->{schedulingPriority} =~ /^\d+$/;
|
if $buildInfo->{schedulingPriority} =~ /^\d+$/;
|
||||||
|
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
# Update the last evaluation time in the database.
|
# Update the last evaluation time in the database.
|
||||||
my $jobInDB = $jobset->jobs->update_or_create(
|
my $job = $jobset->jobs->update_or_create(
|
||||||
{ name => $jobName
|
{ name => $jobName
|
||||||
, lastevaltime => time
|
, lastevaltime => time
|
||||||
});
|
});
|
||||||
|
|
||||||
$jobInDB->update({firstevaltime => time})
|
$job->update({firstevaltime => time})
|
||||||
unless defined $jobInDB->firstevaltime;
|
unless defined $job->firstevaltime;
|
||||||
|
|
||||||
# Don't add a build that has already been scheduled for this
|
# Don't add a build that has already been scheduled for this
|
||||||
# job, or has been built but is still a "current" build for
|
# job, or has been built but is still a "current" build for
|
||||||
|
@ -64,7 +65,7 @@ sub checkJob {
|
||||||
# !!! Checking $outPath doesn't take meta-attributes into
|
# !!! Checking $outPath doesn't take meta-attributes into
|
||||||
# account. For instance, do we want a new build to be
|
# account. For instance, do we want a new build to be
|
||||||
# scheduled if the meta.maintainers field is changed?
|
# scheduled if the meta.maintainers field is changed?
|
||||||
my @previousBuilds = $jobInDB->builds->search({outPath => $outPath, isCurrent => 1});
|
my @previousBuilds = $job->builds->search({outPath => $outPath, isCurrent => 1});
|
||||||
if (scalar(@previousBuilds) > 0) {
|
if (scalar(@previousBuilds) > 0) {
|
||||||
print "already scheduled/built\n";
|
print "already scheduled/built\n";
|
||||||
$currentBuilds->{$_->id} = 1 foreach @previousBuilds;
|
$currentBuilds->{$_->id} = 1 foreach @previousBuilds;
|
||||||
|
@ -72,18 +73,18 @@ sub checkJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Nope, so add it.
|
# Nope, so add it.
|
||||||
my $build = $jobInDB->builds->create(
|
my $build = $job->builds->create(
|
||||||
{ finished => 0
|
{ finished => 0
|
||||||
, timestamp => time()
|
, timestamp => time()
|
||||||
, description => $job->{description}
|
, description => $buildInfo->{description}
|
||||||
, longdescription => $job->{longDescription}
|
, longdescription => $buildInfo->{longDescription}
|
||||||
, license => $job->{license}
|
, license => $buildInfo->{license}
|
||||||
, homepage => $job->{homepage}
|
, homepage => $buildInfo->{homepage}
|
||||||
, maintainers => $job->{maintainers}
|
, maintainers => $buildInfo->{maintainers}
|
||||||
, nixname => $job->{nixName}
|
, nixname => $buildInfo->{nixName}
|
||||||
, drvpath => $drvPath
|
, drvpath => $drvPath
|
||||||
, outpath => $outPath
|
, outpath => $outPath
|
||||||
, system => $job->{system}
|
, system => $buildInfo->{system}
|
||||||
, iscurrent => 1
|
, iscurrent => 1
|
||||||
, nixexprinput => $jobset->nixexprinput
|
, nixexprinput => $jobset->nixexprinput
|
||||||
, nixexprpath => $jobset->nixexprpath
|
, nixexprpath => $jobset->nixexprpath
|
||||||
|
@ -101,7 +102,7 @@ sub checkJob {
|
||||||
|
|
||||||
my %inputs;
|
my %inputs;
|
||||||
$inputs{$jobset->nixexprinput} = $nixExprInput;
|
$inputs{$jobset->nixexprinput} = $nixExprInput;
|
||||||
foreach my $arg (@{$job->{arg}}) {
|
foreach my $arg (@{$buildInfo->{arg}}) {
|
||||||
$inputs{$arg->{name}} = $inputInfo->{$arg->{name}}->[$arg->{altnr}]
|
$inputs{$arg->{name}} = $inputInfo->{$arg->{name}}->[$arg->{altnr}]
|
||||||
|| die "invalid input";
|
|| die "invalid input";
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@ sub checkJobset {
|
||||||
foreach my $job (permute @{$jobs->{job}}) {
|
foreach my $job (permute @{$jobs->{job}}) {
|
||||||
next if $job->{jobName} eq "";
|
next if $job->{jobName} eq "";
|
||||||
print "considering job " . $job->{jobName} . "\n";
|
print "considering job " . $job->{jobName} . "\n";
|
||||||
checkJob($project, $jobset, $inputInfo, $nixExprInput, $job, \%currentBuilds);
|
checkBuild($project, $jobset, $inputInfo, $nixExprInput, $job, \%currentBuilds);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn_do($db, sub {
|
txn_do($db, sub {
|
||||||
|
@ -216,11 +217,11 @@ sub checkJobset {
|
||||||
|
|
||||||
$jobset->update({lastcheckedtime => time});
|
$jobset->update({lastcheckedtime => time});
|
||||||
|
|
||||||
foreach my $jobInDB ($jobset->jobs->all) {
|
foreach my $job ($jobset->jobs->all) {
|
||||||
if ($failedJobNames{$jobInDB->name}) {
|
if ($failedJobNames{$job->name}) {
|
||||||
$jobInDB->update({errormsg => join '\n', @{$failedJobNames{$jobInDB->name}}});
|
$job->update({errormsg => join '\n', @{$failedJobNames{$job->name}}});
|
||||||
} else {
|
} else {
|
||||||
$jobInDB->update({errormsg => undef});
|
$job->update({errormsg => undef});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ sub checkJobsetWrapped {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub checkJobs {
|
sub checkProjects {
|
||||||
foreach my $project ($db->resultset('Projects')->search({enabled => 1})) {
|
foreach my $project ($db->resultset('Projects')->search({enabled => 1})) {
|
||||||
print "considering project ", $project->name, "\n";
|
print "considering project ", $project->name, "\n";
|
||||||
checkJobsetWrapped($project, $_)
|
checkJobsetWrapped($project, $_)
|
||||||
|
@ -293,7 +294,7 @@ if (scalar @ARGV == 2) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
eval {
|
eval {
|
||||||
checkJobs;
|
checkProjects;
|
||||||
};
|
};
|
||||||
if ($@) { print "$@"; }
|
if ($@) { print "$@"; }
|
||||||
print "sleeping...\n";
|
print "sleeping...\n";
|
||||||
|
|
Loading…
Reference in a new issue