Refactoring the generate_build method to return a Peace::Model::Build object.
This commit is contained in:
parent
3e331d7b1a
commit
e67a4cf593
@ -21,6 +21,8 @@ use Peace::DAO::Release;
|
|||||||
{ type => InstanceOf ['Peace::Model::Release'], optional => 1 },
|
{ type => InstanceOf ['Peace::Model::Release'], optional => 1 },
|
||||||
release_uuid => { type => Str, optional => 1, },
|
release_uuid => { type => Str, optional => 1, },
|
||||||
dbh => { type => HasMethods ['selectall_arrayref'], optional => 1 },
|
dbh => { type => HasMethods ['selectall_arrayref'], optional => 1 },
|
||||||
|
success => { type => Bool },
|
||||||
|
log => { type => Str },
|
||||||
arch => { 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 {
|
sub _dbh {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->{dbh};
|
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.
|
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
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<Peace::Model::Release>, L<Peace::DAO::Build>
|
L<Peace::Model::Release>, L<Peace::DAO::Build>
|
||||||
|
@ -15,6 +15,8 @@ use Capture::Tiny qw/tee_merged/;
|
|||||||
use File::Spec;
|
use File::Spec;
|
||||||
use List::AllUtils qw/any/;
|
use List::AllUtils qw/any/;
|
||||||
|
|
||||||
|
use Peace::Model::Build;
|
||||||
|
|
||||||
{
|
{
|
||||||
my $validator = validation_for(
|
my $validator = validation_for(
|
||||||
params => {
|
params => {
|
||||||
@ -103,10 +105,12 @@ use List::AllUtils qw/any/;
|
|||||||
say "BUILD FAILED:\n$merged_output";
|
say "BUILD FAILED:\n$merged_output";
|
||||||
$success = 0;
|
$success = 0;
|
||||||
}
|
}
|
||||||
return {
|
return Peace::Model::Build->new(
|
||||||
output => $merged_output,
|
arch => $arch,
|
||||||
|
log => $merged_output,
|
||||||
success => $success,
|
success => $success,
|
||||||
};
|
release => $self,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,18 +336,14 @@ Peace::Model::Release implements the following methods:
|
|||||||
|
|
||||||
=head2 generate_build
|
=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
|
Attempts to build a flatpak for the release and
|
||||||
returns the success status, any false value failed,
|
unconditionally returns a L<Peace::Model::Build>
|
||||||
any true value succeded and the output which combines
|
object with the results of the build.
|
||||||
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.
|
|
||||||
|
|
||||||
=head2 uuid
|
=head2 uuid
|
||||||
|
|
||||||
|
@ -16,9 +16,15 @@ BEGIN {
|
|||||||
## GIVEN
|
## GIVEN
|
||||||
my $release = Peace::Test::Mock::Model::Release->new;
|
my $release = Peace::Test::Mock::Model::Release->new;
|
||||||
my $arch = 'x86';
|
my $arch = 'x86';
|
||||||
|
my $success = 1;
|
||||||
|
my $log = 'Built successfully.';
|
||||||
my $build = Peace::Model::Build->new(
|
my $build = Peace::Model::Build->new(
|
||||||
release => $release,
|
release => $release,
|
||||||
arch => $arch,
|
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',
|
tag => 'main',
|
||||||
name => 'test',
|
name => 'test',
|
||||||
);
|
);
|
||||||
my $result = $release->generate_build( arch => 'x86_64' );
|
my $build = $release->generate_build( arch => 'aarch64' );
|
||||||
ok $result->{success}, 'Build ends successfully.';
|
ok $build->success, 'Build ends successfully.';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user