Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to convert TAP to GHA workflow commands #1052

Merged
merged 3 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/format_tap.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/perl
#
# Write a summary of a TAP file in a format suitable for Buildkite Annotations

use strict;
use warnings FATAL => 'all';

Expand Down
57 changes: 57 additions & 0 deletions scripts/tap_to_gha.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/perl
#
# Write a summary of a TAP file in a format suitable for Github Actions output
#
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions

use strict;
use warnings FATAL => 'all';

use TAP::Parser;

my $RED = "\e[31m";
my $RESET_FG = "\e[39m";

my $tap_file = $ARGV[0];

my $parser = TAP::Parser->new( { source => $tap_file } );
my $in_error = 0;
my $expected_fail = 0;

while ( my $result = $parser->next ) {
if ( $result->is_test ) {
# conclude any previous error block
if( $in_error ) {
print "::endgroup::\n"
}

$in_error = 0;

if ( not $result->is_ok ) {
$in_error = 1;

my $number = $result->number;
my $description = $result->description;

print "::error ::FAILURE: #$number: $description\n";
print "::group::Logs\n"
} elsif ( $result->directive and not $result->is_actual_ok ) {
$expected_fail++;
}
} elsif ( $result->is_comment and $in_error == 1 ) {
print $result->raw, "\n";
}
}

if( $in_error ) {
print "::endgroup::\n"
}

printf "Totals: %i passed, %i expected fail, %i failed\n", (
# actual_passed includes unexpected passes (ie expected failures which accidentally passed)
scalar $parser->actual_passed,
$expected_fail,
scalar $parser->failed,
);

exit 1 if $parser->failed;