Skip to content

Commit 322fbd7

Browse files
authored
refactor modules (#8)
- moved everything to GPH namespace - added unit tests for all modules - added makefile - added github workflow action - refactored PHPUnit statistics calculation
1 parent ffec9a2 commit 322fbd7

40 files changed

+2220
-329
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "continuous integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
9+
jobs:
10+
unit-tests:
11+
name: "unit tests"
12+
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
perl-version:
21+
- '5.36'
22+
- '5.34'
23+
- '5.32'
24+
- '5.30'
25+
- '5.28'
26+
- '5.26'
27+
- '5.24'
28+
- '5.22'
29+
- '5.20'
30+
- '5.18'
31+
- '5.16'
32+
include:
33+
- name: ' (all)'
34+
os: ubuntu-latest
35+
perl-version: '5.38'
36+
cover: true
37+
38+
container:
39+
image: perldocker/perl-tester:${{ matrix.perl-version }}
40+
41+
steps:
42+
- uses: actions/checkout@main
43+
with:
44+
submodules: recursive
45+
- name: perl version
46+
run: perl -V
47+
- name: install dependencies
48+
run: cpanm --notest --installdeps --verbose .
49+
50+
- if: ${{ matrix.cover }}
51+
run: cpanm -n Devel::Cover::Report::Coveralls
52+
53+
- name: build
54+
run: |
55+
perl Makefile.PL
56+
make
57+
58+
- if: ${{ matrix.cover }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: cover -report Coveralls -test
62+
63+
- if: ${{ matrix.cover }}
64+
name: Upload coverage reports to Codecov
65+
uses: codecov/[email protected]
66+
env:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
slug: wickedOne/gitlab-perl-helpers
69+
70+
- if: ${{ !matrix.cover }}
71+
run: prove -wlvmbr t
72+

Makefile.PL

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use strict;
2+
use warnings;
3+
4+
use ExtUtils::MakeMaker;
5+
6+
WriteMakefile(
7+
ABSTRACT => "collection of perl helpers for implementing code owner specific gitlab ci steps.",
8+
AUTHOR => "wicliff wolda <wicliff.wolda\@gmail.com>",
9+
NAME => 'GPH',
10+
VERSION_FROM => 'lib/GPH.pm',
11+
LICENSE => 'perl',
12+
PREREQ_PM => {
13+
"File::Basename" => 0,
14+
"Time::Piece" => 0,
15+
"XML::LibXML" => 0
16+
},
17+
CONFIGURE_REQUIRES => {
18+
"ExtUtils::MakeMaker" => 0
19+
},
20+
TEST_REQUIRES => {
21+
"Test2::V0" => 0,
22+
"Test2::Tools::Spec" => 0,
23+
"Data::Dumper" => 0,
24+
},
25+
'test' => {
26+
TESTS => 't/unit/GPH/*.t t/unit/GPH/*/*.t'
27+
}
28+
);
29+

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![codecov](https://codecov.io/gh/wickedOne/gitlab-perl-helpers/graph/badge.svg?token=J4SE1MBNOX)](https://codecov.io/gh/wickedOne/gitlab-perl-helpers)
2+
13
# gitlab-perl-helpers
24

35
collection of perl helpers for implementing code owner specific gitlab ci steps.

codeowner2infection-filter.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use Gitlab;
8+
use GPH::Gitlab;
99

1010
use constant CODEOWNERS_FILE => './CODEOWNERS';
1111

@@ -14,6 +14,6 @@
1414
my $paths = $ENV{'EXCLUDE_PATHS'} || '';
1515
my @excludes = split /,/, $paths;
1616

17-
my $gitlab = Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
17+
my $gitlab = GPH::Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
1818

19-
print $gitlab->GetCommaSeparatedPathList();
19+
print $gitlab->getCommaSeparatedPathList();

codeowner2phpmd.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use PHPMD;
8+
use GPH::PHPMD;
99

1010
my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var";
1111
my $cycloLevel = $ENV{'CYCLO_LEVEL'} || 10;
1212

13-
my $phpmd = PHPMD->new($owner, $cycloLevel);
13+
my $phpmd = GPH::PHPMD->new($owner, $cycloLevel);
1414

15-
print $phpmd->GetConfig();
15+
print $phpmd->getConfig();

codeowner2phpstan.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use Gitlab;
9-
use PHPStan;
8+
use GPH::Gitlab;
9+
use GPH::PHPStan;
1010

1111
use constant CODEOWNERS_FILE => './CODEOWNERS';
1212

@@ -24,11 +24,11 @@
2424
my @includes = split /,/, $includes;
2525
my $threads = $ENV{'PHPSTAN_THREADS'} || undef;
2626

27-
my $gitlab = Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
27+
my $gitlab = GPH::Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
2828

2929
# merge ignored dirs with blacklist
30-
@ignored = (@ignored, $gitlab->GetBlacklistPaths());
30+
@ignored = (@ignored, $gitlab->getBlacklistPaths());
3131

32-
my $phpstan = PHPStan->new($level, $gitlab->GetPathsReference(), $baseline, \@ignored, $cacheDir, \@includes, $threads);
32+
my $phpstan = GPH::PHPStan->new($level, $gitlab->getPathsReference(), $baseline, \@ignored, $cacheDir, \@includes, $threads);
3333

34-
print $phpstan->GetConfig();
34+
print $phpstan->getConfig();

codeowner2psalm.pl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use Gitlab;
9-
use Psalm;
8+
use GPH::Gitlab;
9+
use GPH::Psalm;
1010

1111
use constant CODEOWNERS_FILE => './CODEOWNERS';
1212
use constant PSALM_CONFIG => './psalm.xml';
@@ -26,18 +26,18 @@
2626
my @plugins = split /,/, $plugin;
2727
my $clone = defined($ENV{'PSALM_CLONE_HANDLERS'}) ? $ENV{'PSALM_CLONE_HANDLERS'} : 1;
2828

29-
my $gitlab = Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
29+
my $gitlab = GPH::Gitlab->new(CODEOWNERS_FILE, $owner, @excludes);
3030

3131
# merge ignored dirs with blacklist
32-
@ignored = (@ignored, $gitlab->GetBlacklistPaths());
32+
@ignored = (@ignored, $gitlab->getBlacklistPaths());
3333

34-
my $psalm = Psalm->new($level, $gitlab->GetPathsReference(), $baseline, $baselineCheck, \@ignored, $cacheDir, \@plugins);
34+
my $psalm = GPH::Psalm->new($level, $gitlab->getPathsReference(), $baseline, $baselineCheck, \@ignored, $cacheDir, \@plugins);
3535

3636
if ($clone) {
3737
my $excludeHandlers = $ENV{'PSALM_EXCLUDE_HANDLERS'} || '';
3838
my @blacklist = split /,/, $excludeHandlers;
3939

40-
print $psalm->GetConfigWithIssueHandlers(PSALM_CONFIG, @blacklist);
40+
print $psalm->getConfigWithIssueHandlers(PSALM_CONFIG, @blacklist);
4141
} else {
42-
print $psalm->GetConfig();
42+
print $psalm->getConfig();
4343
}

coverage2codeowner.pl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use PHPUnit;
8+
use GPH::PHPUnit;
99

1010
use constant CLASSMAP_FILE => './vendor/composer/autoload_classmap.php';
1111
use constant CODEOWNERS_FILE => './CODEOWNERS';
@@ -19,6 +19,6 @@
1919

2020
my $baseline = $ENV{'PHPUNIT_BASELINE'} || undef;
2121

22-
my $phpunit = PHPUnit->new($owner, CODEOWNERS_FILE, CLASSMAP_FILE, $coverage, \@excludes, $baseline);
22+
my $phpunit = GPH::PHPUnit->new($owner, CODEOWNERS_FILE, CLASSMAP_FILE, $coverage, \@excludes, $baseline);
2323

24-
exit $phpunit->Parse();
24+
exit $phpunit->parse();

infection2escapee-warning.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use File::Basename;
66
use lib dirname(__FILE__) . '/lib/';
77

8-
use Infection;
8+
use GPH::Infection;
99

10-
my $infection = Infection->new($ENV{'MIN_MSI'}, $ENV{'MIN_COVERED_MSI'}, 8);
10+
my $infection = GPH::Infection->new($ENV{'MIN_MSI'}, $ENV{'MIN_COVERED_MSI'}, 8);
1111

1212
exit $infection->Parse();

lib/GPH.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package GPH;
2+
3+
use strict;
4+
use warnings FATAL => 'all';
5+
6+
our $VERSION = '0.0.1';
7+
8+
1;

0 commit comments

Comments
 (0)