.github/dzil-binary/plan.pl

filter: Statementstmt 100% 67 / 67 Branchbran 75.0% 18 / 24 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 88.9% 97 / 109 CC 18 SCAR 23.1
CC
18
Cov
91%
plan
15.4
main
4.0
BEGIN
1.0
CRAP 10.1
« .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 89 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 89 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 81 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 81 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 81 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 81 ▶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 73 my $CONTAINER = 'almalinux:8@sha256:2d0f2eb2a83cc09dbc2eb92fade4dbe8f709628149e81aa00aec70630406603b';
14  
15 73 my @PLATFORMS = qw( linux-x86_64 linux-arm64 macos-arm64 macos-x86_64 windows-x86_64 );
16 73 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 73 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 38 ▶sub plan {
Subroutine plan: called CC=15 SCAR=27.3
32 38 my ($meta_file) = @_;
33 38 ▶ open my $fh, '<:raw', $meta_file or die "cannot read $meta_file: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:raw", $meta_file or die "cannot read ${meta_file}: $!\n" 46 0 46
34 38 my $meta = eval { JSON::PP->new->decode(do { local $/; <$fh> }) };
35 38 ▶ die "$meta_file is not valid JSON: $@" unless $meta;
Branch: 1 branch
BranchTrueFalseTotal
unless $meta 0 38 38
36 38 my $x = $meta->{x_binaries};
37 38 ▶ die "$meta_file has no x_binaries\n" unless ref $x eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x eq "HASH" 1 37 38
38  
39 37 my $want = $x->{platforms};
40 37 ▶ $want = [@PLATFORMS] unless ref $want eq 'ARRAY' && @$want;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $want eq "ARRAY" and @$want 0 37 37
Condition33%1/3
ref $want eq "ARRAY" and @$want
!ll&&!rl&&r
0037
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
ABresult
0X0
100
111
41 37 my %seen;
42 37 for my $p (@$want) {
43 92 ▶ die "x_binaries: unknown platform '$p'\n" unless $RUNNER{$p};
Branch: 1 branch
BranchTrueFalseTotal
unless $RUNNER{$p} 0 92 92
44 92 $seen{$p} = 1;
45 }
46 37 my @use = grep { $seen{$_} } @PLATFORMS;
47  
48 37 my (@legs, @smoke);
49 37 for my $p (@use) {
50 92 ▶ push @legs, { platform => $p, runner => $RUNNER{$p},
Branch: 1 branch
BranchTrueFalseTotal
$p =~ /\Alinux-/ ? : 43 49 92
51 ($p =~ /\Alinux-/ ? (container => $CONTAINER) : ()) };
52 92 my $s = $SMOKE{$p};
53 92 ▶ if ($s->{images}) { push @smoke, { platform => $p, runner => $s->{runner}, image => $_ } for @{ $s->{images} } }
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{'images'}) { } 43 49 92
54 49 else { push @smoke, { platform => $p, runner => $s->{runner} } }
55 }
56  
57 37 my $key = 'none';
58 37 my $prepare = $x->{prepare};
59 37 ▶ if (defined $prepare && $prepare =~ /\S/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prepare and $prepare =~ /\S/) 5 32 37
Condition66%2/3
defined $prepare and $prepare =~ /\S/
!ll&&!rl&&r
3205
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/
ABresult
0X0
100
111
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
BranchTrueFalseTotal
unless -f $file 1 4 5
63 4 $key = Digest::SHA->new(256)->addfile($file, 'b')->hexdigest;
64 }
65  
66 36 my $json = JSON::PP->new->canonical;
67 36 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
BranchTrueFalseTotal
unless @args == 1 0 8 8
73 8 my @lines = eval { plan($args[0]) };
74 8 ▶ if ($@) { print STDERR $@; return 1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 6 8
75 6 print "$_\n" for @lines;
76 6 return 0;
77 }
78  
79 73 ▶exit main(@ARGV) unless caller;
Branch: 1 branch
BranchTrueFalseTotal
unless caller 0 73 73
80 73 1;
« .github/dzil-binary/lib-gate.pl ↑ Summary blib/lib/Dist/Zilla/PluginBundle/Author/GETTY/Binary.pm »