Skip to content

Commit 9aad242

Browse files
committed
Longitude-One quality tools added
1 parent 804498e commit 9aad242

19 files changed

+929
-31
lines changed

.github/workflows/full.yaml

+96-8
Original file line numberDiff line numberDiff line change
@@ -59,49 +59,137 @@ jobs:
5959
--health-timeout 5s
6060
--health-retries 5
6161
steps:
62-
- uses: actions/checkout@v4
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
6365
- name: Validate composer.json
6466
run: composer validate --strict
65-
- name: Get Composer Cache Directory
67+
68+
- name: Display Composer Cache Directory
6669
id: composer-cache
6770
run: |
6871
echo "::set-output name=dir::$(composer config cache-files-dir)"
69-
- uses: actions/cache@v4
72+
73+
- name: Restore cache Composer dependencies
74+
uses: actions/cache@v4
7075
with:
7176
path: ${{ steps.composer-cache.outputs.dir }}
7277
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7378
restore-keys: |
7479
${{ runner.os }}-composer-
80+
7581
- name: Setup PHP ${{ matrix.php }}
7682
uses: shivammathur/setup-php@v2
7783
with:
7884
php-version: ${{ matrix.php }}
7985
coverage: pcov
8086
tools: composer:v2
87+
8188
- name: Echo PHP version
8289
run: php -v
83-
- name: Copy testsuites
90+
91+
- name: Copy test suites
8492
run: cp .github/phpunit.*.xml .
93+
8594
- name: Install libraries
8695
run: composer --prefer-stable update -vvv
96+
8797
- name: Force doctrine/orm library to ${{ matrix.orm }}
8898
run: composer --prefer-stable require doctrine/orm:${{ matrix.orm }} --with-all-dependencies
89-
- name: Run test suite and coverage
99+
100+
- name: Run test suite and with coverage for codeclimate for PHP 8.3 and doctrine/orm ^3.1 only
90101
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' && env.HAS_CC_SECRET == 'true' }}
91102
uses: paambaati/[email protected]
92103
env:
93104
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
94105
with:
95106
coverageCommand: composer run-script test-coverage
96107
coverageLocations: ${{github.workspace}}/.phpunit.cache/code-coverage/clover*.xml:clover
97-
- name: Run test suite for forks or version without coverage
108+
109+
- name: Run test suite for forks or version without code coverage
98110
if: ${{ matrix.php != '8.3' || matrix.orm != '^3.1' || env.HAS_CC_SECRET != 'true' }}
99111
run: composer run-script test
112+
100113
- name: Coveralls.io steps
101114
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' && env.HAS_CA_SECRET == 'true' }}
102115
uses: coverallsapp/github-action@v2
103116
with:
104117
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
105118
file: ${{github.workspace}}/.phpunit.cache/code-coverage/clover.xml
106-
- name: Check quality code
107-
run: composer run-script check-quality-code
119+
120+
## Quality checks
121+
## PHP-CS-Fixer is needed with only one version of PHP
122+
- name: Cache Composer PHP-CS-FIXER packages
123+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
124+
id: composer-phpcsfixer-cache
125+
uses: actions/cache@v4
126+
with:
127+
path: quality/php-cs-fixer/vendor/
128+
key: ${{ runner.os }}-phpcsfixer-${{ hashFiles('**/composer.lock') }}
129+
restore-keys: |
130+
${{ runner.os }}-phpcsfixer-
131+
132+
- name: Install PHP-CS-Fixer
133+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
134+
run: composer update --working-dir=quality/php-cs-fixer
135+
136+
- name: Run PHP-CS-Fixer
137+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
138+
run: ./quality/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=quality/php-cs-fixer/.php-cs-fixer.php --dry-run --allow-risky=yes
139+
140+
## PHP-MESS-DETECTOR
141+
- name: Cache Composer PHP-MESS-DETECTOR packages
142+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
143+
id: composer-phpmd-cache
144+
uses: actions/cache@v4
145+
with:
146+
path: quality/php-cs-fixer/vendor/
147+
key: ${{ runner.os }}-phpmd-${{ hashFiles('**/composer.lock') }}
148+
restore-keys: |
149+
${{ runner.os }}-phpmd-
150+
- name: Install PHP-MESS-DETECTOR
151+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
152+
run: composer update --working-dir=quality/php-mess-detector
153+
- name: Run PHP-MESS-DETECTOR on lib directory
154+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
155+
run: ./quality/php-mess-detector/vendor/bin/phpmd lib text quality/php-mess-detector/ruleset.xml
156+
- name: Run PHP-MESS-DETECTOR on tests directory
157+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
158+
run: ./quality/php-mess-detector/vendor/bin/phpmd tests text quality/php-mess-detector/test-ruleset.xml
159+
160+
## PHP CODE SNIFFER
161+
- name: Cache Composer PHP-CS packages
162+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
163+
id: composer-php-cs-cache
164+
uses: actions/cache@v4
165+
with:
166+
path: quality/php-cs-fixer/vendor/
167+
key: ${{ runner.os }}-php-cs-${{ hashFiles('**/composer.lock') }}
168+
restore-keys: |
169+
${{ runner.os }}-php-cs-
170+
171+
- name: Install PHP-CS
172+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
173+
run: composer update --working-dir=quality/php-code-sniffer
174+
175+
- name: Run PHP-CS
176+
if: ${{ matrix.php == '8.3' && matrix.orm == '^3.1' }}
177+
run: ./quality/php-code-sniffer/vendor/bin/phpcs --standard=quality/php-code-sniffer/phpcs.xml -s
178+
179+
## PHP-STAN
180+
# - name: Cache Composer PHP-STAN packages
181+
# if: ${{ matrix.lexer-version == '~3.0.0' }}
182+
# id: composer-php-stan-cache
183+
# uses: actions/cache@v4
184+
# with:
185+
# path: quality/php-cs-fixer/vendor/
186+
# key: ${{ runner.os }}-php-stan-${{ hashFiles('**/composer.lock') }}
187+
# restore-keys: |
188+
# ${{ runner.os }}-php-stan-
189+
# - name: Install PHP-STAN
190+
# if: ${{ matrix.lexer-version == '~3.0.0' }}
191+
# run: composer update --working-dir=quality/php-stan
192+
# - name: Run PHP-STAN
193+
# if: ${{ matrix.lexer-version == '~3.0.0' }}
194+
# run: ./quality/php-stan/vendor/bin/phpstan analyse --configuration=quality/php-stan/php-stan.neon lib tests --error-format=table --no-progress --no-interaction --no-ansi --level=9 --memory-limit=256M -v
195+

phpmd.test.xml

+23-23
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
66
http://pmd.sf.net/ruleset_xml_schema.xsd"
77
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
8-
<description>Alexandre Tranchant rule set.</description>
9-
<!-- Import some rules of clean code rule set -->
10-
<rule ref="rulesets/cleancode.xml">
11-
<exclude name="BooleanArgumentFlag"/>
12-
<exclude name="MissingImport"/>
13-
<exclude name="StaticAccess"/>
14-
</rule>
15-
<!-- Import some rules of code size rule set -->
16-
<rule ref="rulesets/codesize.xml">
17-
<!-- There are never too many tests -->
18-
<exclude name="TooManyPublicMethods"/>
19-
</rule>
20-
<!-- Import the entire controversial code rule set, but SuperGlobals -->
21-
<rule ref="rulesets/controversial.xml">
22-
<exclude name="Superglobals"/>
23-
</rule>
24-
<!-- Import the entire design code rule set, but "coupling between" and "number of children" -->
25-
<rule ref="rulesets/design.xml">
26-
<exclude name="CouplingBetweenObjects"/>
27-
<exclude name="NumberOfChildren"/>
28-
</rule>
29-
<!-- Import the entire unused code rule set -->
30-
<rule ref="rulesets/unusedcode.xml"/>
8+
<description>Alexandre Tranchant rule set.</description>
9+
<!-- Import some rules of clean code rule set -->
10+
<rule ref="rulesets/cleancode.xml">
11+
<exclude name="BooleanArgumentFlag"/>
12+
<exclude name="MissingImport"/>
13+
<exclude name="StaticAccess"/>
14+
</rule>
15+
<!-- Import some rules of code size rule set -->
16+
<rule ref="rulesets/codesize.xml">
17+
<!-- There are never too many tests -->
18+
<exclude name="TooManyPublicMethods"/>
19+
</rule>
20+
<!-- Import the entire controversial code rule set, but SuperGlobals -->
21+
<rule ref="rulesets/controversial.xml">
22+
<exclude name="Superglobals"/>
23+
</rule>
24+
<!-- Import the entire design code rule set, but "coupling between" and "number of children" -->
25+
<rule ref="rulesets/design.xml">
26+
<exclude name="CouplingBetweenObjects"/>
27+
<exclude name="NumberOfChildren"/>
28+
</rule>
29+
<!-- Import the entire unused code rule set -->
30+
<rule ref="rulesets/unusedcode.xml"/>
3131
</ruleset>

quality/php-code-sniffer/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor/
2+
composer.lock
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"squizlabs/php_codesniffer": "^3.0"
4+
}
5+
}

0 commit comments

Comments
 (0)