From 4a75bffbd334c030f707ba8ff5abf39b93f3bf30 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 21 Jul 2026 12:32:23 +0200 Subject: [PATCH] Disable Windows Defender real-time scanning during Behat runs The functional test job spawns a large number of short-lived `wp` and `php` processes and writes many files per scenario. On the Windows runner, Defender's real-time scanning inspects every spawned process and file write, which makes the Behat suite run several times slower than the equivalent Linux job (e.g. ~84 minutes versus ~29 minutes for the same 262 scenarios on PHP 8.5 / WP trunk / SQLite). Disabling real-time monitoring for the duration of this ephemeral, throwaway runner removes that per-process tax and cuts the wall-clock time of the Windows job substantially. The step is guarded to the Windows runner and fails silently if the cmdlet is unavailable, so it is a no-op everywhere else. --- .github/workflows/reusable-functional.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/reusable-functional.yml b/.github/workflows/reusable-functional.yml index 25da7e8..1e6cb5a 100644 --- a/.github/workflows/reusable-functional.yml +++ b/.github/workflows/reusable-functional.yml @@ -51,6 +51,16 @@ jobs: WP_CLI_TEST_OBJECT_CACHE: ${{ inputs.object_cache }} steps: + # The Behat suite spawns a large number of short-lived `wp`/`php` + # processes and writes many files per scenario. On the Windows runner, + # Defender's real-time scanning inspects each of these, which slows the + # run down by several times compared to Linux. Turning it off for the + # duration of this ephemeral job cuts the wall-clock time dramatically. + - name: Disable Windows Defender real-time scanning + if: ${{ startsWith(inputs.os, 'windows') }} + shell: pwsh + run: Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue + - name: Check out source code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: