Skip to content

Commit

Permalink
Merge pull request #164 from Yoast/feature/composer-actions-update-th…
Browse files Browse the repository at this point in the history
…reshold-check

CS/check thresholds: require exact match for thresholds
  • Loading branch information
jrfnl authored Apr 6, 2024
2 parents 6d1f1dc + fba7411 commit a286169
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 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,15 @@ public static function check_cs_thresholds() {
@\passthru( 'composer check-branch-cs' );
}

exit( ( $above_threshold === true || $return > 2 ) ? $return : 0 );
$exit_code = 0;
if ( $above_threshold === true || $return > 2 ) {
$exit_code = $return;
}
elseif ( $threshold_exact === false ) {
$exit_code = 128;
}

exit( $exit_code );
}

/**
Expand Down

0 comments on commit a286169

Please sign in to comment.