« blib/lib/Dist/Zilla/Plugin/DBIO/GatherSkills.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/DBIO/CodebergMeta.pm »
| 1 | package Dist::Zilla::PluginBundle::DBIO; | ||||||||||||||||||||
| 2 | # ABSTRACT: Dist::Zilla plugin bundle for DBIO distributions | ||||||||||||||||||||
| 3 | 8 | our $VERSION = '0.900007'; | |||||||||||||||||||
| 4 | 8 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 8 | ▶ | use Dist::Zilla; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 8 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 8 | ▶ | use Dist::Zilla::PluginBundle::Basic; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 8 | ▶ | use Dist::Zilla::PluginBundle::Git; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 8 | ▶ | use Dist::Zilla::PluginBundle::Git::VersionManager; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | has core => ( | ||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||
| 15 | isa => 'Bool', | ||||||||||||||||||||
| 16 | lazy => 1, | ||||||||||||||||||||
| 17 | 24 | ▶ | default => sub { $_[0]->payload->{core} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 8 | ); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | has heritage => ( | ||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||
| 23 | isa => 'Bool', | ||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||
| 25 | 24 | ▶ | default => sub { $_[0]->payload->{heritage} || 0 }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 8 | ); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | has copyright_holder => ( | ||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||
| 31 | isa => 'Maybe[Str]', | ||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||
| 33 | 24 | ▶ | default => sub { $_[0]->payload->{copyright_holder} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | 8 | ); | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | has eumm_version => ( | ||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||
| 39 | isa => 'Maybe[Str]', | ||||||||||||||||||||
| 40 | lazy => 1, | ||||||||||||||||||||
| 41 | 24 | ▶ | default => sub { $_[0]->payload->{eumm_version} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 8 | ); | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | has share_skill => ( | ||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||
| 47 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||
| 48 | lazy => 1, | ||||||||||||||||||||
| 49 | # Normalise to an arrayref. A direct [@DBIO] section aggregates repeated | ||||||||||||||||||||
| 50 | # keys via mvp_multivalue_args, but when the bundle is wrapped in [@Filter] | ||||||||||||||||||||
| 51 | # (the async drivers) the reader uses @Filter's multivalue list instead, so | ||||||||||||||||||||
| 52 | # a lone share_skill arrives as a plain scalar — accept both. | ||||||||||||||||||||
| 53 | 24 | ▶ | default => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 54 | 24 | my $v = $_[0]->payload->{share_skill}; | |||||||||||||||||||
| 55 | 24 | ▶ | return [] unless defined $v; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 2 | ▶ | return ref $v eq 'ARRAY' ? $v : [$v]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | }, | ||||||||||||||||||||
| 58 | 8 | ); | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 24 | ▶ | sub mvp_multivalue_args { qw(share_skill) } | ||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | has coverage_threshold => ( | ||||||||||||||||||||
| 64 | is => 'ro', | ||||||||||||||||||||
| 65 | isa => 'Int', | ||||||||||||||||||||
| 66 | lazy => 1, | ||||||||||||||||||||
| 67 | 24 | ▶ | default => sub { $_[0]->payload->{coverage_threshold} // 80 }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->payload->{"coverage_threshold"} // 80
MC/DC100%1/1
$_[0]->payload->{"coverage_threshold"} // 80
$_[0]->payload->{"coverage_threshold"}
Truth table100%2/2
A
A= $_[0]->payload->{"coverage_threshold"}
| |||||||||||||||||||||
| 68 | 8 | ); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 24 | ▶ | sub configure { | ||||||||||||||||||
|
Subroutine
configure: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||
| 71 | 24 | my ($self) = @_; | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | # Set author and copyright_holder via an inner BeforeBuild plugin — bundles have no $self->zilla | ||||||||||||||||||||
| 74 | 24 | ▶ | my $author = $self->heritage ? 'DBIO & DBIx::Class Authors' : 'DBIO Authors'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 24 | ▶ | my $holder = $self->copyright_holder // $author; | ||||||||||||||||||
|
Condition33%1/3
$self->copyright_holder // $author
MC/DC0%0/2
$self->copyright_holder // $author
$self->copyright_holder
$author
Truth table33%1/3
A // B
A= $self->copyright_holderB= $author
| |||||||||||||||||||||
| 76 | 24 | $self->add_plugins([ 'DBIO::SetMeta' => { author => $author, holder => $holder } ]); | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | # What is tracked in git ships; only build products stay out. LICENSE is a | ||||||||||||||||||||
| 79 | # committed file gathered here and checked by DBIO::LicenseFile. | ||||||||||||||||||||
| 80 | 24 | $self->add_plugins([ 'Git::GatherDir' => { | |||||||||||||||||||
| 81 | include_dotfiles => 1, | ||||||||||||||||||||
| 82 | exclude_filename => [qw( META.yml META.json MANIFEST README README.md .karr )], | ||||||||||||||||||||
| 83 | }]); | ||||||||||||||||||||
| 84 | 24 | $self->add_plugins([ 'DBIO::LicenseFile' => { heritage => $self->heritage } ]); | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | # Ship this dist's own agent skills as a sharedir (see DBIO::Skills). | ||||||||||||||||||||
| 87 | # Authored under .claude/skills/, copied into share/skills/ at build time. | ||||||||||||||||||||
| 88 | $self->add_plugins([ 'DBIO::GatherSkills' => | ||||||||||||||||||||
| 89 | 24 | ▶ | @{ $self->share_skill } ? { skill => $self->share_skill } : {} ]); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | 24 | $self->add_plugins('ShareDir'); | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | # Snapshot the full agent context (.claude/.codex/CLAUDE.md/...) into the build | ||||||||||||||||||||
| 93 | # under misc/agent-context/ for build provenance (not installed). This is | ||||||||||||||||||||
| 94 | # separate from GatherSkills above: GatherSkills ships only the owned dbio-* | ||||||||||||||||||||
| 95 | # skills as an installed runtime sharedir; GatherAgentContext records the whole | ||||||||||||||||||||
| 96 | # as-built context, including skilletor-installed (git-ignored) skills. | ||||||||||||||||||||
| 97 | 24 | $self->add_plugins('GatherAgentContext'); | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | # Metadata | ||||||||||||||||||||
| 100 | 24 | $self->add_plugins(qw( | |||||||||||||||||||
| 101 | MetaJSON | ||||||||||||||||||||
| 102 | MetaYAML | ||||||||||||||||||||
| 103 | MetaConfig | ||||||||||||||||||||
| 104 | MetaProvides::Package | ||||||||||||||||||||
| 105 | Prereqs::FromCPANfile | ||||||||||||||||||||
| 106 | )); | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | # Version — core and drivers alike through @Git::VersionManager: every module | ||||||||||||||||||||
| 109 | # under lib/ is rewritten to the version of the dist and raised after the release | ||||||||||||||||||||
| 110 | 24 | $self->add_bundle('@Git::VersionManager' => { | |||||||||||||||||||
| 111 | 'RewriteVersion::Transitional.global' => 1, | ||||||||||||||||||||
| 112 | 'RewriteVersion::Transitional.finder' => [':InstallModules'], | ||||||||||||||||||||
| 113 | 'BumpVersionAfterRelease.finder' => [':InstallModules'], | ||||||||||||||||||||
| 114 | 'RewriteVersion::Transitional.fallback_version_provider' => 'Git::NextVersion', | ||||||||||||||||||||
| 115 | 'Git::NextVersion.first_version' => '0.900000', | ||||||||||||||||||||
| 116 | 'Git::Tag.tag_format' => 'v%V', | ||||||||||||||||||||
| 117 | 'NextRelease.format' => '%-9v %{yyyy-MM-dd}d', | ||||||||||||||||||||
| 118 | }); | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | # POD — heritage uses @DBIO::Heritage which adds DBIx::Class attribution | ||||||||||||||||||||
| 121 | 24 | ▶ | $self->add_plugins([ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | PodWeaver => { | ||||||||||||||||||||
| 123 | config_plugin => $self->heritage ? '@DBIO::Heritage' : '@DBIO', | ||||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | ]); | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | # Tests | ||||||||||||||||||||
| 128 | # ExtraTests promotes the xt/ files gathered by PodCheckerTest and | ||||||||||||||||||||
| 129 | # VersionLockstepTest into t/. The order here is only for readability: | ||||||||||||||||||||
| 130 | # munging runs after all gathering. | ||||||||||||||||||||
| 131 | # PodCheckerTest gathers xt/author/pod-checker.t, promoted the same way: a | ||||||||||||||||||||
| 132 | # Pod::Checker run over the built (woven) POD under AUTHOR_TESTING. | ||||||||||||||||||||
| 133 | 24 | $self->add_plugins('DBIO::PodCheckerTest'); | |||||||||||||||||||
| 134 | # Core only: a test fails when a module deviates from the main module's | ||||||||||||||||||||
| 135 | # $VERSION, whatever the way it got out of step. | ||||||||||||||||||||
| 136 | 24 | ▶ | $self->add_plugins('DBIO::VersionLockstepTest') if $self->core; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 137 | 24 | $self->add_plugins('ExtraTests'); | |||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | # Scripts under bin/ are installed (and woven) for every dist; without a | ||||||||||||||||||||
| 140 | # bin/ the plugin finds nothing and the build is unchanged. | ||||||||||||||||||||
| 141 | 24 | $self->add_plugins([ 'ExecDir' => { dir => 'bin' } ]); | |||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | # Build — core uses MakeMaker::Awesome | ||||||||||||||||||||
| 144 | 24 | ▶ | if ($self->core) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 145 | 8 | ▶ | $self->add_plugins([ 'MakeMaker::Awesome' => | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 146 | { eumm_version => defined $self->eumm_version ? $self->eumm_version : '6.78' } ]); | ||||||||||||||||||||
| 147 | } elsif (defined $self->eumm_version) { | ||||||||||||||||||||
| 148 | 2 | $self->add_plugins([ 'MakeMaker' => { eumm_version => $self->eumm_version } ]); | |||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||
| 150 | 14 | $self->add_plugins('MakeMaker'); | |||||||||||||||||||
| 151 | } | ||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | # The coverage gate is a TestRunner: Dist::Zilla runs the TestRunners in | ||||||||||||||||||||
| 154 | # plugin order, so it stands behind the build plugin and judges cover_db/ | ||||||||||||||||||||
| 155 | # when the suite of the build directory is through. | ||||||||||||||||||||
| 156 | 24 | $self->add_plugins([ 'DBIO::CoverageGate' => { | |||||||||||||||||||
| 157 | coverage_threshold => $self->coverage_threshold, | ||||||||||||||||||||
| 158 | }]); | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | 24 | $self->add_plugins(qw( | |||||||||||||||||||
| 161 | Readme | ||||||||||||||||||||
| 162 | ManifestSkip | ||||||||||||||||||||
| 163 | Manifest | ||||||||||||||||||||
| 164 | )); | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | # Repository metadata — derived offline from the git remote | ||||||||||||||||||||
| 167 | # (Codeberg, or a Forgejo instance via host=), no API token. Replaces [GithubMeta] and the | ||||||||||||||||||||
| 168 | # external Dist::Zilla::Plugin::Codeberg::Meta. | ||||||||||||||||||||
| 169 | 24 | $self->add_plugins([ 'DBIO::CodebergMeta' => { issues => 1 } ]); | |||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | # IRC channel — fixed for the whole DBIO family (one source of truth), set | ||||||||||||||||||||
| 172 | # for every distribution rather than per-dist. No x_IRC_user. | ||||||||||||||||||||
| 173 | 24 | $self->add_plugins([ 'MetaResources' => { 'x_IRC' => 'irc://irc.perl.org/#dbio' } ]); | |||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | # Git checks | ||||||||||||||||||||
| 176 | 24 | $self->add_plugins([ 'Git::Check' => { | |||||||||||||||||||
| 177 | allow_dirty => [qw( dist.ini Changes cpanfile )], | ||||||||||||||||||||
| 178 | }]); | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 24 | $self->add_plugins([ | |||||||||||||||||||
| 181 | 'Git::CheckFor::CorrectBranch' => { release_branch => 'main' }, | ||||||||||||||||||||
| 182 | ]); | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | # Release workflow | ||||||||||||||||||||
| 185 | # A driver is released against the core version it was written for: its | ||||||||||||||||||||
| 186 | # runtime prereq on DBIO must be at least its own version (core is the | ||||||||||||||||||||
| 187 | # source of that version and has no such prereq). | ||||||||||||||||||||
| 188 | 24 | ▶ | my @release_checks = ( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 189 | ($self->core ? () : 'DBIO::RequireCoreVersion'), | ||||||||||||||||||||
| 190 | 'TestRelease', | ||||||||||||||||||||
| 191 | 'Test::ChangesHasContent', | ||||||||||||||||||||
| 192 | [ 'InstallRelease' => { install_command => 'cpanm .' } ], | ||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||
| 194 | # NextRelease, the release snapshot, the tag and the post-release commit | ||||||||||||||||||||
| 195 | # come from @Git::VersionManager above. | ||||||||||||||||||||
| 196 | 24 | $self->add_plugins( | |||||||||||||||||||
| 197 | @release_checks, | ||||||||||||||||||||
| 198 | 'ConfirmRelease', | ||||||||||||||||||||
| 199 | 'UploadToCPAN', | ||||||||||||||||||||
| 200 | [ 'Git::Push' => { push_to => 'origin' } ], | ||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||
| 202 | } | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | 8 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | __END__ | ||||||||||||||||||||