.github/dzil-binary/plan.pl

filter: Statementstmt 100% 66 / 66 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.8% 96 / 108 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 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
BranchTrueFalseTotal
open my $fh, "<:raw", $meta_file or die "cannot read ${meta_file}: $!\n" 8 0 8
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
BranchTrueFalseTotal
unless $meta 0 8 8
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
BranchTrueFalseTotal
unless ref $x eq "HASH" 1 7 8
38  
39 7 my $want = $x->{platforms};
40 7 ▶ $want = [@PLATFORMS] unless ref $want eq 'ARRAY' && @$want;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $want eq "ARRAY" and @$want 0 7 7
Condition33%1/3
ref $want eq "ARRAY" and @$want
!ll&&!rl&&r
007
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 7 my %seen;
42 7 for my $p (@$want) {
43 32 ▶ die "x_binaries: unknown platform '$p'\n" unless $RUNNER{$p};
Branch: 1 branch
BranchTrueFalseTotal
unless $RUNNER{$p} 0 32 32
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
BranchTrueFalseTotal
$p =~ /\Alinux-/ ? : 13 19 32
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
BranchTrueFalseTotal
if ($s->{'images'}) { } 13 19 32
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
BranchTrueFalseTotal
if (defined $prepare and $prepare =~ /\S/) 5 2 7
Condition66%2/3
defined $prepare and $prepare =~ /\S/
!ll&&!rl&&r
205
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 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
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 8 ▶exit main(@ARGV) unless caller;
Branch: 1 branch
BranchTrueFalseTotal
unless caller 8 0 8
80 1;
« .github/dzil-binary/lib-gate.pl ↑ Summary blib/lib/Dist/Zilla/PluginBundle/Author/GETTY/Binary.pm »