From 77ba9eaf85ba2b3304d85caa86ee371541df2c72 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Thu, 4 Sep 2025 17:20:18 +0300
Subject: [PATCH v3 2/2] ci: windows: Default to VS 2022, run VS 2019 task
 manually

Both VS 2019 and VS 2022 are available on the Windows image [1], but
since VS 2022 is the latest version, make it the default. The VS 2019
task is still available but must be triggered manually.

[1] https://github.com/anarazel/pg-vm-images/pull/116

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/flat/CAN55FZ1OsaM+852BMQDJ+Kgfg+07knJ6dM3PjbGbtYaK4qwfqA@mail.gmail.com
---
 .cirrus.star        |  3 ++-
 .cirrus.tasks.yml   | 14 ++++++++++++--
 src/tools/ci/README |  4 ++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/.cirrus.star b/.cirrus.star
index e9bb672b959..cecd9bb026c 100644
--- a/.cirrus.star
+++ b/.cirrus.star
@@ -73,7 +73,7 @@ def compute_environment_vars():
     # REPO_CI_AUTOMATIC_TRIGGER_TASKS="task_name other_task" under "Repository
     # Settings" on Cirrus CI's website.
 
-    default_manual_trigger_tasks = ['mingw', 'netbsd', 'openbsd']
+    default_manual_trigger_tasks = ['mingw', 'netbsd', 'openbsd', 'vs2019']
 
     repo_ci_automatic_trigger_tasks = env.get('REPO_CI_AUTOMATIC_TRIGGER_TASKS', '')
     for task in default_manual_trigger_tasks:
@@ -103,6 +103,7 @@ def compute_environment_vars():
       'netbsd',
       'openbsd',
       'sanitycheck',
+      'vs2019',
       'windows',
     ]
     commit_message = env.get('CIRRUS_CHANGE_MESSAGE')
diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index eca9d62fc22..07e32b588ea 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -752,7 +752,6 @@ WINDOWS_ENVIRONMENT_BASE: &WINDOWS_ENVIRONMENT_BASE
 
 
 task:
-  name: Windows - Server 2019, VS 2019 - Meson & ninja
   << : *WINDOWS_ENVIRONMENT_BASE
 
   env:
@@ -775,10 +774,21 @@ task:
       -Dplperl=enabled
       -Dplpython=enabled
 
+  matrix:
+    - name: Windows - Server 2022, VS 2019 - Meson & ninja
+      env:
+        # Use VS 2019
+        PATH: C:\VS_2019\VC\Auxiliary\Build;${PATH}
+      trigger_type: $CI_TRIGGER_TYPE_VS2019
+      only_if: $CI_VS2019_ENABLED
+
+    # VS 2022 is the default VS installation
+    - name: Windows - Server 2022, VS 2022 - Meson & ninja
+      only_if: $CI_WINDOWS_ENABLED
+
   <<: *windows_task_template
 
   depends_on: SanityCheck
-  only_if: $CI_WINDOWS_ENABLED
 
   setup_additional_packages_script: |
     REM choco install -y --no-progress ...
diff --git a/src/tools/ci/README b/src/tools/ci/README
index d183648a8d0..97426096f7a 100644
--- a/src/tools/ci/README
+++ b/src/tools/ci/README
@@ -61,7 +61,7 @@ Controlling CI via commit messages
 The behavior of CI can be controlled by special content in commit
 messages. Currently the following controls are available:
 
-- ci-os-only: {(freebsd|linux|macos|mingw|netbsd|openbsd|windows)}
+- ci-os-only: {(freebsd|linux|macos|mingw|netbsd|openbsd|vs2019|windows)}
 
   Only runs CI on operating systems specified. This can be useful when
   addressing portability issues affecting only a subset of platforms.
@@ -92,4 +92,4 @@ credits too quickly. This can be changed on the repository level, e.g. when
 custom compute resources are configured.
 
 The following repository level environment variables are recognized:
-- REPO_CI_AUTOMATIC_TRIGGER_TASKS - space-separated list of (mingw|netbsd|openbsd)
+- REPO_CI_AUTOMATIC_TRIGGER_TASKS - space-separated list of (mingw|netbsd|openbsd|vs2019)
-- 
2.51.0

