|
5 | 5 | # - PHP compatibility testing across multiple PHP versions (8.2, 8.3, 8.4, 8.5) |
6 | 6 | # - WordPress compatibility testing across multiple WP versions (7.0, latest, nightly) |
7 | 7 | # - PHPStan static analysis for WordPress-specific code quality |
| 8 | +# - Rector dry run, which fails on PHP that a current idiom would replace |
8 | 9 | # - WordPress security vulnerability scanning using pattern analysis |
9 | 10 | # - PHPCS code standards validation for WordPress coding standards |
10 | 11 | # - Psalm static analysis and taint analysis |
@@ -1067,6 +1068,106 @@ jobs: |
1067 | 1068 | filename: .github/ISSUE_TEMPLATE/phpstan-failure.md |
1068 | 1069 | update_existing: false |
1069 | 1070 |
|
| 1071 | + rector: |
| 1072 | + name: Rector (PHP 8.3) |
| 1073 | + runs-on: ubuntu-latest |
| 1074 | + # The job files an issue when it fails on main. |
| 1075 | + permissions: |
| 1076 | + contents: read |
| 1077 | + issues: write |
| 1078 | + timeout-minutes: 30 |
| 1079 | + steps: |
| 1080 | + - name: Checkout code |
| 1081 | + id: checkout_code |
| 1082 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 1083 | + with: |
| 1084 | + persist-credentials: false |
| 1085 | + # Always fetch the latest commit, disable any caching |
| 1086 | + fetch-depth: 0 |
| 1087 | + clean: true |
| 1088 | + |
| 1089 | + - name: Setup PHP 8.3 |
| 1090 | + id: setup_php_8_3 |
| 1091 | + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 |
| 1092 | + with: |
| 1093 | + php-version: '8.3' |
| 1094 | + extensions: mysqli, curl, zip, intl, gd, mbstring, fileinfo, xml |
| 1095 | + coverage: none |
| 1096 | + tools: composer:v2 |
| 1097 | + |
| 1098 | + - name: Clear any existing composer cache |
| 1099 | + id: clear_any_existing_composer_cache |
| 1100 | + run: | |
| 1101 | + composer clear-cache || true |
| 1102 | + rm -rf vendor/ composer.lock || true |
| 1103 | +
|
| 1104 | + - name: Install Composer dependencies (no cache) |
| 1105 | + id: install_composer_dependencies_no_cache |
| 1106 | + run: | |
| 1107 | + composer install --prefer-dist --no-progress --no-cache |
| 1108 | +
|
| 1109 | + - name: Run Rector dry run |
| 1110 | + id: run_rector_dry_run |
| 1111 | + # The dry run changes nothing and fails when any configured rule would change the code. |
| 1112 | + run: | |
| 1113 | + vendor/bin/rector --version |
| 1114 | + vendor/bin/rector process --dry-run --no-progress-bar |
| 1115 | +
|
| 1116 | + - name: Preserve diagnostic summary |
| 1117 | + id: preserve_diagnostics |
| 1118 | + if: ${{ always() }} |
| 1119 | + continue-on-error: true |
| 1120 | + env: |
| 1121 | + STEP_RESULTS: | |
| 1122 | + checkout_code=${{ steps.checkout_code.outcome }} |
| 1123 | + setup_php_8_3=${{ steps.setup_php_8_3.outcome }} |
| 1124 | + clear_any_existing_composer_cache=${{ steps.clear_any_existing_composer_cache.outcome }} |
| 1125 | + install_composer_dependencies_no_cache=${{ steps.install_composer_dependencies_no_cache.outcome }} |
| 1126 | + run_rector_dry_run=${{ steps.run_rector_dry_run.outcome }} |
| 1127 | + run: | |
| 1128 | + mkdir -p "$RUNNER_TEMP/es-optimizer-diagnostics" |
| 1129 | + printf '%s\n' "$STEP_RESULTS" > "$RUNNER_TEMP/es-optimizer-diagnostics/steps.txt" |
| 1130 | + printf 'commit=%s\njob=%s\n' "$GITHUB_SHA" "$GITHUB_JOB" > "$RUNNER_TEMP/es-optimizer-diagnostics/run.txt" |
| 1131 | + if command -v php >/dev/null; then |
| 1132 | + php -r 'echo PHP_VERSION, PHP_EOL;' > "$RUNNER_TEMP/es-optimizer-diagnostics/php.txt" |
| 1133 | + fi |
| 1134 | + if command -v composer >/dev/null && [ -f vendor/composer/installed.json ]; then |
| 1135 | + php -r '$data = json_decode(file_get_contents("vendor/composer/installed.json"), true, 512, JSON_THROW_ON_ERROR); foreach ($data["packages"] ?? $data as $package) { echo $package["name"], " ", $package["version"], PHP_EOL; }' > "$RUNNER_TEMP/es-optimizer-diagnostics/dependencies.txt" |
| 1136 | + fi |
| 1137 | + # Never upload config, authentication data, SQL, exports, or arbitrary logs. |
| 1138 | + # Refuse oversized or linked diagnostics instead of uploading them. |
| 1139 | + find "$RUNNER_TEMP/es-optimizer-diagnostics" -type l -delete |
| 1140 | + find "$RUNNER_TEMP/es-optimizer-diagnostics" -type f -size +2M -delete |
| 1141 | +
|
| 1142 | + - name: Upload diagnostic summary |
| 1143 | + id: upload_diagnostics |
| 1144 | + if: ${{ always() }} |
| 1145 | + continue-on-error: true |
| 1146 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 1147 | + with: |
| 1148 | + name: wp-compat-rector |
| 1149 | + path: | |
| 1150 | + ${{ runner.temp }}/es-optimizer-diagnostics/run.txt |
| 1151 | + ${{ runner.temp }}/es-optimizer-diagnostics/steps.txt |
| 1152 | + ${{ runner.temp }}/es-optimizer-diagnostics/php.txt |
| 1153 | + ${{ runner.temp }}/es-optimizer-diagnostics/dependencies.txt |
| 1154 | + retention-days: 7 |
| 1155 | + if-no-files-found: warn |
| 1156 | + |
| 1157 | + - name: Create issue on Rector failure |
| 1158 | + id: create_issue_on_rector_failure |
| 1159 | + if: ${{ failure() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.actor != 'dependabot[bot]' }} |
| 1160 | + uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2 |
| 1161 | + env: |
| 1162 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 1163 | + FAILURE_STAGE: ${{ steps.checkout_code.outcome == 'failure' && 'checkout_code' || steps.setup_php_8_3.outcome == 'failure' && 'setup_php_8_3' || steps.clear_any_existing_composer_cache.outcome == 'failure' && 'clear_any_existing_composer_cache' || steps.install_composer_dependencies_no_cache.outcome == 'failure' && 'install_composer_dependencies_no_cache' || steps.run_rector_dry_run.outcome == 'failure' && 'run_rector_dry_run' || 'unknown_or_canceled' }} |
| 1164 | + PHP_VERSION: '8.3' |
| 1165 | + RUN_ID: ${{ github.run_id }} |
| 1166 | + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 1167 | + with: |
| 1168 | + filename: .github/ISSUE_TEMPLATE/rector-failure.md |
| 1169 | + update_existing: false |
| 1170 | + |
1070 | 1171 | lint: |
1071 | 1172 | name: Lint (Node 24) |
1072 | 1173 | runs-on: ubuntu-latest |
|
0 commit comments