File Coverage

blib/lib/Dist/Zilla/Plugin/Author/CSSON/GithubActions/Role/Workflow.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 12 12 100.0
pod 0 2 0.0
total 44 46 95.6


line stmt bran cond sub pod time code
1 1     1   664 use 5.14.0;
  1         5  
2 1     1   7 use strict;
  1         3  
  1         37  
3 1     1   33 use warnings;
  1         4  
  1         89  
4              
5             package Dist::Zilla::Plugin::Author::CSSON::GithubActions::Role::Workflow;
6              
7             # ABSTRACT: Role used to define a GithubActions workflow
8             our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9             our $VERSION = '0.0103';
10              
11 1     1   8 use Moose::Role;
  1         2  
  1         25  
12 1     1   5492 use YAML::XS qw/Load/;
  1         3  
  1         73  
13 1     1   9 use Path::Tiny;
  1         3  
  1         64  
14 1     1   680 use File::ShareDir qw/dist_dir/;
  1         19028  
  1         61  
15 1     1   9 use Try::Tiny;
  1         3  
  1         223  
16             requires 'filepath';
17              
18             sub file_location {
19 10     10 0 26 my $self = shift;
20 10         35 my $package = $self->main_module;
21 10         65 $package =~ s{::}{-}g;
22              
23 10         46 my $dir = path('.');
24             try {
25 10     10   646 $dir = path(dist_dir($package));
26             }
27 10     10   387 finally { };
28              
29 10         157 return $dir->child($self->filepath);
30             }
31             sub yaml {
32 10     10 0 25 my $self = shift;
33 10         34 return Load($self->file_location->slurp);
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding UTF-8
43              
44             =head1 NAME
45              
46             Dist::Zilla::Plugin::Author::CSSON::GithubActions::Role::Workflow - Role used to define a GithubActions workflow
47              
48             =head1 VERSION
49              
50             Version 0.0103, released 2020-12-25.
51              
52             =head1 SYNOPSIS
53              
54             In C<share/your-workflow.yml>:
55              
56             ---
57             filename: 'base-workflow.yml'
58             name: 'dzil-test'
59             on:
60             push:
61             branches:
62             - '*'
63             pull_request:
64             branches:
65             - '*'
66              
67             jobs:
68             perl-job:
69             name: Perl ${{ matrix.perl-version }}
70             runs-on: ${{ matrix.os }}
71             strategy:
72             fail-fast: false
73             matrix:
74             perl-version:
75             - '5.32'
76             os:
77             - 'ubuntu-latest'
78             container: perldocker/perl-tester:${{ matrix.perl-version }}
79             steps:
80             - uses: actions/checkout@v2
81             - name: Dist::Zilla tests
82             run: |
83             dzil authordeps --missing | cpanm --notest
84             dzil listdeps --missing --author | cpanm
85             dzil test --release --author
86              
87             =head1 DESCRIPTION
88              
89             This class should be consumed by workflow classes.
90              
91             The only non-standard setting in the YAML file is C<filename>. This is the filename that will be created
92             in the C<.github/workflows> folder in the distribution that uses this plugin.
93              
94             See L<Dist::Zilla::Plugin::Author::CSSON::GithubActions::BaseWorkflow> for an example workflow.
95              
96             =cut
97              
98             =head1 SOURCE
99              
100             L<https://github.com/Csson/p5-Dist-Zilla-Plugin-Author-CSSON-GithubActions>
101              
102             =head1 HOMEPAGE
103              
104             L<https://metacpan.org/release/Dist-Zilla-Plugin-Author-CSSON-GithubActions>
105              
106             =head1 AUTHOR
107              
108             Erik Carlsson <info@code301.com>
109              
110             =head1 COPYRIGHT AND LICENSE
111              
112             This software is copyright (c) 2020 by Erik Carlsson.
113              
114             This is free software; you can redistribute it and/or modify it under
115             the same terms as the Perl 5 programming language system itself.
116              
117             =cut