Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI Tooling #70

Merged
merged 5 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Code Standards
on:
push:
branches:
- trunk
- 'branch/*'
pull_request:
branches:
- trunk
- 'branch/*'

jobs:
phpcs:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Static Analysis

on:
push:
branches:
- trunk
- 'branch/*'
pull_request:
branches:
- trunk
- 'branch/*'

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install --no-progress --prefer-dist --no-interaction

- name: Run PHPStan
run: composer test:phpstan
8 changes: 6 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: PHPUnit Tests

on:
push:
branches: [ trunk ]
branches:
- trunk
- 'branch/*'
pull_request:
branches: [ trunk ]
branches:
- trunk
- 'branch/*'

jobs:
test:
Expand Down
36 changes: 34 additions & 2 deletions bin/prepare-release.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Release_Preparation {
* Run the release preparation
*/
public function run() {
$this->check_uncommitted_changes();
$this->format_packages();
$this->check_requirements();
$this->build_assets();
$this->run_tests();
Expand Down Expand Up @@ -90,6 +92,36 @@ public function run() {
echo "\nRelease preparation complete!\n";
}

/**
* Format package files
*/
private function format_packages() {
echo "Formatting package files...\n";
passthru( 'composer normalize', $return );
if ( 0 !== $return ) {
exit( $return );
}
passthru( 'npm run sort-package-json', $return );
if ( 0 !== $return ) {
exit( $return );
}
}

/**
* Check for uncommitted changes and abort if found
*/
private function check_uncommitted_changes() {
exec( 'git status --porcelain', $output, $return );
if ( ! empty( $output ) ) {
echo "Error: You have uncommitted changes. Please commit or stash them before running this script.\n";
echo "Changes found:\n";
foreach ( $output as $line ) {
echo " {$line}\n";
}
exit( 1 );
}
}

/**
* Check if required tools are available
*/
Expand Down Expand Up @@ -271,8 +303,8 @@ private function get_stable_tag() {
private function update_stable_tag( $version ) {
$readme = file_get_contents( 'readme.txt' );
$readme = preg_replace(
'/(Stable tag: )[^\s\n]+/',
'$1' . $version,
'/^Stable tag:.*$/m',
'Stable tag: ' . $version,
$readme
);
file_put_contents( 'readme.txt', $readme );
Expand Down
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
"ergebnis/composer-normalize": "^2.45",
"nikic/php-parser": "^4.0",
"phpcompatibility/phpcompatibility-wp": "^2.1.3",
"phpstan/extension-installer": "^1.4",
"phpunit/phpunit": "^9.6",
"sirbrillig/phpcs-changed": "^2.11",
"symfony/finder": "^5.0 || ^6.0",
"wp-coding-standards/wpcs": "^3.0",
"yoast/phpunit-polyfills": "^1.1.0",
"szepeviktor/phpstan-wordpress": "^2.0",
"phpstan/extension-installer": "^1.4"
"wp-coding-standards/wpcs": "^3.0",
"yoast/phpunit-polyfills": "^1.1.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"roots/wordpress-core-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"roots/wordpress-core-installer": true
},
"platform": {
"php": "7.4"
Expand Down Expand Up @@ -62,10 +62,7 @@
"format:php": "phpcbf",
"lint": "@lint:php",
"lint:php": "phpcs",
"prepare-release": [
"@format:packages",
"php bin/prepare-release.php"
],
"prepare-release": "php bin/prepare-release.php",
"test": [
"@test:php",
"@test:phpstan"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ parameters:
paths:
- .
excludePaths:
- node_modules
- node_modules (?)
- assets
- vendor
- docs
- lang
- wordpress
- wordpress (?)
bootstrapFiles:
- bin/phpstan-bootstrap.php