Refactoring the generate_build method to return a Peace::Model::Build object.
This commit is contained in:
parent
3e331d7b1a
commit
e67a4cf593
@ -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<Peace::Model::Release>.
|
||||
|
||||
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<Peace::Model::Release>, L<Peace::DAO::Build>
|
||||
|
@ -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<Peace::Model::Build>
|
||||
object with the results of the build.
|
||||
|
||||
=head2 uuid
|
||||
|
||||
|
@ -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.';
|
||||
}
|
||||
|
@ -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.';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user