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

Composer: update dev dependencies #365

Merged
merged 3 commits into from
Apr 6, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,23 @@ jobs:
custom-cache-suffix: $(date -u "+%Y-%m")

# Check the codestyle of the files against a threshold of expected errors and warnings.
# Keep track of the exit code as it determines whether to run the branch check or not.
# Exit code 128 means the thresholds needs to be lowered. Other exit codes imply CS errors.
- name: Check PHP code style against the thresholds
run: composer check-cs-thresholds
id: thresholds
run: |
set +e
composer check-cs-thresholds
exitcode="$?"
echo "EXITCODE=$exitcode" >> $GITHUB_OUTPUT
exit "$exitcode"

# Check the codestyle only of the files which were changed in the current branch.
# This step will only be executed if the threshold check exited with a failure status.
# The results of this CS check will be shown inline in the PR via the CS2PR tool.
# @link https://github.com/staabm/annotate-pull-request-from-checkstyle/
- name: Check PHP code style for the changes made in the branch only
if: ${{ failure() }}
if: ${{ failure() && steps.thresholds.outputs.EXITCODE != 128 }}
id: phpcs
run: composer check-branch-cs -- ${{ steps.base_branch.outputs.REF }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"require-dev": {
"roave/security-advisories": "dev-master",
"yoast/wp-test-utils": "^1.2.0",
"yoast/yoastcs": "^3.0"
"yoast/yoastcs": "^3.1.0"
},
"autoload": {
"classmap": [
Expand Down
15 changes: 14 additions & 1 deletion config/composer/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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 @@ -167,7 +172,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
9 changes: 4 additions & 5 deletions src/watchers/link-actions-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ public function add_rewrite_and_republish_admin_notice() {
public function add_rewrite_and_republish_block_editor_notice() {
if ( ! empty( $_REQUEST['rewriting'] ) ) {
$notice = [
'text' =>
\__(
'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", this rewritten post will replace the original post.',
'duplicate-post'
),
'text' => \__(
'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", this rewritten post will replace the original post.',
'duplicate-post'
),
'status' => 'warning',
'isDismissible' => true,
];
Expand Down