« .github/dzil-binary/lib-gate.pl
↑ Summary
blib/lib/Dist/Zilla/PluginBundle/Author/GETTY/Binary.pm »
| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | # Build/smoke matrix of the binary release workflow. | ||||||||||||||||||||||||||||
| 3 | # plan.pl <META.json> -> legs=<json> / smoke=<json> / prepare_key=<hex|none> | ||||||||||||||||||||||||||||
| 4 | package DzilBinary::Plan; | ||||||||||||||||||||||||||||
| 5 | 37 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 37 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 37 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 37 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 37 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 37 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # almalinux:8 OCI index (manifest list) digest, read from Docker Hub on 2026-11-06. | ||||||||||||||||||||||||||||
| 13 | 8 | my $CONTAINER = 'almalinux:8@sha256:2d0f2eb2a83cc09dbc2eb92fade4dbe8f709628149e81aa00aec70630406603b'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | my @PLATFORMS = qw( linux-x86_64 linux-arm64 macos-arm64 macos-x86_64 windows-x86_64 ); | |||||||||||||||||||||||||||
| 16 | 8 | my %RUNNER = ( | |||||||||||||||||||||||||||
| 17 | 'linux-x86_64' => 'ubuntu-24.04', | ||||||||||||||||||||||||||||
| 18 | 'linux-arm64' => 'ubuntu-24.04-arm', | ||||||||||||||||||||||||||||
| 19 | 'macos-arm64' => 'macos-15', | ||||||||||||||||||||||||||||
| 20 | 'macos-x86_64' => 'macos-15-intel', | ||||||||||||||||||||||||||||
| 21 | 'windows-x86_64' => 'windows-2025', | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | 8 | my %SMOKE = ( | |||||||||||||||||||||||||||
| 24 | 'linux-x86_64' => { runner => 'ubuntu-24.04', images => [qw( almalinux:8 almalinux:9 debian:bookworm-slim )] }, | ||||||||||||||||||||||||||||
| 25 | 'linux-arm64' => { runner => 'ubuntu-24.04-arm', images => [qw( almalinux:9 )] }, | ||||||||||||||||||||||||||||
| 26 | 'macos-arm64' => { runner => 'macos-26' }, | ||||||||||||||||||||||||||||
| 27 | 'macos-x86_64' => { runner => 'macos-26-intel' }, | ||||||||||||||||||||||||||||
| 28 | 'windows-x86_64' => { runner => 'windows-2022' }, | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 8 | ▶ | sub plan { | ||||||||||||||||||||||||||
|
Subroutine
plan: called CC=15 SCAR=27.3
| |||||||||||||||||||||||||||||
| 32 | 8 | my ($meta_file) = @_; | |||||||||||||||||||||||||||
| 33 | 8 | ▶ | open my $fh, '<:raw', $meta_file or die "cannot read $meta_file: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 8 | my $meta = eval { JSON::PP->new->decode(do { local $/; <$fh> }) }; | |||||||||||||||||||||||||||
| 35 | 8 | ▶ | die "$meta_file is not valid JSON: $@" unless $meta; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 8 | my $x = $meta->{x_binaries}; | |||||||||||||||||||||||||||
| 37 | 8 | ▶ | die "$meta_file has no x_binaries\n" unless ref $x eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 7 | my $want = $x->{platforms}; | |||||||||||||||||||||||||||
| 40 | 7 | ▶ | $want = [@PLATFORMS] unless ref $want eq 'ARRAY' && @$want; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $want eq "ARRAY" and @$want
MC/DC0%0/2
ref $want eq "ARRAY" and @$want
ref $want eq "ARRAY"
@$want
Truth table33%1/3
A and B
A= ref $want eq "ARRAY"B= @$want
| |||||||||||||||||||||||||||||
| 41 | 7 | my %seen; | |||||||||||||||||||||||||||
| 42 | 7 | for my $p (@$want) { | |||||||||||||||||||||||||||
| 43 | 32 | ▶ | die "x_binaries: unknown platform '$p'\n" unless $RUNNER{$p}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 32 | $seen{$p} = 1; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 7 | my @use = grep { $seen{$_} } @PLATFORMS; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 7 | my (@legs, @smoke); | |||||||||||||||||||||||||||
| 49 | 7 | for my $p (@use) { | |||||||||||||||||||||||||||
| 50 | 32 | ▶ | push @legs, { platform => $p, runner => $RUNNER{$p}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | ($p =~ /\Alinux-/ ? (container => $CONTAINER) : ()) }; | ||||||||||||||||||||||||||||
| 52 | 32 | my $s = $SMOKE{$p}; | |||||||||||||||||||||||||||
| 53 | 32 | ▶ | if ($s->{images}) { push @smoke, { platform => $p, runner => $s->{runner}, image => $_ } for @{ $s->{images} } } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 19 | else { push @smoke, { platform => $p, runner => $s->{runner} } } | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 7 | my $key = 'none'; | |||||||||||||||||||||||||||
| 58 | 7 | my $prepare = $x->{prepare}; | |||||||||||||||||||||||||||
| 59 | 7 | ▶ | if (defined $prepare && $prepare =~ /\S/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $prepare and $prepare =~ /\S/
MC/DC50%1/2
defined $prepare and $prepare =~ /\S/
defined $prepare
$prepare =~ /\S/
Truth table66%2/3
A and B
A= defined $prepareB= $prepare =~ /\S/
| |||||||||||||||||||||||||||||
| 60 | 5 | my ($first) = $prepare =~ /\A\s*(\S+)/; | |||||||||||||||||||||||||||
| 61 | 5 | my $file = File::Spec->catfile(File::Basename::dirname($meta_file), $first); | |||||||||||||||||||||||||||
| 62 | 5 | ▶ | die "x_binaries prepare: '$first' is not a file in the dist ($file)\n" unless -f $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 4 | $key = Digest::SHA->new(256)->addfile($file, 'b')->hexdigest; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 6 | my $json = JSON::PP->new->canonical; | |||||||||||||||||||||||||||
| 67 | 6 | return ("legs=" . $json->encode(\@legs), "smoke=" . $json->encode(\@smoke), "prepare_key=$key"); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 8 | ▶ | sub main { | ||||||||||||||||||||||||||
|
Subroutine
main: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 71 | 8 | my (@args) = @_; | |||||||||||||||||||||||||||
| 72 | 8 | ▶ | die "usage: plan.pl <META.json>\n" unless @args == 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 8 | my @lines = eval { plan($args[0]) }; | |||||||||||||||||||||||||||
| 74 | 8 | ▶ | if ($@) { print STDERR $@; return 1 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 6 | print "$_\n" for @lines; | |||||||||||||||||||||||||||
| 76 | 6 | return 0; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 8 | ▶ | exit main(@ARGV) unless caller; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 1; | ||||||||||||||||||||||||||||