Skip to content

Commit 80de85f

Browse files
committed
ci(Unit Tests): change workflow to be inline with phpcsExtra standard.
By coping PHPCSExtra standard's workflow, it might fix some issues and allow the CI to work. Also removed phpunit 10 and 11 support, and changed the composer scripts.
1 parent b02cc11 commit 80de85f

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

.github/workflows/unit-tests.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
- php: "8.2"
8787
phpcs_version: "4.x-dev"
8888

89-
name: "Test: PHP ${{ matrix.php }}"
89+
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
9090

9191
steps:
9292
- name: Checkout code
@@ -110,8 +110,8 @@ jobs:
110110
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
111111
coverage: none
112112

113-
- name: "Composer: set PHPCS version for tests (dev)"
114-
if: ${{ contains( matrix.phpcs_version, 'dev') }}
113+
- name: "Composer: set PHPCS version for tests (dev/specific version)"
114+
if: ${{ matrix.phpcs_version != 'lowest' && matrix.phpcs_version != 'stable' }}
115115
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
116116

117117
- name: "Composer: use lock file when necessary"
@@ -133,26 +133,18 @@ jobs:
133133
- name: Composer info
134134
run: composer info
135135

136-
- name: Grab PHPUnit version
137-
id: phpunit_version
138-
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
136+
- name: Grab PHPCS version
137+
id: phpcs_version
138+
# yamllint disable-line rule:line-length
139+
run: echo "VERSION=$(vendor/bin/phpcs --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
139140

140-
- name: "DEBUG: Show grabbed PHPUnit version"
141-
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
141+
- name: "DEBUG: Show grabbed PHPCS version"
142+
run: echo ${{ steps.phpcs_version.outputs.VERSION }}
142143

143-
- name: Determine PHPUnit config file to use
144-
id: phpunit_config
145-
shell: bash
146-
run: |
147-
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
148-
echo 'FILE=phpunit.xml' >> "$GITHUB_OUTPUT"
149-
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
150-
echo 'FILE=phpunit.xml' >> "$GITHUB_OUTPUT"
151-
else
152-
echo 'FILE=phpunit-lte9.xml' >> "$GITHUB_OUTPUT"
153-
fi
144+
- name: Run the unit tests (PHPCS 3.x)
145+
if: ${{ startsWith( steps.phpcs_version.outputs.VERSION, '3.' ) }}
146+
run: composer test-phpcs3
154147

155-
- name: Run the unit tests
156-
run: composer test -- -c ${{ steps.phpunit_config.outputs.FILE }}
157-
env:
158-
PHPCS_VERSION: ${{ matrix.phpcs_version }}
148+
- name: Run the unit tests (PHPCS 4.x)
149+
if: ${{ startsWith( steps.phpcs_version.outputs.VERSION, '4.' ) }}
150+
run: composer test-phpcs4

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dealerdirect/phpcodesniffer-composer-installer": "^1.1"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^8.5||^9.6||^10.5||^11.5",
25+
"phpunit/phpunit": "^8.5||^9.6",
2626
"phpcsstandards/phpcsdevtools": "^1.0",
2727
"php-parallel-lint/php-parallel-lint": "^1.4"
2828
},
@@ -40,10 +40,14 @@
4040
"lint": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude test_utils",
4141
"cs": "@php ./vendor/bin/phpcs --standard=yCodeTech",
4242
"cbf": "@php ./vendor/bin/phpcbf --standard=yCodeTech",
43-
"test": [
43+
"test-phpcs4": [
4444
"Composer\\Config::disableProcessTimeout",
4545
"@php ./vendor/bin/phpunit --no-coverage"
4646
],
47+
"test-phpcs3": [
48+
"Composer\\Config::disableProcessTimeout",
49+
"@php ./vendor/bin/phpunit --filter yCodeTech --no-coverage ./vendor/squizlabs/php_codesniffer/tests/AllTests.php"
50+
],
4751
"cs-test-file": "@cs ./test_utils/TestFile.php",
4852
"fix-test-file": "@cbf ./test_utils/TestFile.php",
4953
"restore-test-file": "bash ./test_utils/restore_errors.sh",

0 commit comments

Comments
 (0)