From e38fcd0c053c0793fe44b6c4221c6f307ea2bec7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 6 Apr 2024 04:18:55 +0200 Subject: [PATCH] CS/check thresholds: require exact match for thresholds This changes the implementation of the coding standards threshold check to require that both the `YOASTCS_THRESHOLD_ERRORS` environment variable, as well as the `YOASTCS_THRESHOLD_WARNINGS` environment variable match the current status exactly. This prevents PR A fixing some issues and forgetting to update the threshold, which then would allow PR B to introduce new issues. --- config/composer/actions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/composer/actions.php b/config/composer/actions.php index 23cb96a..dde20ac 100644 --- a/config/composer/actions.php +++ b/config/composer/actions.php @@ -155,6 +155,11 @@ public static function check_cs_thresholds() { $above_threshold = false; } + $threshold_exact = true; + if ( \strpos( $phpcs_output, ' than the threshold, great job!' ) !== false ) { + $threshold_exact = false; + } + /* * Don't run the branch check in CI/GH Actions as it prevents the errors from being shown inline. * The GH Actions script will run this via a separate script step. @@ -169,7 +174,7 @@ public static function check_cs_thresholds() { @\passthru( 'composer check-branch-cs' ); } - exit( ( $above_threshold === true || $return > 2 ) ? $return : 0 ); + exit( ( $above_threshold === true || $return > 2 ) ? $return : ( $threshold_exact === false ? 1 : 0 ) ); } /**