Skip to content

Commit

Permalink
CS/check thresholds: require exact match for thresholds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Apr 6, 2024
1 parent 6d1f1dc commit e38fcd0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/composer/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ) );

Check failure on line 177 in config/composer/actions.php

View workflow job for this annotation

GitHub Actions / Check code style

Inline shorthand IF statement requires brackets around comparison
}

/**
Expand Down

0 comments on commit e38fcd0

Please sign in to comment.