Skip to content

Commit 0f00277

Browse files
committed
utils and docs
- moved XMLHelper to the util namespace - bumped version to 1.2.0 (and completely ignoring semver B-) ) - updated infection documentation with stdin2classtype-filter script description
1 parent c674fd6 commit 0f00277

File tree

8 files changed

+51
-14
lines changed

8 files changed

+51
-14
lines changed

doc/Infection.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,48 @@ this script collects the paths defined in your CODEOWNERS file for given codeown
3434
3535
this script accepts a list of files and intersects them with the paths defined in your CODEOWNERS file for given codeowner. the intersected result is printed as comma separated list which can be used as a filter value for, for example, php infection.
3636
37+
> [!CAUTION]
38+
> the `stdin2codeowner-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below).
39+
40+
### example config
41+
42+
> gitlab-ci-yml
43+
> ```yaml
44+
> php-infection:
45+
> stage: test
46+
> rules:
47+
> - <your code owner run conditions>
48+
> needs:
49+
> - phpunit-coverage
50+
> variables:
51+
> DEV_TEAM: '@team-awesome'
52+
> EXCLUDE_PATHS: '/old,/legacy'
53+
> MIN_COVERED_MSI: '98.00'
54+
> MIN_MSI: '95.00'
55+
> before_script:
56+
> - composer dump-autoload --optimize --ignore-platform-reqs
57+
> - git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA
58+
> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2codeowner-filter.pl)
59+
> script:
60+
> - ./vendor/bin/infection -j$(nproc) --filter=$INFECTION_FILTER --min-msi=$MIN_MSI --min-covered-msi=$MIN_COVERED_MSI --coverage=./coverage --skip-initial-tests
61+
> ```
62+
63+
64+
## stdin2classtype-filter
65+
66+
this script accepts a list of files and intersects them with the paths defined in your CODEOWNERS file for given codeowner.
67+
after which a given list of class types are excluded from that list. possible types are `class`, `interface`, `trait`, `enum`, `method_enum`.
68+
3769
### assumptions
3870
39-
this script assumes the presence of the CODEOWNERS file in the root directory of you project.
40-
though configurable in the `stdin2codeowner-filter.pl` file, for now no plans to make that configurable or accept it as input parameter.
71+
this script assumes the presence of the `PHP_EXCLUDE_TYPES` environment variable and should contain a comma separated list of class types to exclude.
4172
4273
> [!CAUTION]
43-
> the `stdin2codeowner-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below).
74+
> the `stdin2classtype-filter.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below).
75+
also the classes are expected to be conform PSR-4 standards (i.e. the filename matches the classname).
76+
77+
> [!NOTE]
78+
> enum class types are differentiated as `enum` and `method_enum` where the later is an enumeration containing methods (for which typically mutants _can_ be generated).
4479
4580
4681
### example config
@@ -58,10 +93,11 @@ though configurable in the `stdin2codeowner-filter.pl` file, for now no plans to
5893
> EXCLUDE_PATHS: '/old,/legacy'
5994
> MIN_COVERED_MSI: '98.00'
6095
> MIN_MSI: '95.00'
96+
> PHP_EXCLUDE_TYPES: 'interface,enum'
6197
> before_script:
6298
> - composer dump-autoload --optimize --ignore-platform-reqs
6399
> - git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA
64-
> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2codeowner-filter.pl)
100+
> - export INFECTION_FILTER=$(git diff $CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA --diff-filter=AMR --name-only -- '***.php' | .stdin2classtype-filter.pl)
65101
> script:
66102
> - ./vendor/bin/infection -j$(nproc) --filter=$INFECTION_FILTER --min-msi=$MIN_MSI --min-covered-msi=$MIN_COVERED_MSI --coverage=./coverage --skip-initial-tests
67103
> ```
@@ -91,3 +127,4 @@ this script assumes both `MIN_MSI` and `MIN_COVERED_MSI` are configured.
91127
> - set +e
92128
> - ./vendor/bin/infection | infection2escapee-warning.pl
93129
> ```
130+

lib/GPH.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package GPH;
33
use strict;
44
use warnings FATAL => 'all';
55

6-
our $VERSION = '1.1.3';
6+
our $VERSION = '1.2.0';
77

88
1;
99

lib/GPH/PHPMD.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44
use warnings FATAL => 'all';
55

66
use XML::LibXML;
7-
use GPH::XMLHelper;
7+
use GPH::Util::XMLHelper;
88

99
sub new {
1010
my ($class, %args) = @_;
@@ -14,7 +14,7 @@ sub new {
1414
my $self = {
1515
owner => $args{owner},
1616
cycloLevel => $args{cyclo_level},
17-
generator => GPH::XMLHelper->new(),
17+
generator => GPH::Util::XMLHelper->new(),
1818
};
1919

2020
bless $self, $class;

lib/GPH/Psalm.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44
use warnings FATAL => 'all';
55

66
use XML::LibXML;
7-
use GPH::XMLHelper;
7+
use GPH::Util::XMLHelper;
88

99
sub new {
1010
my ($class, %args) = @_;
@@ -23,7 +23,7 @@ sub new {
2323
baseline_check => $args{baseline_check} || 'true',
2424
cache_dir => $args{cache_dir} || './psalm',
2525
plugins => $plugins,
26-
generator => GPH::XMLHelper->new(),
26+
generator => GPH::Util::XMLHelper->new(),
2727
};
2828

2929
bless $self, $class;

lib/GPH/XMLHelper.pm renamed to lib/GPH/Util/XMLHelper.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package GPH::XMLHelper;
1+
package GPH::Util::XMLHelper;
22

33
use strict;
44
use warnings FATAL => 'all';

t/unit/GPH/PHPMD.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe "class `$CLASS`" => sub {
3636
field owner => '@teams/alpha';
3737
field cycloLevel => 3;
3838
field generator => object {
39-
prop blessed => 'GPH::XMLHelper';
39+
prop blessed => 'GPH::Util::XMLHelper';
4040
};
4141
end;
4242
},

t/unit/GPH/Psalm.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe 'configuration options' => sub {
9898
field cache_dir => $expected_cache_dir;
9999
field plugins => $expected_plugins;
100100
field generator => object {
101-
prop blessed => 'GPH::XMLHelper';
101+
prop blessed => 'GPH::Util::XMLHelper';
102102
};
103103
etc;
104104
},

t/unit/GPH/XMLHelper.t renamed to t/unit/GPH/Util/XMLHelper.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/perl
2-
package t::unit::GPH::XMLHelper;
2+
package t::unit::GPH::Util::XMLHelper;
33

44
use strict;
55
use warnings;
66

7-
use Test2::V0 -target => 'GPH::XMLHelper';
7+
use Test2::V0 -target => 'GPH::Util::XMLHelper';
88
use Test2::Tools::Spec;
99
use Data::Dumper;
1010

0 commit comments

Comments
 (0)