Skip to content

Commit 8b4ca37

Browse files
Add php mess detector to validate the php code
1 parent 5411909 commit 8b4ca37

File tree

7 files changed

+920
-41
lines changed

7 files changed

+920
-41
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PHP validate and Unit Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
concurrency:
8+
group: test
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Validate composer.json and composer.lock
22+
run: composer validate --strict
23+
24+
- name: Cache Composer packages
25+
id: composer-cache
26+
uses: actions/cache@v3
27+
28+
- name: Create Environments
29+
run: echo "${{ secrets.TEST_ENV_VARIABLES }}" > .env
30+
31+
- name: Install and update Composer packages
32+
run: composer run-script install-dependencies
33+
34+
- name: Run test suite
35+
run: composer run-script phpunit-test
36+
37+
validate:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: Setup PHP
42+
uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
43+
with:
44+
php-version: '8.3'
45+
46+
- name: Checkout code
47+
uses: actions/checkout@v3
48+
49+
- name: Validate PHP version
50+
run: php -v
51+
52+
- name: Cache Composer packages
53+
id: composer-cache
54+
uses: actions/cache@v3
55+
56+
- name: Install and update Composer packages
57+
run: composer install --ignore-platform-reqs
58+
59+
- name: Run PHP mess detector
60+
run: composer run-script mess-detect

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"minimum-stability": "dev",
2929
"prefer-stable": true,
3030
"scripts": {
31-
"install-dependencies": "composer install --prefer-source",
32-
"phpunit-test": "vendor/bin/phpunit --colors=always --configuration phpunit.xml"
31+
"install-dependencies": "composer install --ignore-platform-reqs",
32+
"phpunit-test": "vendor/bin/phpunit --colors=always --configuration phpunit.xml",
33+
"mess-detect": "vendor/bin/phpmd ./src text phpmd.xml"
3334
},
3435
"require": {
3536
"php": ">=8.0",
@@ -41,6 +42,7 @@
4142
},
4243
"require-dev": {
4344
"fakerphp/faker": "^1.23",
45+
"phpmd/phpmd": "^2.15",
4446
"phpunit/phpunit": "^9.5",
4547
"psr/log": "^1.1|^2.0|^3.0"
4648
},

0 commit comments

Comments
 (0)