Skip to content

Commit 28604ad

Browse files
author
Greg Bowler
authored
Strengthen tests with mess detector & code sniffer (#42)
* build: hard dependencies * test: ensure asArray is called * maintenance: phpstan * test: code sniffer tests * wip: mess detector - working on reducing complexity * maintenance: static analysis * test: pass existing tests * test: phpmd and phpcs * test: test coverage
1 parent d1f1429 commit 28604ad

File tree

14 files changed

+1676
-240
lines changed

14 files changed

+1676
-240
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on: [push]
55
jobs:
66
composer:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php: [ 8.1, 8.2 ]
811

912
steps:
1013
- uses: actions/checkout@v3
@@ -18,7 +21,7 @@ jobs:
1821
- name: Composer install
1922
uses: php-actions/composer@v6
2023
with:
21-
php_version: 8.1
24+
php_version: ${{ matrix.php }}
2225

2326
- name: Archive build
2427
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
@@ -31,7 +34,10 @@ jobs:
3134

3235
phpunit:
3336
runs-on: ubuntu-latest
34-
needs: [composer]
37+
needs: [ composer ]
38+
strategy:
39+
matrix:
40+
php: [ 8.1, 8.2 ]
3541

3642
outputs:
3743
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
@@ -50,7 +56,7 @@ jobs:
5056
env:
5157
XDEBUG_MODE: cover
5258
with:
53-
php_version: 8.1
59+
php_version: ${{ matrix.php }}
5460
php_extensions: xdebug
5561
configuration: test/phpunit/phpunit.xml
5662
bootstrap: vendor/autoload.php
@@ -83,7 +89,10 @@ jobs:
8389

8490
phpstan:
8591
runs-on: ubuntu-latest
86-
needs: [composer]
92+
needs: [ composer ]
93+
strategy:
94+
matrix:
95+
php: [ 8.1, 8.2 ]
8796

8897
steps:
8998
- uses: actions/download-artifact@v3
@@ -97,8 +106,56 @@ jobs:
97106
- name: PHP Static Analysis
98107
uses: php-actions/phpstan@v3
99108
with:
109+
php_version: ${{ matrix.php }}
100110
path: src/
101111

112+
phpmd:
113+
runs-on: ubuntu-latest
114+
needs: [ composer ]
115+
strategy:
116+
matrix:
117+
php: [ 8.1, 8.2 ]
118+
119+
steps:
120+
- uses: actions/download-artifact@v3
121+
with:
122+
name: build-artifact
123+
path: /tmp/github-actions
124+
125+
- name: Extract build archive
126+
run: tar -xvf /tmp/github-actions/build.tar ./
127+
128+
- name: PHP Mess Detector
129+
uses: php-actions/phpmd@v1
130+
with:
131+
php_version: ${{ matrix.php }}
132+
path: src/
133+
output: text
134+
ruleset: phpmd.xml
135+
136+
phpcs:
137+
runs-on: ubuntu-latest
138+
needs: [ composer ]
139+
strategy:
140+
matrix:
141+
php: [ 8.1, 8.2 ]
142+
143+
steps:
144+
- uses: actions/download-artifact@v3
145+
with:
146+
name: build-artifact
147+
path: /tmp/github-actions
148+
149+
- name: Extract build archive
150+
run: tar -xvf /tmp/github-actions/build.tar ./
151+
152+
- name: PHP Code Sniffer
153+
uses: php-actions/phpcs@v1
154+
with:
155+
php_version: ${{ matrix.php }}
156+
path: src/
157+
standard: phpcs.xml
158+
102159
remove_old_artifacts:
103160
runs-on: ubuntu-latest
104161

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
},
1616

1717
"require-dev": {
18-
"phpunit/phpunit": "^10",
19-
"phpstan/phpstan": "^1.7.2"
18+
"phpunit/phpunit": "^10.0",
19+
"phpstan/phpstan": "^1.10",
20+
"phpmd/phpmd": "^2.13",
21+
"squizlabs/php_codesniffer": "^3.7"
2022
},
2123

2224
"autoload": {

0 commit comments

Comments
 (0)