From 0585858de3602b88b2c8f11924d3439f457b5ab2 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Fri, 8 Oct 2021 17:29:10 -0700
Subject: [PATCH v5 16/16] meson: ci: Build both with meson and as before.

---
 .cirrus.yml | 466 ++++++++++++++++++++++++++++++++++------------------
 1 file changed, 309 insertions(+), 157 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 2bb6f4a14d7..a7f955b3c63 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -13,14 +13,13 @@ env:
 
 
 task:
-  name: FreeBSD
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*'
   compute_engine_instance:
     image_project: pg-vm-images-aio
     image: family/pg-aio-freebsd-13-0
     platform: freebsd
-    cpu: 2
-    memory: 2G
+    cpu: 4
+    memory: 4G
     disk: 50
   env:
     CCACHE_DIR: "/tmp/ccache_dir"
@@ -39,33 +38,52 @@ task:
     - mkdir -p /tmp/ccache_dir
     - chown -R postgres:postgres /tmp/ccache_dir
 
-  configure_script: |
-    su postgres -c './configure \
-      --enable-cassert --enable-debug --enable-tap-tests \
-      --enable-nls \
-      \
-      --with-icu \
-      --with-ldap \
-      --with-libxml \
-      --with-libxslt \
-      \
-      --with-lz4 \
-      --with-pam \
-      --with-perl \
-      --with-python \
-      --with-ssl=openssl \
-      --with-tcl --with-tclconfig=/usr/local/lib/tcl8.6/ \
-      --with-uuid=bsd \
-      \
-      --with-includes=/usr/local/include --with-libs=/usr/local/lib \
-      CC="ccache cc"'
-  build_script:
-    - su postgres -c 'gmake -s -j3 && gmake -s -j3 -C contrib'
-  upload_caches:
-    - ccache
+  matrix:
+    - name: FreeBSD autoconf
+
+      configure_script: |
+        su postgres -c './configure \
+          --enable-cassert --enable-debug --enable-tap-tests \
+          --enable-nls \
+          \
+          --with-icu \
+          --with-ldap \
+          --with-libxml \
+          --with-libxslt \
+          \
+          --with-lz4 \
+          --with-pam \
+          --with-perl \
+          --with-python \
+          --with-ssl=openssl \
+          --with-tcl --with-tclconfig=/usr/local/lib/tcl8.6/ \
+          --with-uuid=bsd \
+          \
+          --with-includes=/usr/local/include --with-libs=/usr/local/lib \
+          CC="ccache cc"'
+      build_script:
+        - su postgres -c 'gmake -s -j4 && gmake -s -j4 -C contrib'
+      upload_caches:
+        - ccache
+
+      tests_script:
+        - su postgres -c 'time gmake -s -j4 ${CHECK} ${CHECKFLAGS}'
+
+    - name: FreeBSD meson
+
+      configure_script:
+        - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=bsd build'
+      build_script:
+        - su postgres -c 'ninja -C build'
+      upload_caches:
+        - ccache
+      run_tests_script:
+        - su postgres -c 'meson test --no-rebuild -C build'
 
-  tests_script:
-    - su postgres -c 'time gmake -s -j2 ${CHECK} ${CHECKFLAGS}'
+  always:
+    meson_log_artifacts:
+      path: "build/meson-logs/*.txt"
+      type: text/plain
 
   on_failure:
     cores_script: |
@@ -83,14 +101,16 @@ task:
     tap_artifacts:
       path: "**/regress_log_*"
       type: text/plain
+    meson_test_artifacts:
+      path: "build/meson-logs/testlog.junit.xml"
+      type: text/xml
+      format: junit
 
 
 task:
-  name: Linux
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
   compute_engine_instance:
     image_project: pg-vm-images-aio
-    image: family/pg-aio-bullseye
     platform: linux
     cpu: 4
     memory: 2G
@@ -120,37 +140,78 @@ task:
     - su postgres -c 'ulimit -l -S'
     - echo '/tmp/%e-%s-%p.core' > /proc/sys/kernel/core_pattern
 
-  configure_script: |
-    su postgres -c './configure \
-      --enable-cassert --enable-debug --enable-tap-tests \
-      --enable-nls \
-      \
-      --with-gssapi \
-      --with-icu \
-      --with-ldap \
-      --with-libxml \
-      --with-libxslt \
-      --with-llvm \
-      --with-lz4 \
-      --with-pam \
-      --with-perl \
-      --with-python \
-      --with-ssl=openssl \
-      --with-systemd \
-      --with-tcl --with-tclconfig=/usr/lib/tcl8.6/ \
-      --with-uuid=e2fs \
-      \
-      CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" CFLAGS="-O0 -ggdb"'
-  build_script:
-    - su postgres -c 'make -s -j4 && make -s -j4 -C contrib'
-  upload_caches:
-    - ccache
+  matrix:
+    - name: Linux Autoconf
+
+      compute_engine_instance:
+        image: family/pg-aio-bullseye
+
+      configure_script: |
+        su postgres -c './configure \
+          --enable-cassert --enable-debug --enable-tap-tests \
+          --enable-nls \
+          \
+          --with-gssapi \
+          --with-icu \
+          --with-ldap \
+          --with-libxml \
+          --with-libxslt \
+          --with-llvm \
+          --with-lz4 \
+          --with-pam \
+          --with-perl \
+          --with-python \
+          --with-ssl=openssl \
+          --with-systemd \
+          --with-tcl --with-tclconfig=/usr/lib/tcl8.6/ \
+          --with-uuid=e2fs \
+          \
+          CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" CFLAGS="-O0 -ggdb"'
+      build_script:
+        - su postgres -c 'make -s -j4 && make -s -j4 -C contrib'
+      upload_caches:
+        - ccache
+
+      tests_script: |
+        su postgres -c '\
+          ulimit -c unlimited; \
+          make -s ${CHECK} ${CHECKFLAGS} -j8 \
+          '
+
+    - name: Linux Meson
+
+      compute_engine_instance:
+        image: family/pg-aio-bullseye
+
+      configure_script:
+        - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs build'
+      build_script:
+        - su postgres -c 'ninja -C build'
+      upload_caches:
+        - ccache
+
+      tests_script:
+        - su postgres -c 'meson test --no-rebuild -C build'
+
+    - name: Linux Meson Sid
+
+      compute_engine_instance:
+        image: family/pg-aio-sid
+
+      configure_script:
+        - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=ossp build'
+      build_script:
+        - su postgres -c 'ninja -C build'
+      upload_caches:
+        - ccache
+
+      tests_script:
+        - su postgres -c 'meson test --no-rebuild -C build'
 
-  tests_script: |
-    su postgres -c '\
-      ulimit -c unlimited; \
-      make -s ${CHECK} ${CHECKFLAGS} -j8 \
-      '
+  always:
+    meson_log_artifacts:
+      path: "build/meson-logs/*.txt"
+      type: text/plain
 
   on_failure:
     cores_script: |
@@ -168,10 +229,13 @@ task:
     tap_artifacts:
       path: "**/regress_log_*"
       type: text/plain
+    meson_test_artifacts:
+      path: "build/meson-logs/testlog.junit.xml"
+      type: text/xml
+      format: junit
 
 
 task:
-  name: macOS
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*'
   osx_instance:
     image: big-sur-base
@@ -201,56 +265,87 @@ task:
     - sudo chmod 777 /cores
   homebrew_install_script:
     - brew install make coreutils ccache icu4c lz4 tcl-tk openldap
+    - brew install meson ninja python@3.9
   upload_caches:
     - homebrew
 
-  configure_script: |
-    LIBS="/usr/local/lib:$LIBS"
-    INCLUDES="/usr/local/include:$INCLUDES"
-
-    INCLUDES="/usr/local/opt/openssl/include:$INCLUDES"
-    LIBS="/usr/local/opt/openssl/lib:$LIBS"
-
-    PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
-    INCLUDES="/usr/local/opt/icu4c/include:$INCLUDES"
-    LIBS="/usr/local/opt/icu4c/lib:$LIBS"
-
-    LIBS="/usr/local/opt/openldap/lib:$LIBS"
-    INCLUDES="/usr/local/opt/openldap/include:$INCLUDES"
-
-    export PKG_CONFIG_PATH
-
-    ./configure \
-      --prefix=$HOME/install \
-      --with-includes="$INCLUDES" \
-      --with-libs="$LIBS" \
-      \
-      --enable-cassert --enable-debug --enable-tap-tests \
-      --enable-nls \
-      \
-      --with-icu \
-      --with-ldap \
-      --with-libxml \
-      --with-libxslt \
-      \
-      --with-lz4 \
-      --with-perl \
-      --with-python \
-      --with-ssl=openssl \
-      --with-tcl --with-tclconfig=/usr/local/opt/tcl-tk/lib/ \
-      --with-uuid=e2fs \
-      \
-      CC="ccache gcc" CFLAGS="-O0 -ggdb" \
-      PYTHON=python3
-  build_script:
-    - gmake -s -j12 && gmake -s -j12 -C contrib
-  upload_caches:
-    - ccache
+  matrix:
+    - name: macOS autoconf
+
+      configure_script: |
+        LIBS="/usr/local/lib:$LIBS"
+        INCLUDES="/usr/local/include:$INCLUDES"
+
+        PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
+        INCLUDES="/usr/local/opt/openssl/include:$INCLUDES"
+        LIBS="/usr/local/opt/openssl/lib:$LIBS"
+
+        PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
+        INCLUDES="/usr/local/opt/icu4c/include:$INCLUDES"
+        LIBS="/usr/local/opt/icu4c/lib:$LIBS"
+
+        PKG_CONFIG_PATH="/usr/local/opt/openldap/lib/pkgconfig:$PKG_CONFIG_PATH"
+        LIBS="/usr/local/opt/openldap/lib:$LIBS"
+        INCLUDES="/usr/local/opt/openldap/include:$INCLUDES"
+
+        export PKG_CONFIG_PATH
+
+        ./configure \
+          --prefix=$HOME/install \
+          --with-includes="$INCLUDES" \
+          --with-libs="$LIBS" \
+          \
+          --enable-cassert --enable-debug --enable-tap-tests \
+          --enable-nls \
+          \
+          --with-icu \
+          --with-ldap \
+          --with-libxml \
+          --with-libxslt \
+          \
+          --with-lz4 \
+          --with-perl \
+          --with-python \
+          --with-ssl=openssl \
+          --with-tcl --with-tclconfig=/usr/local/opt/tcl-tk/lib/ \
+          --with-uuid=e2fs \
+          \
+          CC="ccache gcc" CFLAGS="-O0 -ggdb" \
+          PYTHON=python3
+      build_script:
+        - gmake -s -j12 && gmake -s -j12 -C contrib
+      upload_caches:
+        - ccache
+
+      tests_script:
+        - ulimit -c unlimited
+        - ulimit -n 1024
+        - gmake -s -j12 ${CHECK} ${CHECKFLAGS}
+
+    - name: macOS meson
+
+      configure_script: |
+        PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
+        PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
+        PKG_CONFIG_PATH="/usr/local/opt/openldap/lib/pkgconfig:$PKG_CONFIG_PATH"
+
+        export PKG_CONFIG_PATH
+
+        meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs build
+      build_script:
+        - ninja -C build
+      upload_caches:
+        - ccache
+
+      tests_script:
+        - ulimit -c unlimited
+        - ulimit -n 1024
+        - meson test --no-rebuild -C build
 
-  tests_script:
-    - ulimit -c unlimited
-    - ulimit -n 1024
-    - gmake -s -j12 ${CHECK} ${CHECKFLAGS}
+  always:
+    meson_log_artifacts:
+      path: "build/meson-logs/*.txt"
+      type: text/plain
 
   on_failure:
     cores_script: |
@@ -266,10 +361,13 @@ task:
     tap_artifacts:
       path: "**/regress_log_*"
       type: text/plain
+    meson_test_artifacts:
+      path: "build/meson-logs/testlog.junit.xml"
+      type: text/xml
+      format: junit
 
 
 task:
-  name: Windows
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
   windows_container:
     dockerfile: ci/docker/windows_vs_2019
@@ -282,6 +380,8 @@ task:
     TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/ci/pg_ci_base.conf
     # Avoid re-installing over and over
     NO_TEMP_INSTALL: 1
+    # Try to hide git's tar
+    PATH: c:\windows\system32;${PATH}
 
   sysinfo_script:
     - chcp
@@ -290,55 +390,103 @@ task:
     - ps: Get-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug'
     - set
 
-  configure_script:
-    - copy ci\windows_build_config.pl src\tools\msvc\config.pl
-    - vcvarsall x64
-    - perl src/tools/msvc/mkvcbuild.pl
-  build_script:
-    - vcvarsall x64
-    # Disable file tracker, we're never going to rebuild...
-    - msbuild -m /p:TrackFileAccess=false pgsql.sln
-  tempinstall_script:
-    # Installation on windows currently only completely works from src\tools\msvc
-    - cd src\tools\msvc && perl .\install.pl %CIRRUS_WORKING_DIR%\tmp_install
-
-  check_test_script:
-    - perl src/tools/msvc/vcregress.pl check parallel
-  startcreate_test_script:
-    - tmp_install\bin\pg_ctl.exe initdb -D tmp_check\db -l tmp_check\initdb.log
-    - echo include '%TEMP_CONFIG%' >> tmp_check\db\postgresql.conf
-    - tmp_install\bin\pg_ctl.exe start -D tmp_check\db -l tmp_check\postmaster.log
-  plcheck_test_script:
-    - perl src/tools/msvc/vcregress.pl plcheck
-  isolationcheck_test_script:
-    - perl src/tools/msvc/vcregress.pl isolationcheck
-  modulescheck_test_script:
-    - perl src/tools/msvc/vcregress.pl modulescheck
-  contribcheck_test_script:
-    - perl src/tools/msvc/vcregress.pl contribcheck
-  stop_test_script:
-    - tmp_install\bin\pg_ctl.exe stop -D tmp_check\db -l tmp_check\postmaster.log
-  ssl_test_script:
-    - set with_ssl=openssl
-    - perl src/tools/msvc/vcregress.pl taptest .\src\test\ssl\
-  subscriptioncheck_test_script:
-    - perl src/tools/msvc/vcregress.pl taptest .\src\test\subscription\
-  authentication_test_script:
-    - perl src/tools/msvc/vcregress.pl taptest .\src\test\authentication\
-  recoverycheck_test_script:
-    - perl src/tools/msvc/vcregress.pl recoverycheck
-  bincheck_test_script:
-    - perl src/tools/msvc/vcregress.pl bincheck
-  upgradecheck_test_script:
-    - perl src/tools/msvc/vcregress.pl upgradecheck
-  ecpgcheck_test_script:
-    # tries to build additional stuff
-    - vcvarsall x64
-    # References ecpg_regression.proj in the current dir
-    - cd src\tools\msvc
-    - perl vcregress.pl ecpgcheck
+  matrix:
+    - name: Windows homegrown
+
+      configure_script:
+        - copy ci\windows_build_config.pl src\tools\msvc\config.pl
+        - vcvarsall x64
+        - perl src/tools/msvc/mkvcbuild.pl
+      build_script:
+        - vcvarsall x64
+        # Disable file tracker, we're never going to rebuild...
+        - msbuild -m /p:TrackFileAccess=false pgsql.sln
+      tempinstall_script:
+        # Installation on windows currently only completely works from src\tools\msvc
+        - cd src\tools\msvc && perl .\install.pl %CIRRUS_WORKING_DIR%\tmp_install
+
+      check_test_script:
+        - perl src/tools/msvc/vcregress.pl check parallel
+      startcreate_test_script:
+        - tmp_install\bin\pg_ctl.exe initdb -D tmp_check\db -l tmp_check\initdb.log
+        - echo include '%TEMP_CONFIG%' >> tmp_check\db\postgresql.conf
+        - tmp_install\bin\pg_ctl.exe start -D tmp_check\db -l tmp_check\postmaster.log
+      plcheck_test_script:
+        - perl src/tools/msvc/vcregress.pl plcheck
+      isolationcheck_test_script:
+        - perl src/tools/msvc/vcregress.pl isolationcheck
+      modulescheck_test_script:
+        - perl src/tools/msvc/vcregress.pl modulescheck
+      contribcheck_test_script:
+        - perl src/tools/msvc/vcregress.pl contribcheck
+      stop_test_script:
+        - tmp_install\bin\pg_ctl.exe stop -D tmp_check\db -l tmp_check\postmaster.log
+      ssl_test_script:
+        - set with_ssl=openssl
+        - perl src/tools/msvc/vcregress.pl taptest .\src\test\ssl\
+      subscriptioncheck_test_script:
+        - perl src/tools/msvc/vcregress.pl taptest .\src\test\subscription\
+      authentication_test_script:
+        - perl src/tools/msvc/vcregress.pl taptest .\src\test\authentication\
+      recoverycheck_test_script:
+        - perl src/tools/msvc/vcregress.pl recoverycheck
+      bincheck_test_script:
+        - perl src/tools/msvc/vcregress.pl bincheck
+      upgradecheck_test_script:
+        - perl src/tools/msvc/vcregress.pl upgradecheck
+      ecpgcheck_test_script:
+        # tries to build additional stuff
+        - vcvarsall x64
+        # References ecpg_regression.proj in the current dir
+        - cd src\tools\msvc
+        - perl vcregress.pl ecpgcheck
+
+    - name: Windows Meson+vs+Ninja
+
+      meson_script:
+        - pip install meson
+        - pip install ninja
+      configure_script:
+        - vcvarsall x64
+        - mkdir subprojects
+        - meson wrap install lz4
+        - meson wrap install zlib
+        - meson setup --buildtype debug --backend ninja  -Dcassert=true -Db_pch=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1.1l\lib -Dextra_include_dirs=c:\openssl\1.1.1l\include build
+      build_script:
+        - vcvarsall x64
+        - ninja -C build
+
+      check_script:
+        - vcvarsall x64
+        - meson test --no-rebuild -C build
+
+    - name: Windows Meson+vs+msbuild
+
+      # Need a development version of meson for now
+      meson_dev_script:
+        - git clone https://github.com/mesonbuild/meson.git
+
+      configure_script:
+        - vcvarsall x64
+        - mkdir subprojects
+        - .\meson\meson.py wrap install lz4
+        - .\meson\meson.py wrap install zlib
+        - .\meson\meson.py setup --buildtype debug --backend vs -Dcassert=true -Db_pch=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1.1l\lib -Dextra_include_dirs=c:\openssl\1.1.1l\include build
+
+      build_script:
+        - vcvarsall x64
+        - msbuild -m /p:UseMultiToolTask=true build\postgresql.sln
+
+      check_script:
+        - vcvarsall x64
+        - .\meson\meson.py test --no-rebuild -C build
 
   always:
+    meson_log_artifacts:
+      path: "build/meson-logs/*.txt"
+      type: text/plain
+    cat_dumps_script:
+
     cores_script:
       - cat crashlog.txt || true
     dump_artifacts:
@@ -355,12 +503,16 @@ task:
     tap_artifacts:
       path: "**/regress_log_*"
       type: text/plain
+    meson_test_artifacts:
+      path: "build/meson-logs/testlog.junit.xml"
+      type: text/xml
+      format: junit
 
 
 task:
   name: CompilerWarnings
   depends_on:
-    - Linux
+    - Linux Autoconf
   # task that did not run count as a success, so we need to recheck Linux' condition here :/
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
   container:
-- 
2.23.0.385.gbc12974a89

