From f0f906d56347ab56735a4159b7a55f1b4fbd7a60 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 20 Apr 2022 12:08:09 -0700
Subject: [PATCH v13 10/20] meson: ci: Build both with meson and as before

Author: Andres Freund <andres@anarazel.de>
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Justin Pryzby <pryzby@telsasoft.com>
---
 .cirrus.yml                                   | 843 +++++++++++++++++-
 src/tools/ci/docker/linux_centos7             |  57 ++
 src/tools/ci/docker/linux_centos8             |  54 ++
 src/tools/ci/docker/linux_fedora_rawhide      |  49 +
 src/tools/ci/docker/linux_opensuse_tumbleweed |  56 ++
 5 files changed, 1013 insertions(+), 46 deletions(-)
 create mode 100644 src/tools/ci/docker/linux_centos7
 create mode 100644 src/tools/ci/docker/linux_centos8
 create mode 100644 src/tools/ci/docker/linux_fedora_rawhide
 create mode 100644 src/tools/ci/docker/linux_opensuse_tumbleweed

diff --git a/.cirrus.yml b/.cirrus.yml
index 7034352c487..5a7a93baf4c 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -22,13 +22,14 @@ env:
   CHECK: check-world PROVE_FLAGS=$PROVE_FLAGS
   CHECKFLAGS: -Otarget
   PROVE_FLAGS: --timer
+  MTEST_ARGS: --print-errorlogs --no-rebuild -C build
   PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests
   TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
   PG_TEST_EXTRA: kerberos ldap ssl
 
 
 # What files to preserve in case tests fail
-on_failure: &on_failure
+on_failure_ac: &on_failure_ac
   log_artifacts:
     paths:
       - "**/*.log"
@@ -36,9 +37,41 @@ on_failure: &on_failure
       - "**/regress_log_*"
     type: text/plain
 
-task:
-  name: FreeBSD - 13
+on_failure_meson: &on_failure_meson
+  testrun_artifacts:
+    paths:
+      - "build/testrun/**/*.log"
+      - "build/testrun/**/*.diffs"
+      - "build/testrun/**/regress_log_*"
+    type: text/plain
 
+  # In theory it'd be nice to upload the junit files meson generates, so that
+  # cirrus will nicely annotate the commit. Unfortunately the files don't
+  # contain identifyable file + line numbers right now, so the annotations
+  # don't end up useful. We could probably improve on that with a some custom
+  # conversion script, but ...
+  meson_log_artifacts:
+    path: "build/meson-logs/*.txt"
+    type: text/plain
+
+
+# configure feature flags, shared between the task running the BSD tests
+# these feature flags don't include --with-gssapi and --with-uuid=bsd
+# since these are not working on openBSD and netBSD
+BSD_CONFIGURE_FEATURES: &BSD_CONFIGURE_FEATURES >-
+  --with-icu
+  --with-ldap
+  --with-libxml
+  --with-libxslt
+  --with-lz4
+  --with-pam
+  --with-perl
+  --with-python
+  --with-ssl=openssl
+  --with-tcl --with-tclconfig=${TCL_CONFIG_PATH}
+
+
+freebsd_template: &freebsd_template
   env:
     # FreeBSD on GCP is slow when running with larger number of CPUS /
     # jobs. Using one more job than cpus seems to work best.
@@ -48,6 +81,12 @@ task:
 
     CCACHE_DIR: /tmp/ccache_dir
 
+    TCL_CONFIG_PATH: /usr/local/lib/tcl8.6/
+
+    CFLAGS: "-Og -ggdb"
+
+    BSD_CONFIGURE_FEATURES: *BSD_CONFIGURE_FEATURES
+
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*'
 
   compute_engine_instance:
@@ -80,6 +119,13 @@ task:
   setup_additional_packages_script: |
     #pkg install -y ...
 
+
+task:
+  <<: *freebsd_template
+
+  name: FreeBSD - 13 - Autoconf
+  trigger_type: manual
+
   # NB: Intentionally build without --with-llvm. The freebsd image size is
   # already large enough to make VM startup slow, and even without llvm
   # freebsd already takes longer than other platforms except for windows.
@@ -90,16 +136,7 @@ task:
         --enable-nls \
         \
         --with-gssapi \
-        --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/ \
+        ${BSD_CONFIGURE_FEATURES} \
         --with-uuid=bsd \
         --with-zstd \
         \
@@ -107,8 +144,7 @@ task:
         --with-libs=/usr/local/lib \
         \
         CC="ccache cc" \
-        CXX="ccache c++" \
-        CFLAGS="-Og -ggdb"
+        CXX="ccache c++"
     EOF
   build_script: su postgres -c "gmake -s -j${BUILD_JOBS} world-bin"
   upload_caches: ccache
@@ -117,14 +153,274 @@ task:
   # platforms without support for locking pipes. See also
   # https://savannah.gnu.org/bugs/?60774
   # script uses pseudo-ttys, which do support locking.
-  test_world_script:
-    - su postgres -c "time script test.log gmake -s -j${TEST_JOBS} ${CHECK} ${CHECKFLAGS}"
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      time script test.log gmake -s -j${TEST_JOBS} ${CHECK} ${CHECKFLAGS}
+    EOF
 
   on_failure:
-    <<: *on_failure
+    <<: *on_failure_ac
     cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores
 
 
+task:
+  <<: *freebsd_template
+
+  name: FreeBSD - 13 - Meson
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+    cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores
+
+
+netbsd_template: &netbsd_template
+  env:
+    CPUS: 2
+    BUILD_JOBS: 3
+    TEST_JOBS: 3
+
+    CIRRUS_WORKING_DIR: /home/postgres/postgres
+    CCACHE_DIR: /tmp/ccache_dir
+
+    PATH: /usr/sbin:$PATH
+    TCL_CONFIG_PATH: /usr/pkg/lib
+
+    # Postgres interprets LANG as a 'en_US.UTF-8' but it is 'C', then
+    # Postgres tries to set 'LC_COLLATE' to 'en_US.UTF-8' but it is not
+    # changeable. Initdb fails because of that. So, LANG is forced to be 'C'.
+    LANG: "C"
+    LC_ALL: "C"
+
+    CFLAGS: "-Og -ggdb"
+
+    BSD_CONFIGURE_FEATURES: *BSD_CONFIGURE_FEATURES
+
+  only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*netbsd.*'
+
+  compute_engine_instance:
+    image_project: $IMAGE_PROJECT
+    image: family/pg-ci-netbsd-9-postgres
+    platform: netbsd
+    cpu: $CPUS
+    memory: 4G
+    disk: 25
+
+  sysinfo_script: |
+    locale
+    id
+    uname -a
+    ulimit -a -H && ulimit -a -S
+    export
+
+  ccache_cache:
+    folder: $CCACHE_DIR
+
+  create_user_script: |
+    useradd postgres
+    chown -R postgres:users /home/postgres
+    mkdir -p ${CCACHE_DIR}
+    chown -R postgres:users ${CCACHE_DIR}
+
+
+task:
+  <<: *netbsd_template
+
+  name: NetBSD - 9 - Autoconf
+  trigger_type: manual
+
+  # --with-uuid=bsd is not set since 'bsd' uuid option
+  # is not working on netBSD. See
+  # https://www.postgresql.org/message-id/17358-89806e7420797025@postgresql.org
+  # And other uuid options are not available on netBSD
+  configure_script: |
+    su postgres <<-EOF
+      ./configure \
+        --enable-cassert --enable-debug --enable-tap-tests \
+        --enable-nls \
+        \
+        ${BSD_CONFIGURE_FEATURES} \
+        \
+        --with-includes=/usr/pkg/include --with-libs=/usr/pgk/lib \
+        CC="ccache cc" \
+        CXX="ccache c++" \
+        LDFLAGS="-Wl,-R/usr/pkg/lib" \
+        \
+        PYTHON=python3.9
+    EOF
+  build_script: su postgres -c "gmake -s -j${BUILD_JOBS} world-bin"
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      gmake -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  <<: *netbsd_template
+
+  name: NetBSD - 9 - Meson
+
+  # -Duuid=bsd is not set since 'bsd' uuid option
+  # is not working on netBSD. See
+  # https://www.postgresql.org/message-id/17358-89806e7420797025@postgresql.org
+  # And other uuid options are not available on netBSD
+  configure_script: |
+    su postgres  <<-EOF
+      meson setup \
+        --buildtype debug \
+        -Dcassert=true -Dssl=openssl \
+        -Dextra_lib_dirs=/usr/pkg/lib -Dextra_include_dirs=/usr/pkg/include \
+        build
+    EOF
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
+openbsd_template: &openbsd_template
+  env:
+    CPUS: 2
+    BUILD_JOBS: 3
+    TEST_JOBS: 3
+
+    CIRRUS_WORKING_DIR: /home/postgres/postgres
+    CCACHE_DIR: /tmp/ccache_dir
+
+    PATH: /usr/sbin:$PATH
+    TCL_CONFIG_PATH: /usr/local/lib/tcl/tcl8.6/
+
+    # Postgres interprets LANG as a 'en_US.UTF-8' but it is 'C', then
+    # Postgres tries to set 'LC_COLLATE' to 'en_US.UTF-8' but it is not
+    # changeable. Initdb fails because of that. So, LANG is forced to be 'C'.
+    LANG: "C"
+    LC_ALL: "C"
+
+    CFLAGS: "-Og -ggdb"
+
+    BSD_CONFIGURE_FEATURES: *BSD_CONFIGURE_FEATURES
+
+  only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*openbsd.*'
+
+  compute_engine_instance:
+    image_project: $IMAGE_PROJECT
+    image: family/pg-ci-openbsd-7-postgres
+    platform: openbsd
+    cpu: $CPUS
+    memory: 4G
+    disk: 25
+
+  sysinfo_script: |
+    locale
+    id
+    uname -a
+    ulimit -a -H && ulimit -a -S
+    export
+
+  ccache_cache:
+    folder: $CCACHE_DIR
+
+  create_user_script: |
+    useradd postgres
+    chown -R postgres:postgres /home/postgres
+    mkdir -p ${CCACHE_DIR}
+    chown -R postgres:postgres ${CCACHE_DIR}
+
+
+task:
+  <<: *openbsd_template
+
+  name: OpenBSD - 7 - Autoconf
+  trigger_type: manual
+
+  # --with-uuid option is set to 'e2fs' since 'bsd' uuid option
+  # is not working on openBSD. See
+  # https://www.postgresql.org/message-id/17358-89806e7420797025@postgresql.org
+  # (same error applies for openBSD)
+  configure_script: |
+    su postgres <<-EOF
+      ./configure \
+        --enable-cassert --enable-debug --enable-tap-tests \
+        --enable-nls \
+        \
+        ${BSD_CONFIGURE_FEATURES} \
+        --with-uuid=e2fs \
+        \
+        --with-includes=/usr/local/include --with-libs=/usr/local/lib \
+        CC="ccache cc" \
+        CXX="ccache c++" \
+        LDFLAGS="-Wl,-R/usr/local/lib"
+    EOF
+  build_script: su postgres -c "gmake -s -j${BUILD_JOBS} world-bin"
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      gmake -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  <<: *openbsd_template
+
+  name: OpenBSD - 7 - Meson
+
+  # -Duuid option is set to 'e2fs' since 'bsd' uuid option
+  # is not working on openBSD. See
+  # https://www.postgresql.org/message-id/17358-89806e7420797025@postgresql.org
+  # (same error applies for openBSD)
+  configure_script: |
+    su postgres <<-EOF
+      meson setup \
+        --buildtype debug \
+        -Dcassert=true -Dssl=openssl -Duuid=e2fs \
+        -Dextra_include_dirs=/usr/local/include -Dextra_lib_dirs=/usr/local/lib \
+        build
+    EOF
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
 # configure feature flags, shared between the task running the linux tests and
 # the CompilerWarnings task
 LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
@@ -141,14 +437,28 @@ LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
   --with-selinux
   --with-ssl=openssl
   --with-systemd
-  --with-tcl --with-tclconfig=/usr/lib/tcl8.6/
-  --with-uuid=ossp
+  --with-tcl --with-tclconfig=${TCL_DIR:/usr/lib/tcl8.6/}
+  --with-uuid=${UUID:ossp}
   --with-zstd
 
 
-task:
-  name: Linux - Debian Bullseye
+# configure preparation scripts, shared between tasks running the linux tests
+linux_preparation_scripts_template: &linux_preparation_scripts_template
+  sysinfo_script: |
+    id
+    uname -a
+    cat /proc/cmdline
+    ulimit -a -H && ulimit -a -S
+    export
+  create_user_script: |
+    useradd -m -U postgres
+    chown -R postgres:postgres .
+    mkdir -p ${CCACHE_DIR}
+    chown -R postgres:postgres ${CCACHE_DIR}
+    su postgres -c "ulimit -l -H && ulimit -l -S"
 
+
+linux_debian_template: &linux_debian_template
   env:
     CPUS: 4
     BUILD_JOBS: 4
@@ -157,6 +467,9 @@ task:
     CCACHE_DIR: /tmp/ccache_dir
     DEBUGINFOD_URLS: "https://debuginfod.debian.net"
 
+    CFLAGS: "-Og -ggdb"
+    CXXFLAGS: "-Og -ggdb"
+
     LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
 
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
@@ -171,19 +484,9 @@ task:
   ccache_cache:
     folder: ${CCACHE_DIR}
 
-  sysinfo_script: |
-    id
-    uname -a
-    cat /proc/cmdline
-    ulimit -a -H && ulimit -a -S
-    export
-  create_user_script: |
-    useradd -m postgres
-    chown -R postgres:postgres .
-    mkdir -p ${CCACHE_DIR}
-    chown -R postgres:postgres ${CCACHE_DIR}
+  set_limits_script: |
     echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf
-    su postgres -c "ulimit -l -H && ulimit -l -S"
+  <<: *linux_preparation_scripts_template
   setup_core_files_script: |
     mkdir -m 770 /tmp/cores
     chown root:postgres /tmp/cores
@@ -192,6 +495,12 @@ task:
     #apt-get update
     #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
 
+
+task:
+  <<: *linux_debian_template
+
+  name: Linux - Debian Bullseye - Autoconf
+
   configure_script: |
     su postgres <<-EOF
       ./configure \
@@ -202,9 +511,7 @@ task:
         \
         CC="ccache gcc" \
         CXX="ccache g++" \
-        CLANG="ccache clang" \
-        CFLAGS="-Og -ggdb" \
-        CXXFLAGS="-Og -ggdb"
+        CLANG="ccache clang"
     EOF
   build_script: su postgres -c "make -s -j${BUILD_JOBS} world-bin"
   upload_caches: ccache
@@ -216,13 +523,353 @@ task:
     EOF
 
   on_failure:
-    <<: *on_failure
+    <<: *on_failure_ac
+    cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores
+
+
+task: &linux_debian_bullseye_meson
+  <<: *linux_debian_template
+
+  name: Linux - Debian Bullseye - Meson
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs -Ddtrace=enabled build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
     cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores
 
 
 task:
-  name: macOS - Monterey
+  <<: *linux_debian_bullseye_meson
 
+  name: Linux - Debian Sid - Meson
+  trigger_type: manual
+
+  compute_engine_instance:
+    image: family/pg-ci-sid
+
+
+linux_opensuse_template: &linux_opensuse_template
+  env:
+    CPUS: 4
+    BUILD_JOBS: 4
+    TEST_JOBS: 8 # experimentally derived to be a decent choice
+
+    CCACHE_DIR: /tmp/ccache_dir
+    DEBUGINFOD_URLS: "https://debuginfod.opensuse.org/"
+
+    TCL_DIR: /usr/lib64/
+    UUID: e2fs
+
+    CFLAGS: "-Og -ggdb"
+    CXXFLAGS: "-Og -ggdb"
+
+    LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
+
+  only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
+
+  container:
+    dockerfile: src/tools/ci/docker/linux_opensuse_tumbleweed
+    cpu: $CPUS
+    memory: 4G
+
+  ccache_cache:
+    folder: ${CCACHE_DIR}
+
+  <<: *linux_preparation_scripts_template
+
+
+task:
+  <<: *linux_opensuse_template
+
+  name: Linux - OpenSuse Tumbleweed - Autoconf
+  trigger_type: manual
+
+  configure_script: |
+    su postgres <<-EOF
+      export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" && \
+      ./configure \
+      --enable-cassert --enable-debug --enable-tap-tests \
+      --enable-nls \
+      \
+      ${LINUX_CONFIGURE_FEATURES}
+      \
+      CC="ccache gcc"  \
+      CXX="ccache g++" \
+      CLANG="ccache clang"
+    EOF
+  build_script: su postgres -c 'make -s -j${BUILD_JOBS} world-bin'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  <<: *linux_opensuse_template
+
+  name: Linux - OpenSuse Tumbleweed (LLVM) - Meson
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs -Dllvm=enabled build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
+linux_rhel_template: &linux_rhel_template
+  env:
+    CPUS: 4
+    BUILD_JOBS: 4
+    TEST_JOBS: 8 # experimentally derived to be a decent choice
+
+    CCACHE_DIR: /tmp/ccache_dir
+    DEBUGINFOD_URLS: ${DEBUGINFO}
+
+    TCL_DIR: /usr/lib64/
+    UUID: e2fs
+
+    CFLAGS: "-Og -ggdb"
+    CXXFLAGS: "-Og -ggdb"
+
+    LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
+
+  only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
+
+  container:
+    dockerfile: ${DOCKERFILE_PATH}
+    cpu: $CPUS
+    memory: 4G
+
+  ccache_cache:
+    folder: ${CCACHE_DIR}
+
+  <<: *linux_preparation_scripts_template
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_fedora_rawhide
+    DEBUGINFO: "https://debuginfod.fedoraproject.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Fedora Rawhide - Autoconf
+  trigger_type: manual
+
+  configure_script: |
+    su postgres <<-EOF
+      ./configure \
+      --enable-cassert --enable-debug --enable-tap-tests \
+      --enable-nls \
+      \
+      ${LINUX_CONFIGURE_FEATURES}
+      \
+      CC="ccache gcc"  \
+      CXX="ccache g++" \
+      CLANG="ccache clang"
+    EOF
+  build_script: su postgres -c 'make -s -j${BUILD_JOBS} world-bin'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_fedora_rawhide
+    DEBUGINFO: "https://debuginfod.fedoraproject.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Fedora Rawhide - Meson
+  trigger_type: manual
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_centos8
+    DEBUGINFO: "http://debuginfo.centos.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Centos 8 - Autoconf
+  trigger_type: manual
+
+  configure_script: |
+    su postgres <<-EOF
+      ./configure \
+      --enable-cassert --enable-debug --enable-tap-tests \
+      --enable-nls \
+      \
+      ${LINUX_CONFIGURE_FEATURES}
+      \
+      CC="ccache gcc"  \
+      CXX="ccache g++" \
+      CLANG="ccache clang"
+    EOF
+  build_script: su postgres -c 'make -s -j${BUILD_JOBS} world-bin'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_centos8
+    DEBUGINFO: "http://debuginfo.centos.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Centos 8 - Meson
+  trigger_type: manual
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_centos7
+    DEBUGINFO: "http://debuginfo.centos.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Centos 7 - Autoconf
+  trigger_type: manual
+
+  configure_script: |
+    su postgres <<-EOF
+      PYTHON=python3 \
+      ./configure \
+      --enable-cassert --enable-debug --enable-tap-tests \
+      --enable-nls \
+      \
+      --with-gssapi \
+      --with-icu \
+      --with-ldap \
+      --with-libxml \
+      --with-libxslt \
+      --with-lz4 \
+      --with-pam \
+      --with-perl \
+      --with-python \
+      --with-selinux \
+      --with-ssl=openssl \
+      --with-systemd \
+      --with-tcl --with-tclconfig=/usr/lib64/ \
+      --with-uuid=e2fs \
+      \
+      CC="ccache gcc"  \
+      CXX="ccache g++" \
+      CLANG="ccache clang"
+    EOF
+  build_script: su postgres -c 'make -s -j${BUILD_JOBS} world-bin'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_ac
+
+
+task:
+  env:
+    DOCKERFILE_PATH: src/tools/ci/docker/linux_centos7
+    DEBUGINFO: "http://debuginfo.centos.org/"
+
+  <<: *linux_rhel_template
+
+  name: Linux - Centos 7 - Meson
+  trigger_type: manual
+
+  configure_script:
+    - su postgres -c 'meson setup --buildtype debug -Dcassert=true -Dssl=openssl -Duuid=e2fs build'
+
+  build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
+  upload_caches: ccache
+
+  test_world_script: |
+    su postgres <<-EOF
+      ulimit -c unlimited
+      meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+    EOF
+
+  on_failure:
+    <<: *on_failure_meson
+
+
+macos_template: &macos_template
   env:
     CPUS: 12 # always get that much for cirrusci macOS instances
     BUILD_JOBS: $CPUS
@@ -233,6 +880,9 @@ task:
     HOMEBREW_CACHE: ${HOME}/homebrew-cache
     PERL5LIB: ${HOME}/perl5/lib/perl5
 
+    CFLAGS: "-Og -ggdb"
+    CXXFLAGS: "-Og -ggdb"
+
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*'
 
   osx_instance:
@@ -269,6 +919,7 @@ task:
       llvm \
       lz4 \
       make \
+      meson \
       openldap \
       openssl \
       python \
@@ -280,6 +931,14 @@ task:
 
   ccache_cache:
     folder: $CCACHE_DIR
+
+
+task:
+  <<: *macos_template
+
+  name: macOS - Monterey - Autoconf
+  trigger_type: manual
+
   configure_script: |
     brewpath="/usr/local"
     INCLUDES="${brewpath}/include:${INCLUDES}"
@@ -319,8 +978,6 @@ task:
       CC="ccache cc" \
       CXX="ccache c++" \
       CLANG="ccache ${brewpath}/llvm/bin/ccache" \
-      CFLAGS="-Og -ggdb" \
-      CXXFLAGS="-Og -ggdb" \
       \
       LLVM_CONFIG=${brewpath}/llvm/bin/llvm-config \
       PYTHON=python3
@@ -334,13 +991,48 @@ task:
     script test.log gmake -s -j${TEST_JOBS} ${CHECK} ${CHECKFLAGS}
 
   on_failure:
-    <<: *on_failure
+    <<: *on_failure_ac
     cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores"
 
 
 task:
-  name: Windows - Server 2019, VS 2019
+  <<: *macos_template
 
+  name: macOS - Monterey - Meson
+
+  configure_script: |
+    brewpath="/usr/local"
+    PKG_CONFIG_PATH="${brewpath}/lib/pkgconfig:${PKG_CONFIG_PATH}"
+
+    for pkg in icu4c krb5 openldap openssl ; do
+      pkgpath="${brewpath}/opt/${pkg}"
+      PKG_CONFIG_PATH="${pkgpath}/lib/pkgconfig:${PKG_CONFIG_PATH}"
+    done
+
+    export PKG_CONFIG_PATH
+
+    meson setup \
+      --buildtype debug \
+      -Dextra_include_dirs=${brewpath}/include \
+      -Dextra_lib_dirs=${brewpath}/lib \
+      -Dcassert=true \
+      -Dssl=openssl -Duuid=e2fs  -Ddtrace=auto \
+      build
+
+  build_script: ninja -C build -j${BUILD_JOBS}
+  upload_caches: ccache
+
+  tests_world_script:
+    - ulimit -c unlimited
+    - ulimit -n 1024
+    - meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
+
+  on_failure:
+    <<: *on_failure_meson
+    cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores"
+
+
+windows_template: &windows_template
   env:
     # Half the allowed per-user CPU cores
     CPUS: 4
@@ -412,6 +1104,11 @@ task:
   setup_additional_packages_script: |
     REM choco install -y --no-progress ...
 
+
+task:
+  <<: *windows_template
+  name: Windows - Server 2019, VS 2019 - Homegrown
+
   configure_script:
     # copy errors out when using forward slashes
     - copy src\tools\ci\windows_build_config.pl src\tools\msvc\config.pl
@@ -461,10 +1158,63 @@ task:
     %T_C% perl vcregress.pl ecpgcheck
 
   on_failure:
-    <<: *on_failure
+    <<: *on_failure_ac
+    crashlog_artifacts:
+      path: "crashlog-*.txt"
+
+
+task:
+  <<: *windows_template
+  name: Windows - Server 2019, VS 2019 - Meson & ninja
+
+  meson_install_wraps_script:
+    - mkdir subprojects
+    - meson wrap install lz4
+    - meson wrap install zlib
+
+  configure_script:
+    - vcvarsall x64
+    - meson setup --buildtype debug --backend ninja  -Dcassert=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe build
+
+  build_script:
+    - vcvarsall x64
+    - ninja -C build
+
+  check_world_script:
+    - vcvarsall x64
+    - meson test %MTEST_ARGS% --num-processes 10
+
+  on_failure:
+    <<: *on_failure_meson
+    crashlog_artifacts:
+      path: "crashlog-*.txt"
+
+
+task:
+  <<: *windows_template
+  name: Windows - Server 2019, VS 2019 - Meson & msbuild
+
+  meson_install_wraps_script:
+    - mkdir subprojects
+    - meson wrap install lz4
+    - meson wrap install zlib
+
+  configure_script:
+    - vcvarsall x64
+    - meson setup --buildtype debug --backend vs -Dcassert=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe build
+
+  build_script:
+    - vcvarsall x64
+    - msbuild %MSBFLAGS% build\postgresql.sln
+
+  check_world_script:
+    - vcvarsall x64
+    - meson test %MTEST_ARGS% --num-processes 10
+
+  on_failure:
+    <<: *on_failure_meson
     crashlog_artifacts:
       path: "crashlog-*.txt"
-      type: text/plain
 
 
 task:
@@ -472,7 +1222,8 @@ task:
 
   # To limit unnecessary work only run this once the normal linux test succeeds
   depends_on:
-    - Linux - Debian Bullseye
+    - Linux - Debian Bullseye - Meson
+  trigger_type: manual
 
   env:
     CPUS: 4
diff --git a/src/tools/ci/docker/linux_centos7 b/src/tools/ci/docker/linux_centos7
new file mode 100644
index 00000000000..3742890d961
--- /dev/null
+++ b/src/tools/ci/docker/linux_centos7
@@ -0,0 +1,57 @@
+FROM centos:centos7
+# Enable powertools, EPEL and devtoolset repository
+RUN \
+  yum -y install dnf-plugins-core \
+  epel-release \
+  centos-release-scl-rh && \
+  \
+  yum -y update && \
+  yum -y install \
+  \
+  git \
+  perl \
+  perl-ExtUtils-Embed \
+  perl-IPC-Run \
+  perl-Test-Harness \
+  perl-Test-Simple \
+  \
+  bison \
+  ccache \
+  clang \
+  devtoolset-7-make \
+  flex \
+  gcc \
+  gettext \
+  \
+  krb5-devel \
+  libicu-devel \
+  libuuid-devel \
+  libxml2-devel \
+  libxslt-devel \
+  libzstd-devel \
+  lz4-devel \
+  openldap-devel \
+  openssl-devel \
+  pam-devel \
+  python3-devel \
+  readline-devel \
+  systemd-devel \
+  tcl-devel \
+  \
+  krb5-server \
+  krb5-server-ldap \
+  krb5-workstation \
+  lz4 \
+  openldap-clients \
+  openldap-servers \
+  openssl \
+  zstd \
+  \
+  && \
+  pip3 install meson && \
+  pip3 install ninja && \
+  yum clean all
+
+# Make version is 3.82 but required is > 4, adding devtoolset-7-make to the PATH
+ENV PATH="/opt/rh/devtoolset-7/root/usr/bin/:${PATH}"
+ENV LANG=en_US.UTF-8
diff --git a/src/tools/ci/docker/linux_centos8 b/src/tools/ci/docker/linux_centos8
new file mode 100644
index 00000000000..58f95847ef1
--- /dev/null
+++ b/src/tools/ci/docker/linux_centos8
@@ -0,0 +1,54 @@
+FROM quay.io/centos/centos:stream8
+# Enable powertools and EPEL repository
+RUN \
+  dnf -y install dnf-plugins-core && \
+  dnf config-manager --set-enabled powertools && \
+  dnf -y install epel-release && \
+  dnf -y update && \
+  dnf -y install \
+  \
+  git \
+  meson \
+  perl \
+  perl-IPC-Run \
+  \
+  bison \
+  ccache \
+  clang \
+  diffutils \
+  flex \
+  gcc \
+  gettext \
+  \
+  krb5-devel \
+  libicu-devel \
+  libuuid-devel \
+  libxml2-devel \
+  libxslt-devel \
+  libzstd-devel \
+  llvm-devel \
+  lz4-devel \
+  openldap-devel \
+  openssl-devel \
+  pam-devel \
+  python3-devel \
+  readline-devel \
+  systemd-devel \
+  tcl-devel \
+  \
+  krb5-server \
+  krb5-server-ldap \
+  krb5-workstation \
+  lz4 \
+  openldap-clients \
+  openldap-servers \
+  openssl \
+  zstd \
+  \
+  glibc-langpack-en \
+  \
+  && \
+  pip3 install ninja && \
+  yum clean all
+
+ENV LANG=en_US.UTF-8
diff --git a/src/tools/ci/docker/linux_fedora_rawhide b/src/tools/ci/docker/linux_fedora_rawhide
new file mode 100644
index 00000000000..c95027cd6a7
--- /dev/null
+++ b/src/tools/ci/docker/linux_fedora_rawhide
@@ -0,0 +1,49 @@
+FROM fedora:rawhide
+RUN \
+  dnf -y update && \
+  dnf -y install \
+  git \
+  meson \
+  perl \
+  perl-IPC-Run \
+  \
+  bison \
+  ccache \
+  clang \
+  flex \
+  gcc \
+  gettext \
+  ninja-build \
+  \
+  krb5-devel \
+  libicu-devel \
+  libuuid-devel \
+  libxml2-devel \
+  libxslt-devel \
+  libzstd-devel \
+  llvm-devel \
+  lz4-devel \
+  openldap-devel \
+  openssl-devel \
+  pam-devel \
+  python3-devel \
+  readline-devel \
+  systemd-devel \
+  tcl-devel \
+  \
+  krb5-server \
+  krb5-server-ldap \
+  krb5-workstation \
+  lz4 \
+  openldap-clients \
+  openldap-servers \
+  openssl \
+  zstd \
+  \
+  langpacks-en \
+  glibc-langpack-en \
+  \
+  && \
+  yum clean all
+
+ENV LANG=en_US.UTF-8
diff --git a/src/tools/ci/docker/linux_opensuse_tumbleweed b/src/tools/ci/docker/linux_opensuse_tumbleweed
new file mode 100644
index 00000000000..07364ee85ff
--- /dev/null
+++ b/src/tools/ci/docker/linux_opensuse_tumbleweed
@@ -0,0 +1,56 @@
+FROM opensuse/tumbleweed
+RUN \
+  zypper -n clean -a && \
+  zypper -n ref && \
+  zypper -n dup && \
+  zypper -n update && \
+  zypper -n install \
+  diffutils \
+  git \
+  icu \
+  make \
+  meson \
+  perl-IPC-Run \
+  shadow \
+  systemd-devel \
+  util-linux \
+  \
+  bison \
+  ccache \
+  clang \
+  flex \
+  gcc \
+  gcc-c++ \
+  gettext-runtime \
+  ninja \
+  \
+  krb5-devel \
+  libicu-devel \
+  libldapcpp-devel \
+  liblz4-devel \
+  libopenssl-devel \
+  libselinux-devel \
+  libuuid-devel \
+  libxml2-devel \
+  libxslt-devel \
+  libzstd-devel \
+  llvm-devel \
+  pam-devel \
+  python38-devel \
+  readline-devel \
+  tcl-devel \
+  \
+  openldap2 \
+  openldap2-client \
+  \
+  krb5-client \
+  krb5-plugin-kdb-ldap \
+  krb5-server \
+  lz4 \
+  zstd \
+  \
+  && \
+  zypper -n clean -a
+
+# Fixing ICU errors caused by locale being set to 'POSIX'
+ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
-- 
2.37.3.542.gdd3f6c4cae

