commit ff6021450a17688bea9d63ee9398c8142f2ddc74 Author: Eelco Dolstra Date: Fri Oct 10 16:05:05 2008 +0000 * Start putting build results in a database. diff --git a/src/hydra.schema b/src/hydra.schema new file mode 100644 index 00000000..4a3d1ab4 --- /dev/null +++ b/src/hydra.schema @@ -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, ... +); diff --git a/src/scheduler.pl b/src/scheduler.pl new file mode 100644 index 00000000..c5d968e0 --- /dev/null +++ b/src/scheduler.pl @@ -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"; +} diff --git a/test.nix b/test.nix new file mode 100644 index 00000000..fc258b08 --- /dev/null +++ b/test.nix @@ -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; + +}