From 8f300f5b804d5fd2268709d40e31b52c86d6799c Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Mon, 25 Jul 2022 23:05:10 +1200
Subject: [PATCH 1/2] WIP CI support for Cygwin.

XXX Doesn't get all the way through yet...

XXX Needs some --with-X options

XXX This should use a canned Docker image with all the right packages
installed

XXX We would never want this to run by default in CI, but it'd be nice
to be able to ask for it with ci-os-only!  (See commented out line)

XXX configure is soooo slooow, can we cache it?!  Compiling is also
insanely slow, but ccache gets it down to a couple of minutes if you're
lucky

XXX I don't know how to put variables like BUILD_JOBS into the scripts

XXX I have no idea if crash dump works, and if this should share
elements with the msys work in commitfest #3575
---
 .cirrus.yml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/.cirrus.yml b/.cirrus.yml
index f23d6cae55..b5238f5f52 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -456,6 +456,57 @@ task:
       path: "crashlog-*.txt"
       type: text/plain
 
+task:
+  name: Windows - Cygwin
+
+  env:
+    CPUS: 4
+    BUILD_JOBS: 4
+    TEST_JOBS: 8
+
+  #only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*'
+
+  windows_container:
+    image: cirrusci/windowsservercore:2019
+    os_version: 2019
+    cpu: $CPUS
+    memory: 4G
+
+  ccache_cache:
+    folder: C:\tools\cygwin\tmp\ccache
+
+  sysinfo_script: |
+    chcp
+    systeminfo
+    powershell -Command get-psdrive -psprovider filesystem
+    set
+
+  setup_additional_packages_script: |
+    choco install -y --no-progress cygwin
+    C:\tools\cygwin\cygwinsetup.exe -q -P cygrunsrv,make,gcc-core,ccache,binutils,libtool,pkg-config,flex,bison,zlib-devel,libssl-devel,libreadline-devel,perl,perl-IPC-Run
+    C:\tools\cygwin\bin\bash.exe --login -c "cygserver-config -y" || EXIT /b 1
+    C:\tools\cygwin\bin\bash.exe --login -c "echo 'kern.ipc.semmni 1024' >> /etc/cygserver.conf" || EXIT /b 1
+    C:\tools\cygwin\bin\bash.exe --login -c "echo 'kern.ipc.semmns 1024' >> /etc/cygserver.conf" || EXIT /b 1
+    C:\tools\cygwin\bin\bash.exe --login -c "net start cygserver" || EXIT /b 1
+
+  configure_script:
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && CCACHE_DIR=/tmp/ccache ./configure --enable-cassert --enable-debug --enable-tap-tests CC='ccache gcc'" || EXIT /b 1
+
+  build_script:
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && CCACHE_DIR=/tmp/ccache make -s -j4 world-bin" || EXIT /b 1
+
+  test_world_script:
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && CCACHE_DIR=/tmp/ccache make -s -j1 check-world -Otarget" || EXIT /b 1
+
+  on_failure:
+    <<: *on_failure
+    crashlog_artifacts:
+      path: "crashlog-*.txt"
+      type: text/plain
+
+  always:
+    upload_caches: ccache
+
 
 task:
   name: CompilerWarnings
-- 
2.35.1

