ci: Test NetBSD and OpenBSD
authorAndres Freund <[email protected]>
Wed, 12 Feb 2025 14:40:07 +0000 (09:40 -0500)
committerAndres Freund <[email protected]>
Wed, 12 Feb 2025 14:40:07 +0000 (09:40 -0500)
NetBSD and OpenBSD Postgres CI images are now generated [1], but aren't yet
utilized for Postgres' CI. This commit adds CI support for them.

For now the tasks will be manually triggered, to save on CI credits.

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

Author: Nazir Bilal Yavuz <[email protected]>
Discussion: https://postgr.es/m/CAN55FZ32ySyYa06k9MFd+VY5vHhUyBpvgmJUZae5PihjzaurVg@mail.gmail.com

.cirrus.tasks.yml
.cirrus.yml
src/tools/ci/README

index cfe2117e02e78531e7265d3c13e1e25722134e03..0d99b787f5fbf4d8099f4cf4adc7edfd742c2099 100644 (file)
@@ -216,6 +216,98 @@ task:
     cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores
 
 
+task:
+  depends_on: SanityCheck
+  trigger_type: manual
+
+  env:
+    # Below are experimentally derived to be a decent choice.
+    CPUS: 4
+    BUILD_JOBS: 8
+    TEST_JOBS: 8
+
+    # Default working directory is /tmp, but its total size (1.2 GB) is not
+    # enough, so different working and cache directory are set.
+    CIRRUS_WORKING_DIR: /home/postgres/postgres
+    CCACHE_DIR: /home/postgres/cache
+
+    PATH: /usr/sbin:$PATH
+
+  matrix:
+    - name: NetBSD - Meson
+      only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*netbsd.*'
+      env:
+        IMAGE_FAMILY: pg-ci-netbsd-postgres
+        PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/pkg/lib/pkgconfig'
+        # initdb fails with: 'invalid locale settings' error on NetBSD.
+        # Force 'LANG' and 'LC_*' variables to be 'C'.
+        # See https://postgr.es/m/2490325.1734471752%40sss.pgh.pa.us
+        LANG: "C"
+        LC_ALL: "C"
+        # -Duuid is not set for the NetBSD, see the comment below, above
+        # configure_script, for more information.
+      setup_additional_packages_script: |
+        #pkgin -y install ...
+      <<: *netbsd_task_template
+
+    - name: OpenBSD - Meson
+      only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*openbsd.*'
+      env:
+        IMAGE_FAMILY: pg-ci-openbsd-postgres
+        PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig'
+        UUID: -Duuid=e2fs
+        TCL: -Dtcl_version=tcl86
+      setup_additional_packages_script: |
+        #pkg_add -I ...
+      <<: *openbsd_task_template
+
+  sysinfo_script: |
+    locale
+    id
+    uname -a
+    ulimit -a -H && ulimit -a -S
+    env
+
+  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}
+
+  # -Duuid=bsd is not set since 'bsd' uuid option
+  # is not working on NetBSD & OpenBSD. See
+  # https://www.postgresql.org/message-id/[email protected]
+  # And other uuid options are not available on NetBSD.
+  configure_script: |
+    su postgres <<-EOF
+      meson setup \
+        --buildtype=debugoptimized \
+        --pkg-config-path ${PKGCONFIG_PATH} \
+        -Dcassert=true -Dinjection_points=true \
+        -Dssl=openssl ${UUID} ${TCL} \
+        -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
+        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
+      # Otherwise tests will fail on OpenBSD, due to inability to start enough
+      # processes.
+      ulimit -p 256
+      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 >-
index a83129ae46d1e37d14d0ac1da1b28a0e3c30651b..33c6e481d746afb69e703e1bb25fa721381f6ff0 100644 (file)
@@ -52,6 +52,16 @@ default_freebsd_task_template: &freebsd_task_template
     PLATFORM: freebsd
   <<: *cirrus_community_vm_template
 
+default_netbsd_task_template: &netbsd_task_template
+  env:
+    PLATFORM: netbsd
+  <<: *cirrus_community_vm_template
+
+default_openbsd_task_template: &openbsd_task_template
+  env:
+    PLATFORM: openbsd
+  <<: *cirrus_community_vm_template
+
 
 default_windows_task_template: &windows_task_template
   env:
index 30ddd200c9669bc05729847fc12cb2e721bfd956..12c1e7c308fa9959d554bc254936e001cb730184 100644 (file)
@@ -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|windows|mingw)}
+- ci-os-only: {(freebsd|linux|macos|mingw|netbsd|openbsd|windows)}
 
   Only runs CI on operating systems specified. This can be useful when
   addressing portability issues affecting only a subset of platforms.