* Start putting build results in a database.

This commit is contained in:
Eelco Dolstra 2008-10-10 16:05:05 +00:00
commit ff6021450a
3 changed files with 65 additions and 0 deletions

9
src/hydra.schema Normal file
View file

@ -0,0 +1,9 @@
create table builds (
id integer primary key autoincrement,
timestamp integer, -- time this build was added to the db (in Unix time)
name text,
description text,
drvPath text,
outPath text,
buildStatus integer -- 0 = succeeded, 1 = failure, ...
);

39
src/scheduler.pl Normal file
View file

@ -0,0 +1,39 @@
#! @perl@ -w
use strict;
use XML::Simple;
use DBI;
my $dbh = DBI->connect("dbi:SQLite:dbname=hydra.sqlite", "", "");
my $jobsXml = `nix-env -f ../test.nix --query --available "*" --attr-path --out-path --drv-path --meta --xml --system-filter "*"`
or die "cannot evaluate the Nix expression containing the job definitions: $?";
print "$jobsXml";
my $jobs = XMLin($jobsXml, KeyAttr => ['attrPath', 'name'])
or die "cannot parse XML output";
foreach my $jobName (keys %{$jobs->{item}}) {
my $job = $jobs->{item}->{$jobName};
print "JOB: $jobName ($job->{meta}->{description}->{value})\n";
my $outPath = $job->{outPath};
if (scalar(@{$dbh->selectall_arrayref("select * from builds where name = ? and outPath = ?", {}, $jobName, $outPath)}) > 0) {
print " already done\n";
next;
}
my $res = system("nix-build ../test.nix --attr $jobName");
my $buildStatus = $res == 0 ? 0 : 1;
$dbh->prepare("insert into builds(timestamp, name, description, drvPath, outPath, buildStatus) values(?, ?, ?, ?, ?, ?)")
->execute(time(), $jobName, $job->{meta}->{description}->{value}, $job->{drvPath}, $outPath, $buildStatus);
print " db id = ", $dbh->last_insert_id(undef, undef, undef, undef), "\n";
}

17
test.nix Normal file
View file

@ -0,0 +1,17 @@
let
pkgs = import (builtins.getEnv "NIXPKGS_ALL") {};
pkgs64 = import (builtins.getEnv "NIXPKGS_ALL") {system = "x86_64-linux";};
in
{
job1 = pkgs.hello;
job1_64 = pkgs64.hello;
job2 = pkgs.aterm;
}