From b5fea54b66ae1d357bf3e2aa1bc74e219bbfa192 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 22 Jul 2026 12:57:13 +0200 Subject: [PATCH] Speed up Windows functional tests by using the D: drive The Windows functional (Behat) job is by far the slowest in the matrix, taking well over an hour while the equivalent Linux job finishes in under 30 minutes. Nearly all of that time is the Behat run itself: the suite installs WordPress and spawns a large number of short-lived `wp`/`php` processes per scenario, and on the Windows runner all of that file I/O happens on the slow C: drive. Relocating the temporary files to the runner's fast D: drive roughly halves the Behat run time. The wp-cli-tests framework derives the WP install directory, the core/install/SQLite caches and HOME/COMPOSER_HOME (the WP-CLI cache) from sys_get_temp_dir(), and forwards TEMP/TMP to the spawned `wp` processes, so pointing TEMP/TMP at D: relocates everything in one step. The step is guarded and becomes a no-op if D: is ever unavailable. The D: drive only exists on the windows-2022 image (it was removed from windows-2025, which is also significantly slower), so the Windows matrix entry is pinned to windows-2022. --- .github/workflows/reusable-functional.yml | 22 ++++++++++++++++++++++ .github/workflows/reusable-testing.yml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-functional.yml b/.github/workflows/reusable-functional.yml index 25da7e8..e94dea9 100644 --- a/.github/workflows/reusable-functional.yml +++ b/.github/workflows/reusable-functional.yml @@ -51,6 +51,28 @@ jobs: WP_CLI_TEST_OBJECT_CACHE: ${{ inputs.object_cache }} steps: + # The Behat suite is heavily I/O- and process-bound: every scenario + # installs WordPress and spawns many short-lived `wp` processes. On the + # GitHub Windows runner those working files land on the slow C: drive. + # Relocating them to the fast D: drive roughly halves the Behat run time. + # The wp-cli-tests framework derives the WP install dir, all core/install/ + # SQLite caches and HOME/COMPOSER_HOME (the WP-CLI cache) from + # sys_get_temp_dir(), and forwards TEMP/TMP to the spawned `wp` processes, + # so pointing TEMP/TMP at D: relocates all of it. Guarded so it is a no-op + # if the D: drive is ever unavailable. + - name: Use the fast D drive for temporary files + if: ${{ startsWith(inputs.os, 'windows') }} + shell: pwsh + run: | + if (Test-Path 'D:\') { + New-Item -ItemType Directory -Force -Path 'D:\Temp' | Out-Null + "TEMP=D:\Temp" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + "TMP=D:\Temp" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + Write-Host 'Using D:\Temp for temporary files.' + } else { + Write-Host 'D: drive not available; using the default temp location.' + } + - name: Check out source code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/.github/workflows/reusable-testing.yml b/.github/workflows/reusable-testing.yml index 236a790..71700a7 100644 --- a/.github/workflows/reusable-testing.yml +++ b/.github/workflows/reusable-testing.yml @@ -317,7 +317,7 @@ jobs: "php": "8.5", "wp": "trunk", "dbtype": "sqlite", - "os": "windows-latest" + "os": "windows-2022" } ] }