forked from lix-project/hydra
* Store info about the build inputs in the build record.
This commit is contained in:
parent
a970603ad1
commit
0ea294e77e
|
@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
|
|||
__PACKAGE__->load_classes;
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UAjA2VmMoOSjiHk0NUzLfQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uu8sYu88Z2oes5zF82ugmg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
37
src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm
Normal file
37
src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm
Normal file
|
@ -0,0 +1,37 @@
|
|||
package HydraFrontend::Schema::Buildinputs;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class';
|
||||
|
||||
__PACKAGE__->load_components("Core");
|
||||
__PACKAGE__->table("buildInputs");
|
||||
__PACKAGE__->add_columns(
|
||||
"buildid",
|
||||
{ data_type => "integer", is_nullable => 0, size => undef },
|
||||
"name",
|
||||
{ data_type => "text", is_nullable => 0, size => undef },
|
||||
"type",
|
||||
{ data_type => "text", is_nullable => 0, size => undef },
|
||||
"uri",
|
||||
{ data_type => "text", is_nullable => 0, size => undef },
|
||||
"revision",
|
||||
{ data_type => "integer", is_nullable => 0, size => undef },
|
||||
"tag",
|
||||
{ data_type => "text", is_nullable => 0, size => undef },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("buildid", "name");
|
||||
__PACKAGE__->belongs_to(
|
||||
"buildid",
|
||||
"HydraFrontend::Schema::Builds",
|
||||
{ id => "buildid" },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m8eC8wnRqF6OLO7EQ7gEvg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
1;
|
|
@ -25,8 +25,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kck2qlNZVLFUnevNPSBVKw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aEqSRZwHoE8HMwlUb05r+w
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -25,8 +25,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CnCSHdI5+5p+L6+r/YITxQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ft672+6Aile/GNGUGMsGWw
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -46,9 +46,14 @@ __PACKAGE__->has_many(
|
|||
"HydraFrontend::Schema::Buildlogs",
|
||||
{ "foreign.buildid" => "self.id" },
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
"buildinputs",
|
||||
"HydraFrontend::Schema::Buildinputs",
|
||||
{ "foreign.buildid" => "self.id" },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Odp6qymLlNXbsD7VOQ7PAQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uogJnVTVX17swfcbZgGQYg
|
||||
|
||||
1;
|
||||
|
|
|
@ -40,8 +40,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pzKFsX3b5wTNZvo8t3WTDg
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:q2kFjFI0X2cbHCrWi3GUCg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -37,8 +37,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pEIAO9lDM+lMKLCLGWRdXg
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Y3YaApHX3uowoamLrr3fAA
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -19,8 +19,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-04 14:45:23
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cpO0BGfChpnpm7KBKkSUjw
|
||||
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-05 07:10:07
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gjIRVxp5x78v1ctQ6+ZqLg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<h1>Build [% id %]</h1>
|
||||
|
||||
|
||||
<h2>Information</h2>
|
||||
|
||||
<table>
|
||||
|
@ -51,6 +52,24 @@
|
|||
</table>
|
||||
|
||||
|
||||
<h2>Build inputs</h2>
|
||||
|
||||
<table class="tablesorter">
|
||||
<thead>
|
||||
<tr><th>Name</th><th>type</th><th>Uri</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH input IN build.buildinputs -%]
|
||||
<tr>
|
||||
<td>[% input.name %]</td>
|
||||
<td>[% input.type %]</td>
|
||||
<td>[% input.uri %]</td>
|
||||
</tr>
|
||||
[% END -%]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<h2>Build products</h2>
|
||||
|
||||
<ul>
|
||||
|
|
|
@ -21,6 +21,19 @@ create table builds (
|
|||
);
|
||||
|
||||
|
||||
create table buildInputs (
|
||||
buildId integer not null,
|
||||
-- Copied from the jobSetInputs from which the build was created.
|
||||
name text not null,
|
||||
type text not null,
|
||||
uri text,
|
||||
revision integer,
|
||||
tag text,
|
||||
primary key (buildId, name),
|
||||
foreign key (buildId) references builds(id) on delete cascade -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
create table buildProducts (
|
||||
buildId integer not null,
|
||||
type text not null, -- "nix-build", "file", "doc", "report", ...
|
||||
|
@ -45,6 +58,7 @@ create table buildLogs (
|
|||
create trigger cascadeBuildDeletion
|
||||
before delete on builds
|
||||
for each row begin
|
||||
delete from buildInputs where buildId = old.id;
|
||||
delete from buildLogs where buildId = old.id;
|
||||
delete from buildProducts where buildId = old.id;
|
||||
end;
|
||||
|
|
|
@ -16,7 +16,7 @@ sub isValidPath {
|
|||
|
||||
|
||||
sub buildJob {
|
||||
my ($project, $jobset, $jobName, $drvPath, $outPath) = @_;
|
||||
my ($project, $jobset, $jobName, $drvPath, $outPath, $usedInputs) = @_;
|
||||
|
||||
if (scalar($db->resultset('Builds')->search({project => $project->name, jobset => $jobset->name, attrname => $jobName, outPath => $outPath})) > 0) {
|
||||
print " already done\n";
|
||||
|
@ -57,6 +57,17 @@ sub buildJob {
|
|||
});
|
||||
print " build ID = ", $build->id, "\n";
|
||||
|
||||
foreach my $input (keys %{$usedInputs}) {
|
||||
$db->resultset('Buildinputs')->create(
|
||||
{ buildid => $build->id
|
||||
, name => $usedInputs->{$input}->{orig}->name
|
||||
, type => $usedInputs->{$input}->{orig}->type
|
||||
, uri => $usedInputs->{$input}->{orig}->uri
|
||||
, revision => $usedInputs->{$input}->{orig}->revision
|
||||
, tag => $usedInputs->{$input}->{orig}->tag
|
||||
});
|
||||
}
|
||||
|
||||
my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath;
|
||||
if (-e $logPath) {
|
||||
print " LOG $logPath\n";
|
||||
|
@ -105,7 +116,7 @@ sub fetchInput {
|
|||
or die "cannot copy path $uri to the Nix store";
|
||||
chomp $storePath;
|
||||
print " copied to $storePath\n";
|
||||
$$inputInfo{$input->name} = {storePath => $storePath};
|
||||
$$inputInfo{$input->name} = {orig => $input, storePath => $storePath};
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -151,19 +162,28 @@ sub checkJobSet {
|
|||
|
||||
my $extraArgs = "";
|
||||
|
||||
my $usedInputs = {};
|
||||
|
||||
# If the expression is a function, then look at its formal
|
||||
# arguments and see if we can supply them.
|
||||
if (defined $jobExpr->{function}->{attrspat}) {
|
||||
|
||||
foreach my $argName (keys(%{$jobExpr->{function}->{attrspat}->{attr}})) {
|
||||
print " needs input $argName\n";
|
||||
|
||||
my $storePath;
|
||||
|
||||
if (defined $inputInfo->{$argName}) {
|
||||
# The argument name matches an input.
|
||||
$storePath = $inputInfo->{$argName}->{storePath};
|
||||
} else {
|
||||
$$usedInputs{$argName} = $inputInfo->{$argName};
|
||||
}
|
||||
|
||||
else {
|
||||
(my $prevBuild) = $db->resultset('Builds')->search(
|
||||
{project => $project->name, jobset => $jobset->name, attrname => $argName},
|
||||
{order_by => "timestamp DESC", rows => 1});
|
||||
|
||||
if (defined $prevBuild) {
|
||||
# The argument name matches a previously built
|
||||
# job in this jobset. Pick the most recent
|
||||
|
@ -178,12 +198,12 @@ sub checkJobSet {
|
|||
die "missing input `$argName'";
|
||||
}
|
||||
}
|
||||
|
||||
$extraArgs .= " --arg $argName '{path = " . $storePath . ";}'";
|
||||
}
|
||||
}
|
||||
|
||||
# Instantiate the store derivation.
|
||||
print "$extraArgs\n";
|
||||
my $drvPath = `nix-instantiate $nixExprPath --attr $jobName $extraArgs`
|
||||
or die "cannot evaluate the Nix expression containing the job definitions: $?";
|
||||
chomp $drvPath;
|
||||
|
@ -202,7 +222,7 @@ sub checkJobSet {
|
|||
die unless $job->{drvPath} eq $drvPath;
|
||||
my $outPath = $job->{outPath};
|
||||
|
||||
buildJob($project, $jobset, $jobName, $drvPath, $outPath);
|
||||
buildJob($project, $jobset, $jobName, $drvPath, $outPath, $usedInputs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue