App-Actions
view release on metacpan or search on metacpan
lib/App/Actions/Runner/Containers.pm view on Meta::CPAN
=over 4
=item * B<Always call L</remove_all> at the end of a run>, even after an
error, unless the run keeps its containers. Otherwise containers and
networks are left on the computer.
=item * B<Pass the same C<\@started> list to the start and clean-up
calls.> L</cleanup_job> removes what is in that list, newest first.
=item * B<A service must keep running.> A database image that exits at
once (for example because a required password variable is missing) fails
the job, with its last log lines in the message.
=item * B<Service ports are not published.> Steps reach a service by its
id on the job's network (C<postgres:5432>), not on C<localhost>. Only
C<ports:> mappings in the workflow publish ports on your computer.
=item * B<Container options from the workflow are passed to Docker as they
are.> C<container.options> and C<container.volumes> can mount any folder
of your computer. Run only workflows you trust.
q{Unable to read the container options '--env "A=${{ env.SECRET }}': a quote is not closed},
'options with an unclosed quote, quoted as written');
my ($error, $started, $object) = $start->({ db => 'postgres' }, container_start => 125);
throws_code(sub { die $error }, 'runner.service.start_failed', q{Failed to start service 'db' (exit 125)},
'a service the daemon will not start');
is_deeply($started, [ 'action-run-34567890-1-svc-build-1-db' ], 'is still in the started list');
is_deeply($object->remaining->{containers}, $started, 'and remembered for removal');
($error) = $start->({ db => 'postgres' }, container_running => 0, container_exit_code => 1,
container_log_text => "starting\r\nFATAL: no password\r\n\n \n");
my $stopped = throws_code(sub { die $error }, 'runner.container.stopped',
"Service 'db' did not stay running (exit 1); its last output was:\n starting\n FATAL: no password",
'a service that stopped, with its last output');
is("$stopped", $stopped->message . "\n", 'which reads as its message, without a source line');
($error) = $start->({ db => 'postgres' }, container_running => 0);
throws_code(sub { die $error }, 'runner.container.stopped',
q{Service 'db' did not stay running (its exit status could not be read); it printed nothing}, 'one that said nothing');
($error) = $start->({ db => 'postgres' }, container_status => 'restarting', container_restart_count => 3, container_log_text => "oops\n");
throws_code(sub { die $error }, 'runner.container.restarting',
"Service 'db' is restarting (restart count 3); its last output was:\n oops", 'a service that keeps restarting');
};
( run in 2.525 seconds using v1.01-cache-2.11-cpan-f5f21f1076c )