App-Actions

 view release on metacpan or  search on metacpan

t/integration.t  view on Meta::CPAN

	my ($passing, $failing) = (project($PASSING), project($CASCADE =~ s{^(\s+)runs-on: ubuntu-latest\n}{$1runs-on: ubuntu-latest\n$1container: $config{other_image}\n}mgr));
	my ($passing_daemon, $failing_daemon) = (daemon(), daemon());
	my ($passing_record, $failing_record) = map { File::Spec->catfile(tempdir(CLEANUP => 1), 'cache.json') } 1 .. 2;
	my (@passing_log, @failing_log);

	my $one = actions($passing, cache_file => $passing_record, logger => \@passing_log);
	my $two = actions($failing, cache_file => $failing_record, logger => \@failing_log);
	isnt($one->workflow, $two->workflow, 'each has its own workflow');

	my $only_lint = with_daemon($passing_daemon, {}, sub { captured(sub { $one->run(jobs => [ 'lint' ]) }) });
	my $cascade = with_daemon($failing_daemon, {}, sub { captured(sub { $two->run }) });
	my $whole = with_daemon($passing_daemon, {}, sub { captured(sub { $one->run }) });

	is_deeply([ sort keys %{ summary($only_lint->{stdout}) } ], [ 'lint' ], 'an override selects jobs for one run');
	is(scalar keys %{ summary($whole->{stdout}) }, scalar @{ $config{matrix} } + 1,
		'and does not stay behind for the next run of the same object');
	is($whole->{result}, $config{exit}{success}, 'the passing workflow passes');
	is($cascade->{result}, $config{exit}{failure}, 'while the other fails');

	is_deeply(\@passing_log, [], 'the failure is not reported to the other object\'s logger');
	ok(scalar @{ messages(\@failing_log, 'error') }, 'but to its own');

	is_deeply([ map { $_->{image} } @{ App::Actions::Cache->new(file => $passing_record)->entries } ], [ $config{image} ],
		'one record holds only the image its object pulled');
	is_deeply([ map { $_->{image} } @{ App::Actions::Cache->new(file => $failing_record)->entries } ], [ $config{other_image} ],
		'and the other only its own');
	ok(!(grep { grep { $_ eq $config{other_image} } @{$_} } @{ commands($passing_daemon) }),
		'and neither daemon was asked about the other\'s image');
};

subtest 'a failing job is reported to the logger and does not bring down the others' => sub {
	# A step that fails is a job that fails: the jobs that need it are
	# skipped, an independent job still runs, and the error goes to the
	# logger rather than to standard error.
	my @logger;
	my $actions = actions(project($CASCADE), logger => \@logger);
	my $run = with_daemon(daemon(), {}, sub { captured(sub { $actions->run }) });
	verbose_diag('cascade', $run);

	is($run->{result}, $config{exit}{failure}, 'the run reports that a job failed');
	is_deeply(summary($run->{stdout}), { build => 'failure', test => 'skipped', docs => 'success' },
		'the job that needs the failed one is skipped, and the other one still runs');
	like(messages(\@logger, 'error')->[0], qr/\b$config{step_status}\b/, 'the logger is told the status the step exited with');
	is($run->{stderr}, '', 'and nothing is printed to standard error');
};

subtest 'preflight prepares the images and returns a valid document' => sub {
	# preflight runs the check and the image preparation a run makes before



( run in 0.391 second using v1.01-cache-2.11-cpan-f1796dc4e6b )