Skip to content

Commit 3d8059e

Browse files
authored
Feat: use core vendor binaries
1 parent 16654e4 commit 3d8059e

File tree

2 files changed

+108
-22
lines changed

2 files changed

+108
-22
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 104 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,50 +96,113 @@ jobs:
9696
run: |
9797
npm install --no-save
9898
- name: "PHP Parallel Lint"
99-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/parallel-lint', inputs.plugin-key)) != '' }}
10099
run: |
101100
echo -e "\033[0;33mExecuting PHP Parallel Lint...\033[0m"
102-
vendor/bin/parallel-lint --colors --exclude ./lib/ --exclude ./node_modules/ --exclude ./vendor/ --no-progress .
101+
if [[ -f "vendor/bin/parallel-lint" ]]; then
102+
vendor/bin/parallel-lint --colors --exclude ./lib/ --exclude ./node_modules/ --exclude ./vendor/ --no-progress .
103+
elif [[ -f "../../vendor/bin/parallel-lint" ]]; then
104+
../../vendor/bin/parallel-lint --colors --exclude ./lib/ --exclude ./node_modules/ --exclude ./vendor/ --no-progress .
105+
else
106+
echo -e "\033[0;31mPHP Parallel Lint binary not found!\033[0m"
107+
exit 1
108+
fi
103109
- name: "PHP CodeSniffer"
104-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/phpcs', inputs.plugin-key)) != '' && hashFiles(format('{0}/.phpcs.xml', inputs.plugin-key)) != '' }}
110+
if: ${{ !cancelled() && hashFiles(format('{0}/.phpcs.xml', inputs.plugin-key)) != '' }}
105111
run: |
106112
echo -e "\033[0;33mExecuting PHP CodeSniffer...\033[0m"
113+
if [[ -f "vendor/bin/phpcs" ]]; then
114+
vendor/bin/phpcs
115+
elif [[ -f "../../vendor/bin/phpcs" ]]; then
116+
../../vendor/bin/phpcs
117+
else
118+
echo -e "\033[0;31mPHP CodeSniffer binary not found!\033[0m"
119+
exit 1
120+
fi
107121
vendor/bin/phpcs
108122
- name: "PHP-CS-Fixer"
109-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/php-cs-fixer', inputs.plugin-key)) != '' && hashFiles(format('{0}/.php-cs-fixer.php', inputs.plugin-key)) != '' }}
123+
if: ${{ !cancelled() && hashFiles(format('{0}/.php-cs-fixer.php', inputs.plugin-key)) != '' }}
110124
run: |
111125
echo -e "\033[0;33mExecuting PHP-CS-Fixer...\033[0m"
112-
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer check --config=.php-cs-fixer.php --no-interaction --show-progress none
126+
if [[ -f "vendor/bin/php-cs-fixer" ]]; then
127+
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer check --config=.php-cs-fixer.php --no-interaction --show-progress none
128+
elif [[ -f "../../vendor/bin/php-cs-fixer" ]]; then
129+
PHP_CS_FIXER_IGNORE_ENV=1 php ../../vendor/bin/php-cs-fixer check --config=.php-cs-fixer.php --no-interaction --show-progress none
130+
else
131+
echo -e "\033[0;31mPHP-CS-Fixer binary not found!\033[0m"
132+
exit 1
133+
fi
113134
- name: "PHPStan"
114-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/phpstan', inputs.plugin-key)) != '' && hashFiles(format('{0}/phpstan.neon', inputs.plugin-key)) != '' }}
135+
if: ${{ !cancelled() && hashFiles(format('{0}/phpstan.neon', inputs.plugin-key)) != '' }}
115136
run: |
116137
echo -e "\033[0;33mExecuting PHPStan...\033[0m"
117-
vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
138+
if [[ -f "vendor/bin/phpstan" ]]; then
139+
vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
140+
elif [[ -f "../../vendor/bin/phpstan" ]]; then
141+
../../vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
142+
else
143+
echo -e "\033[0;31mPHPStan binary not found!\033[0m"
144+
exit 1
145+
fi
118146
- name: "Psalm"
119147
if: ${{ !cancelled() && hashFiles(format('{0}/psalm.xml', inputs.plugin-key)) != '' }}
120148
run: |
121149
echo -e "\033[0;33mExecuting Psalm...\033[0m"
122-
php ../../vendor/bin/psalm --long-progress --output-format=github
150+
if [[ -f "vendor/bin/psalm" ]]; then
151+
vendor/bin/psalm --long-progress --output-format=github
152+
elif [[ -f "../../vendor/bin/psalm" ]]; then
153+
../../vendor/bin/psalm --long-progress --output-format=github
154+
else
155+
echo -e "\033[0;31mPsalm binary not found!\033[0m"
156+
exit 1
157+
fi
123158
- name: "Rector"
124-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/rector', inputs.plugin-key)) != '' && hashFiles(format('{0}/rector.php', inputs.plugin-key)) != '' }}
159+
if: ${{ !cancelled() && hashFiles(format('{0}/rector.php', inputs.plugin-key)) != '' }}
125160
run: |
126161
echo -e "\033[0;33mExecuting Rector...\033[0m"
127-
php vendor/bin/rector process --dry-run --ansi
162+
if [[ -f "vendor/bin/rector" ]]; then
163+
vendor/bin/rector process --dry-run --ansi
164+
elif [[ -f "../../vendor/bin/rector" ]]; then
165+
../../vendor/bin/rector process --dry-run --ansi
166+
else
167+
echo -e "\033[0;31mRector binary not found!\033[0m"
168+
exit 1
169+
fi
128170
- name: "JS Lint"
129-
if: ${{ !cancelled() && hashFiles(format('{0}/node_modules/.bin/eslint', inputs.plugin-key)) != '' && (hashFiles(format('{0}/eslint.config.js', inputs.plugin-key)) != '' || hashFiles(format('{0}/eslint.config.mjs', inputs.plugin-key)) != '' || hashFiles(format('{0}/eslint.config.cjs', inputs.plugin-key)) != '' || hashFiles(format('{0}/.eslintrc.js', inputs.plugin-key)) != '') }}
171+
if: ${{ !cancelled() && (hashFiles(format('{0}/eslint.config.js', inputs.plugin-key)) != '' || hashFiles(format('{0}/eslint.config.mjs', inputs.plugin-key)) != '' || hashFiles(format('{0}/eslint.config.cjs', inputs.plugin-key)) != '' || hashFiles(format('{0}/.eslintrc.js', inputs.plugin-key)) != '') }}
130172
run: |
131173
echo -e "\033[0;33mExecuting ESLint...\033[0m"
132-
node_modules/.bin/eslint --color .
174+
if [[ -f "node_modules/.bin/eslint" ]]; then
175+
node_modules/.bin/eslint --color .
176+
elif [[ -f "../../node_modules/.bin/eslint" ]]; then
177+
../../node_modules/.bin/eslint --color .
178+
else
179+
echo -e "\033[0;31mESLint binary not found!\033[0m"
180+
exit 1
181+
fi
133182
- name: "CSS Lint"
134183
if: ${{ !cancelled() && hashFiles(format('{0}/node_modules/.bin/stylelint', inputs.plugin-key)) != '' && hashFiles(format('{0}/.stylelintrc.js', inputs.plugin-key)) != '' }}
135184
run: |
136185
echo -e "\033[0;33mExecuting Stylelint...\033[0m"
137-
node_modules/.bin/stylelint --color "**/*.css" "**/*.scss"
186+
if [[ -f "node_modules/.bin/stylelint" ]]; then
187+
node_modules/.bin/stylelint --color "**/*.css" "**/*.scss"
188+
elif [[ -f "../../node_modules/.bin/stylelint" ]]; then
189+
../../node_modules/.bin/stylelint --color "**/*.css" "**/*.scss"
190+
else
191+
echo -e "\033[0;31mStylelint binary not found!\033[0m"
192+
exit 1
193+
fi
138194
- name: "Misc lint"
139-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/licence-headers-check', inputs.plugin-key)) != '' && hashFiles(format('{0}/tools/HEADER', inputs.plugin-key)) != '' }}
195+
if: ${{ !cancelled() && hashFiles(format('{0}/tools/HEADER', inputs.plugin-key)) != '' }}
140196
run: |
141197
echo -e "\033[0;33mExecuting licence headers checks...\033[0m"
142-
vendor/bin/licence-headers-check --ansi --no-interaction
198+
if [[ -f "vendor/bin/licence-headers-check" ]]; then
199+
vendor/bin/licence-headers-check --ansi --no-interaction
200+
elif [[ -f "../../vendor/bin/licence-headers-check" ]]; then
201+
../../vendor/bin/licence-headers-check --ansi --no-interaction --header-file=tools/HEADER -d .
202+
else
203+
echo -e "\033[0;31mLicence headers check binary not found!\033[0m"
204+
exit 1
205+
fi
143206
- name: "Install plugin"
144207
if: ${{ !cancelled() }}
145208
working-directory: "/var/www/glpi"
@@ -159,14 +222,36 @@ jobs:
159222
if: ${{ !cancelled() && hashFiles(format('{0}/phpunit.xml', inputs.plugin-key)) != '' }}
160223
run: |
161224
echo -e "\033[0;33mExecuting PHPUnit...\033[0m"
162-
php ../../vendor/bin/phpunit --colors=always
225+
if [[ -f "vendor/bin/phpunit" ]]; then
226+
vendor/bin/phpunit --colors=always
227+
elif [[ -f "../../vendor/bin/phpunit" ]]; then
228+
../../vendor/bin/phpunit --colors=always
229+
else
230+
echo -e "\033[0;31mPHPUnit binary not found!\033[0m"
231+
exit 1
232+
fi
163233
- name: "Jest"
164-
if: ${{ !cancelled() && hashFiles(format('{0}/node_modules/.bin/jest', inputs.plugin-key)) != '' && hashFiles(format('{0}/jest.config.js', inputs.plugin-key)) != '' }}
234+
if: ${{ !cancelled() && hashFiles(format('{0}/jest.config.js', inputs.plugin-key)) != '' }}
165235
run: |
166236
echo -e "\033[0;33mExecuting Jest...\033[0m"
167-
NODE_OPTIONS="--experimental-vm-modules" node_modules/.bin/jest --colors --forceExit
237+
if [[ -f "node_modules/.bin/jest" ]]; then
238+
NODE_OPTIONS="--experimental-vm-modules" node_modules/.bin/jest --colors --forceExit
239+
elif [[ -f "../../node_modules/.bin/jest" ]]; then
240+
NODE_OPTIONS="--experimental-vm-modules" ../../node_modules/.bin/jest --colors --forceExit
241+
else
242+
echo -e "\033[0;31mJest binary not found!\033[0m"
243+
exit 1
244+
fi
168245
- name: "TwigCS"
169-
if: ${{ !cancelled() && hashFiles(format('{0}/vendor/bin/twigcs', inputs.plugin-key)) != '' && hashFiles(format('{0}/.twig_cs.dist.php', inputs.plugin-key)) != '' }}
246+
if: ${{ !cancelled() && hashFiles(format('{0}/.twig_cs.dist.php', inputs.plugin-key)) != '' }}
170247
run: |
171248
echo -e "\033[0;33mExecuting TwigCS...\033[0m"
249+
if [[ -f "vendor/bin/twigcs" ]]; then
250+
vendor/bin/twigcs
251+
elif [[ -f "../../vendor/bin/twigcs" ]]; then
252+
../../vendor/bin/twigcs
253+
else
254+
echo -e "\033[0;31mTwigCS binary not found!\033[0m"
255+
exit 1
256+
fi
172257
vendor/bin/twigcs

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
## Continuous integration workflow
44

55
This workflow will execute the following actions as long as they are available on the plugin repository.
6+
If the vendor package is not installed within the plugin repository, the CI workflow will attempt to use the vendor binaries provided by GLPI directly.
67

7-
| Action | Required package | Required config file |
8+
| Action | Vendor package | Required config file |
89
| -------- | -------- | -------- |
910
| PHP Parallel Lint | [php-parallel-lint/php-parallel-lint](https://packagist.org/packages/php-parallel-lint/php-parallel-lint) | |
1011
| PHP CodeSniffer | [squizlabs/php_codesniffer](https://packagist.org/packages/squizlabs/php_codesniffer) | `.phpcs.xml` |
1112
| PHP-CS-Fixer | [friendsofphp/php-cs-fixer](https://packagist.org/packages/friendsofphp/php-cs-fixer) | `.php-cs-fixer.php` |
1213
| PHPStan | [phpstan/phpstan](https://packagist.org/packages/phpstan/phpstan) | `phpstan.neon` |
13-
| Psalm | none, GLPI provides it | `psalm.xml` |
14+
| Psalm | [vimeo/psalm](https://packagist.org/packages/vimeo/psalm) | `psalm.xml` |
1415
| Rector | [rector/rector](https://packagist.org/packages/rector/rector) | `rector.php` |
1516
| ESLint | [eslint](https://www.npmjs.com/package/eslint) | `eslint.config.js` or `eslint.config.mjs` or `eslint.config.cjs` or `.eslintrc.js` |
1617
| Stylelint | [stylelint](https://www.npmjs.com/package/stylelint) | `.stylelintrc.js` |
1718
| Licence headers check | [glpi-project/tools](https://packagist.org/packages/glpi-project/tools) | `tools/HEADER` |
18-
| PHPUnit | none, GLPI provides it | `phpunit.xml` |
19+
| PHPUnit | [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) | `phpunit.xml` |
1920
| Jest | [jest](https://www.npmjs.com/package/jest) | `jest.config.js` |
2021
| TwigCS | [friendsoftwig/twigcs](https://github.com/friendsoftwig/twigcs) | `.twig_cs.dist.php` |
2122

0 commit comments

Comments
 (0)