diff --git a/lib/Peace/Model/Build.pm b/lib/Peace/Model/Build.pm index 6fcedf5..d3f2f87 100644 --- a/lib/Peace/Model/Build.pm +++ b/lib/Peace/Model/Build.pm @@ -21,7 +21,9 @@ use Peace::DAO::Release; { type => InstanceOf ['Peace::Model::Release'], optional => 1 }, release_uuid => { type => Str, optional => 1, }, dbh => { type => HasMethods ['selectall_arrayref'], optional => 1 }, - arch => { type => Str, }, + success => { type => Bool }, + log => { type => Str }, + arch => { type => Str, }, } ); @@ -97,6 +99,34 @@ use Peace::DAO::Release; } } +{ + my $validator = + validation_for( params => [ { type => Str, optional => 1, } ] ); + + sub log { + my $self = shift; + if (@_) { + my ($new_log) = $validator->(@_); + $self->{log} = $new_log; + } + return $self->{log}; + } +} + +{ + my $validator = + validation_for( params => [ { type => Bool, optional => 1, } ] ); + + sub success { + my $self = shift; + if (@_) { + my ($new_success) = $validator->(@_); + $self->{success} = $new_success; + } + return $self->{success}; + } +} + sub _dbh { my $self = shift; return $self->{dbh}; @@ -175,6 +205,22 @@ Allows to set and retrieve the release attribute as a L. Allows to set and retrieve the architecture attribute. +=head2 log + + my $log = $build->log; + + $build->log($log); + +Allows to set an retrieve the build log. + +=head2 success + + my $success = $build->success; + + $build->success($success); + +Allows to set and retrieve the build success status. + =head1 SEE ALSO L, L diff --git a/lib/Peace/Model/Release.pm b/lib/Peace/Model/Release.pm index c111237..0ea3079 100644 --- a/lib/Peace/Model/Release.pm +++ b/lib/Peace/Model/Release.pm @@ -15,6 +15,8 @@ use Capture::Tiny qw/tee_merged/; use File::Spec; use List::AllUtils qw/any/; +use Peace::Model::Build; + { my $validator = validation_for( params => { @@ -103,10 +105,12 @@ use List::AllUtils qw/any/; say "BUILD FAILED:\n$merged_output"; $success = 0; } - return { - output => $merged_output, + return Peace::Model::Build->new( + arch => $arch, + log => $merged_output, success => $success, - }; + release => $self, + ); } } @@ -332,18 +336,14 @@ Peace::Model::Release implements the following methods: =head2 generate_build -my $result = $release->generate_build( arch => $arch ); +my $build = $release->generate_build( arch => $arch ); -my ($success, $output) = @result{'success', 'output'}; +my $success = $build->success; +my $log = $build->log; -Generates a build for a given arch of the release and -returns the success status, any false value failed, -any true value succeded and the output which combines -stdout and stderr from the ran commands and some -application specific data about whats being done. - -The output log is thought to be human consumed, not -automatically parsed. +Attempts to build a flatpak for the release and +unconditionally returns a L +object with the results of the build. =head2 uuid diff --git a/t/00011-build-model.t b/t/00011-build-model.t index bb955fa..09eb6fd 100644 --- a/t/00011-build-model.t +++ b/t/00011-build-model.t @@ -16,9 +16,15 @@ BEGIN { ## GIVEN my $release = Peace::Test::Mock::Model::Release->new; my $arch = 'x86'; + my $success = 1; + my $log = 'Built successfully.'; my $build = Peace::Model::Build->new( release => $release, arch => $arch, + success => $success, + log => $log, + ); - ok $build->isa('Peace::Model::Build'), 'Build is made of Peace::Model::Build.'; + ok $build->isa('Peace::Model::Build'), + 'Build is made of Peace::Model::Build.'; } diff --git a/web_tests/000001-release-model.t b/web_tests/000001-release-model.t index 8755d36..bc5bd51 100644 --- a/web_tests/000001-release-model.t +++ b/web_tests/000001-release-model.t @@ -33,6 +33,6 @@ use Peace::Model::Release; tag => 'main', name => 'test', ); - my $result = $release->generate_build( arch => 'x86_64' ); - ok $result->{success}, 'Build ends successfully.'; + my $build = $release->generate_build( arch => 'aarch64' ); + ok $build->success, 'Build ends successfully.'; }