From 5da3dcfd57b62c43f0ec62f9d0da5244770c152c Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 29 Oct 2013 14:41:48 -0400 Subject: [PATCH] Make the outputs' outpaths available via the Build JSON API Signed-off-by: Shea Levy --- src/lib/Hydra/Schema/BuildOutputs.pm | 10 +++++++++- src/lib/Hydra/Schema/Builds.pm | 5 ++++- tests/api-test.pl | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Schema/BuildOutputs.pm b/src/lib/Hydra/Schema/BuildOutputs.pm index 9bd656da..751eac4b 100644 --- a/src/lib/Hydra/Schema/BuildOutputs.pm +++ b/src/lib/Hydra/Schema/BuildOutputs.pm @@ -97,6 +97,14 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-06-13 01:54:50 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:V8MbzKvZNEaeHBJV67+ZMQ +my %hint = ( + columns => [ + 'path' + ], +); + +sub json_hint { + return \%hint; +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index 16e89088..2355e4ee 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -617,7 +617,10 @@ my %hint = ( 'busy', 'buildstatus', 'releasename' - ] + ], + eager_relations => { + buildoutputs => 'name' + } ); sub json_hint { diff --git a/tests/api-test.pl b/tests/api-test.pl index 8b520fba..f9068dd4 100644 --- a/tests/api-test.pl +++ b/tests/api-test.pl @@ -1,6 +1,6 @@ use LWP::UserAgent; use JSON; -use Test::Simple tests => 15; +use Test::Simple tests => 16; my $ua = LWP::UserAgent->new; $ua->cookie_jar({}); @@ -62,3 +62,4 @@ ok($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision} != $evals->[1]->{jobs my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content()); ok($build->{job} eq "job", "The build's job name is job"); ok($build->{finished} == 0, "The build isn't finished yet"); +ok($build->{buildoutputs}->{out}->{path} =~ /^\/run\/nix\/store\/[a-zA-Z0-9]{32}-job$/, "The build's outpath is in the nix store and named 'job'");