Skip to content

Commit

Permalink
Merge pull request #962 from WordPress/fix/lint-staged
Browse files Browse the repository at this point in the history
Run build-cs composer install/update via post-install/update-cmd scripts
  • Loading branch information
swissspidy authored Feb 1, 2024
2 parents 4396a84 + aad3002 commit a4a8060
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: npm
- name: Composer update
run: composer update
- name: npm install
run: npm ci
- name: Install WordPress
run: npm run wp-env start
# Note that `composer update` is required instead of `composer install`
# for the sake of PHP versions older than 8.1, which is the version of
# PHP that the composer.lock was created for.
- name: Composer update
run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer update --no-interaction
- name: Running single site unit tests
run: npm run test-php
- name: Running multisite unit tests
Expand Down
17 changes: 5 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@
"php": ">=7|^8"
},
"scripts": {
"phpstan": [
"composer --working-dir=build-cs update --no-interaction",
"build-cs/vendor/bin/phpstan analyse --memory-limit=2048M -c phpstan.neon.dist"
],
"format": [
"composer --working-dir=build-cs update --no-interaction",
"build-cs/vendor/bin/phpcbf --standard=phpcs.xml.dist --report-summary --report-source"
],
"lint": [
"composer --working-dir=build-cs update --no-interaction",
"build-cs/vendor/bin/phpcs --standard=phpcs.xml.dist"
],
"post-install-cmd": "if php -r 'exit( version_compare( phpversion(), \"8.1\", \">=\" ) ? 0 : 1 );'; then composer --working-dir=build-cs install --no-interaction; else echo 'Skipping composer install for build-cs since not on PHP 8.1+. You are running: '; php -v; fi",
"post-update-cmd": "if php -r 'exit( version_compare( phpversion(), \"8.1\", \">=\" ) ? 0 : 1 );'; then composer --working-dir=build-cs update --no-interaction; else echo 'Skipping composer update for build-cs since not on PHP 8.1+. You are running: '; php -v; fi",
"phpstan": "build-cs/vendor/bin/phpstan analyse --memory-limit=2048M -c phpstan.neon.dist",
"format": "build-cs/vendor/bin/phpcbf --standard=phpcs.xml.dist --report-summary --report-source",
"lint": "build-cs/vendor/bin/phpcs --standard=phpcs.xml.dist",
"test": "phpunit -c phpunit.xml.dist --verbose",
"test-multisite": "phpunit -c tests/multisite.xml --verbose"
},
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
"lint-js": "wp-scripts lint-js",
"format-php": "composer format",
"phpstan": "composer phpstan",
"prelint-php": "wp-env run composer 'install --no-interaction'",
"lint-php": "composer lint",
"pretest-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction",
"test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test",
"pretest-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer update --no-interaction",
"test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test-multisite",
"wp-env": "wp-env",
"prepare": "husky install"
Expand Down

0 comments on commit a4a8060

Please sign in to comment.