1 # CI configuration file for CI utilizing cirrus-ci.org
3 # For instructions on how to enable the CI integration in a repository and
4 # further details, see src/tools/ci/README
8 # The lower depth accelerates git clone. Use a bit of depth so that
9 # concurrent tasks and retrying older jobs have a chance of working.
10 CIRRUS_CLONE_DEPTH: 500
11 # Useful to be able to analyse what in a script takes long
12 CIRRUS_LOG_TIMESTAMP: true
14 CCACHE_MAXSIZE: "250M"
16 # target to test, for all but windows
17 CHECK: check-world PROVE_FLAGS=$PROVE_FLAGS
20 MTEST_ARGS: --print-errorlogs --no-rebuild -C build
21 PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests
22 TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
23 PG_TEST_EXTRA: kerberos ldap ssl load_balance
26 # What files to preserve in case tests fail
27 on_failure_ac: &on_failure_ac
35 on_failure_meson: &on_failure_meson
38 - "build*/testrun/**/*.log"
39 - "build*/testrun/**/*.diffs"
40 - "build*/testrun/**/regress_log_*"
43 # In theory it'd be nice to upload the junit files meson generates, so that
44 # cirrus will nicely annotate the commit. Unfortunately the files don't
45 # contain identifiable file + line numbers right now, so the annotations
46 # don't end up useful. We could probably improve on that with a some custom
47 # conversion script, but ...
49 path: "build*/meson-logs/*.txt"
53 # To avoid unnecessarily spinning up a lot of VMs / containers for entirely
54 # broken commits, have a minimal task that all others depend on.
58 # If a specific OS is requested, don't run the sanity check. This shortens
59 # push-wait-for-ci cycle time a bit when debugging operating system specific
60 # failures. Uses skip instead of only_if, as cirrus otherwise warns about
61 # only_if conditions not matching.
62 skip: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:.*'
68 IMAGE_FAMILY: pg-ci-bullseye
69 CCACHE_DIR: ${CIRRUS_WORKING_DIR}/ccache_dir
70 # no options enabled, should be small
71 CCACHE_MAXSIZE: "150M"
73 # While containers would start up a bit quicker, building is a bit
74 # slower. This way we don't have to maintain a container image.
75 <<: *linux_task_template
82 chown -R postgres:postgres .
83 mkdir -p ${CCACHE_DIR}
84 chown -R postgres:postgres ${CCACHE_DIR}
85 echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf
86 su postgres -c "ulimit -l -H && ulimit -l -S"
87 # Can't change container's kernel.core_pattern. Postgres user can't write
88 # to / normally. Change that.
96 --auto-features=disabled \
102 ninja -C build -j${BUILD_JOBS}
104 upload_caches: ccache
106 # Run a minimal set of tests. The main regression tests take too long for
107 # this purpose. For now this is a random quick pg_regress style test, and a
108 # tap test that exercises both a frontend binary and the backend.
109 test_minimal_script: |
112 meson test $MTEST_ARGS --num-processes ${TEST_JOBS} \
113 tmp_install cube/regress pg_ctl/001_start_stop
117 <<: *on_failure_meson
119 mkdir -m 770 /tmp/cores
120 find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \;
121 src/tools/ci/cores_backtrace.sh linux /tmp/cores
125 name: FreeBSD - 13 - Meson
128 # FreeBSD on GCP is slow when running with larger number of CPUS /
129 # jobs. Using one more job than cpus seems to work best.
133 IMAGE_FAMILY: pg-ci-freebsd-13
136 CCACHE_DIR: /tmp/ccache_dir
137 CPPFLAGS: -DRELCACHE_FORCE_RELEASE -DCOPY_PARSE_PLAN_TREES -DWRITE_READ_PARSE_PLAN_TREES -DRAW_EXPRESSION_COVERAGE_TEST
140 <<: *freebsd_task_template
142 depends_on: SanityCheck
143 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*'
148 ulimit -a -H && ulimit -a -S
153 # Work around performance issues due to 32KB block size
154 repartition_script: src/tools/ci/gcp_freebsd_repartition.sh
155 create_user_script: |
157 chown -R postgres:postgres .
158 mkdir -p ${CCACHE_DIR}
159 chown -R postgres:postgres ${CCACHE_DIR}
160 setup_core_files_script: |
161 mkdir -m 770 /tmp/cores
162 chown root:postgres /tmp/cores
163 sysctl kern.corefile='/tmp/cores/%N.%P.core'
164 setup_additional_packages_script: |
167 # NB: Intentionally build without -Dllvm. The freebsd image size is already
168 # large enough to make VM startup slow, and even without llvm freebsd
169 # already takes longer than other platforms except for windows.
174 -Dcassert=true -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
175 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
176 -Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
179 build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
180 upload_caches: ccache
185 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
188 # test runningcheck, freebsd chosen because it's currently fast enough
189 test_running_script: |
193 meson test $MTEST_ARGS --quiet --suite setup
194 export LD_LIBRARY_PATH="$(pwd)/build/tmp_install/usr/local/pgsql/lib/:$LD_LIBRARY_PATH"
195 mkdir -p build/testrun
196 build/tmp_install/usr/local/pgsql/bin/initdb -N build/runningcheck --no-instructions -A trust
197 echo "include '$(pwd)/src/tools/ci/pg_ci_base.conf'" >> build/runningcheck/postgresql.conf
198 build/tmp_install/usr/local/pgsql/bin/pg_ctl -c -o '-c fsync=off' -D build/runningcheck -l build/testrun/runningcheck.log start
199 meson test $MTEST_ARGS --num-processes ${TEST_JOBS} --setup running
200 build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop
204 # if the server continues running, it often causes cirrus-ci to fail
205 # during upload, as it doesn't expect artifacts to change size
206 stop_running_script: |
208 build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop || true
210 <<: *on_failure_meson
211 cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores
214 # configure feature flags, shared between the task running the linux tests and
215 # the CompilerWarnings task
216 LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
230 --with-tcl --with-tclconfig=/usr/lib/tcl8.6/
234 LINUX_MESON_FEATURES: &LINUX_MESON_FEATURES >-
243 TEST_JOBS: 8 # experimentally derived to be a decent choice
244 IMAGE_FAMILY: pg-ci-bullseye
246 CCACHE_DIR: /tmp/ccache_dir
247 DEBUGINFOD_URLS: "https://debuginfod.debian.net"
249 # Enable a reasonable set of sanitizers. Use the linux task for that, as
250 # it's one of the fastest tasks (without sanitizers). Also several of the
251 # sanitizers work best on linux.
253 # The overhead of alignment sanitizer is low, undefined behaviour has
254 # moderate overhead. Test alignment sanitizer in the meson task, as it
255 # does both 32 and 64 bit builds and is thus more likely to expose
258 # Address sanitizer in contrast is somewhat expensive. Enable it in the
259 # autoconf task, as the meson task tests both 32 and 64bit.
261 # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes
262 # print_stacktraces=1,verbosity=2, duh
263 # detect_leaks=0: too many uninteresting leak errors in short-lived binaries
264 UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2
265 ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0
267 # SANITIZER_FLAGS is set in the tasks below
268 CFLAGS: -Og -ggdb -fno-sanitize-recover=all $SANITIZER_FLAGS
270 LDFLAGS: $SANITIZER_FLAGS
274 LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
275 LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
277 <<: *linux_task_template
279 depends_on: SanityCheck
280 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
283 folder: ${CCACHE_DIR}
289 ulimit -a -H && ulimit -a -S
291 create_user_script: |
293 chown -R postgres:postgres .
294 mkdir -p ${CCACHE_DIR}
295 chown -R postgres:postgres ${CCACHE_DIR}
296 echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf
297 su postgres -c "ulimit -l -H && ulimit -l -S"
298 setup_core_files_script: |
299 mkdir -m 770 /tmp/cores
300 chown root:postgres /tmp/cores
301 sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core'
303 setup_hosts_file_script: |
304 cat >> /etc/hosts <<-EOF
305 127.0.0.1 pg-loadbalancetest
306 127.0.0.2 pg-loadbalancetest
307 127.0.0.3 pg-loadbalancetest
310 setup_additional_packages_script: |
312 #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
315 - name: Linux - Debian Bullseye - Autoconf
318 SANITIZER_FLAGS: -fsanitize=address
320 # Normally, the "relation segment" code basically has no coverage in our
321 # tests, because we (quite reasonably) don't generate tables large
322 # enough in tests. We've had plenty bugs that we didn't notice due the
323 # code not being exercised much. Thus specify a very small segment size
324 # here. Use a non-power-of-two segment size, given we currently allow
329 --enable-cassert --enable-debug --enable-tap-tests \
331 --with-segsize-blocks=6 \
333 ${LINUX_CONFIGURE_FEATURES} \
337 build_script: su postgres -c "make -s -j${BUILD_JOBS} world-bin"
338 upload_caches: ccache
342 ulimit -c unlimited # default is 0
343 make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
349 - name: Linux - Debian Bullseye - Meson
352 CCACHE_MAXSIZE: "400M" # tests two different builds
353 SANITIZER_FLAGS: -fsanitize=alignment,undefined
360 ${LINUX_MESON_FEATURES} \
361 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
365 # Also build & test in a 32bit build - it's gotten rare to test that
367 configure_32_script: |
369 export CC='ccache gcc -m32'
373 ${LINUX_MESON_FEATURES} \
375 --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
376 -DPERL=perl5.32-i386-linux-gnu \
377 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
381 build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
382 build_32_script: su postgres -c 'ninja -C build-32 -j${BUILD_JOBS}'
384 upload_caches: ccache
389 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
391 # so that we don't upload 64bit logs if 32bit fails
394 # There's currently no coverage of icu with LANG=C in the buildfarm. We
395 # can easily provide some here by running one of the sets of tests that
396 # way. Newer versions of python insist on changing the LC_CTYPE away
397 # from C, prevent that with PYTHONCOERCECLOCALE.
398 test_world_32_script: |
401 PYTHONCOERCECLOCALE=0 LANG=C meson test $MTEST_ARGS -C build-32 --num-processes ${TEST_JOBS}
405 <<: *on_failure_meson
408 cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores
412 name: macOS - Ventura - Meson
415 CPUS: 4 # always get that much for cirrusci macOS instances
417 # Test performance regresses noticably when using all cores. 8 seems to
419 # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de
421 IMAGE: ghcr.io/cirruslabs/macos-ventura-base:latest
423 CIRRUS_WORKING_DIR: ${HOME}/pgsql/
424 CCACHE_DIR: ${HOME}/ccache
425 MACPORTS_CACHE: ${HOME}/macports-cache
432 <<: *macos_task_template
434 depends_on: SanityCheck
435 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*'
440 ulimit -a -H && ulimit -a -S
443 setup_core_files_script:
444 - mkdir ${HOME}/cores
445 - sudo sysctl kern.corefile="${HOME}/cores/core.%P"
447 # Use macports, even though homebrew is installed. The installation
448 # of the additional packages we need would take quite a while with
449 # homebrew, even if we cache the downloads. We can't cache all of
450 # homebrew, because it's already large. So we use macports. To cache
451 # the installation we create a .dmg file that we mount if it already
453 # XXX: The reason for the direct p5.34* references is that we'd need
454 # the large macport tree around to figure out that p5-io-tty is
455 # actually p5.34-io-tty. Using the unversioned name works, but
456 # updates macports every time.
458 folder: ${MACPORTS_CACHE}
459 setup_additional_packages_script: |
460 sh src/tools/ci/ci_macports_packages.sh \
472 # Make macports install visible for subsequent steps
473 echo PATH=/opt/local/sbin/:/opt/local/bin/:$PATH >> $CIRRUS_ENV
474 upload_caches: macports
479 export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/"
482 -Dextra_include_dirs=/opt/local/include \
483 -Dextra_lib_dirs=/opt/local/lib \
485 -Duuid=e2fs -Ddtrace=auto \
486 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
489 build_script: ninja -C build -j${BUILD_JOBS}
490 upload_caches: ccache
493 ulimit -c unlimited # default is 0
494 ulimit -n 1024 # default is 256, pretty low
495 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
498 <<: *on_failure_meson
499 cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores"
502 WINDOWS_ENVIRONMENT_BASE: &WINDOWS_ENVIRONMENT_BASE
504 # Half the allowed per-user CPU cores
507 # The default cirrus working dir is in a directory msbuild complains about
508 CIRRUS_WORKING_DIR: "c:/cirrus"
509 # git's tar doesn't deal with drive letters, see
510 # https://postgr.es/m/b6782dc3-a7b0-ed56-175f-f8f54cb08d67%40dunslane.net
511 TAR: "c:/windows/system32/tar.exe"
512 # Avoids port conflicts between concurrent tap test runs
513 PG_TEST_USE_UNIX_SOCKETS: 1
514 PG_REGRESS_SOCK_DIR: "c:/cirrus/"
520 powershell -Command get-psdrive -psprovider filesystem
525 name: Windows - Server 2019, VS 2019 - Meson & ninja
526 << : *WINDOWS_ENVIRONMENT_BASE
529 TEST_JOBS: 8 # wild guess, data based value welcome
531 # Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That
532 # prevents crash reporting from working unless binaries do SetErrorMode()
533 # themselves. Furthermore, it appears that either python or, more likely,
534 # the C runtime has a bug where SEM_NOGPFAULTERRORBOX can very
535 # occasionally *trigger* a crash on process exit - which is hard to debug,
536 # given that it explicitly prevents crash dumps from working...
537 # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX
538 CIRRUS_WINDOWS_ERROR_MODE: 0x8001
539 IMAGE_FAMILY: pg-ci-windows-ci-vs-2019
541 <<: *windows_task_template
543 depends_on: SanityCheck
544 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
546 setup_additional_packages_script: |
547 REM choco install -y --no-progress ...
549 setup_hosts_file_script: |
550 echo 127.0.0.1 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
551 echo 127.0.0.2 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
552 echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
553 type c:\Windows\System32\Drivers\etc\hosts
555 # Use /DEBUG:FASTLINK to avoid high memory usage during linking
558 meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
564 check_world_script: |
566 meson test %MTEST_ARGS% --num-processes %TEST_JOBS%
569 <<: *on_failure_meson
571 path: "crashlog-*.txt"
576 << : *WINDOWS_ENVIRONMENT_BASE
577 name: Windows - Server 2019, MinGW64 - Meson
579 # due to resource constraints we don't run this task by default for now
581 # worth using only_if despite being manual, otherwise this task will show up
582 # when e.g. ci-os-only: linux is used.
583 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*mingw.*'
584 # otherwise it'll be sorted before other tasks
585 depends_on: SanityCheck
588 TEST_JOBS: 4 # higher concurrency causes occasional failures
589 CCACHE_DIR: C:/msys64/ccache
590 CCACHE_MAXSIZE: "500M"
591 CCACHE_SLOPPINESS: pch_defines,time_macros
593 # for some reason mingw plpython cannot find its installation without this
594 PYTHONHOME: C:/msys64/ucrt64
595 # prevents MSYS bash from resetting error mode
597 # Start bash in current working directory
599 BASH: C:\msys64\usr\bin\bash.exe -l
600 IMAGE_FAMILY: pg-ci-windows-ci-mingw64
602 <<: *windows_task_template
605 folder: ${CCACHE_DIR}
607 setup_additional_packages_script: |
608 REM C:\msys64\usr\bin\pacman.exe -S --noconfirm ...
611 %BASH% -c "where gcc"
612 %BASH% -c "gcc --version"
613 %BASH% -c "where perl"
614 %BASH% -c "perl --version"
616 # disable -Dnls as the number of files it creates cause a noticable slowdown
618 %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
621 %BASH% -c "ninja -C build"
623 upload_caches: ccache
626 %BASH% -c "meson test %MTEST_ARGS% --num-processes %TEST_JOBS%"
629 <<: *on_failure_meson
631 path: "crashlog-*.txt"
636 name: CompilerWarnings
638 # To limit unnecessary work only run this once the SanityCheck
639 # succeeds. This is particularly important for this task as we intentionally
640 # use always: to continue after failures. Task that did not run count as a
641 # success, so we need to recheck SanityChecks's condition here ...
642 depends_on: SanityCheck
643 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*'
648 IMAGE_FAMILY: pg-ci-bullseye
650 # Use larger ccache cache, as this task compiles with multiple compilers /
653 CCACHE_DIR: "/tmp/ccache_dir"
655 LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
656 LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
658 <<: *linux_task_template
664 ulimit -a -H && ulimit -a -S
672 setup_additional_packages_script: |
674 #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
677 # Test that code can be built with gcc/clang without warnings
680 setup_script: echo "COPT=-Werror" > src/Makefile.custom
682 # Trace probes have a history of getting accidentally broken. Use the
683 # different compilers to build with different combinations of dtrace on/off
684 # and cassert on/off.
686 # gcc, cassert off, dtrace on
688 gcc_warning_script: |
692 ${LINUX_CONFIGURE_FEATURES} \
693 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
694 make -s -j${BUILD_JOBS} clean
695 time make -s -j${BUILD_JOBS} world-bin
697 # gcc, cassert on, dtrace off
699 gcc_a_warning_script: |
703 ${LINUX_CONFIGURE_FEATURES} \
704 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
705 make -s -j${BUILD_JOBS} clean
706 time make -s -j${BUILD_JOBS} world-bin
708 # clang, cassert off, dtrace off
710 clang_warning_script: |
712 --cache clang.cache \
713 ${LINUX_CONFIGURE_FEATURES} \
714 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
715 make -s -j${BUILD_JOBS} clean
716 time make -s -j${BUILD_JOBS} world-bin
718 # clang, cassert on, dtrace on
720 clang_a_warning_script: |
722 --cache clang.cache \
725 ${LINUX_CONFIGURE_FEATURES} \
726 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
727 make -s -j${BUILD_JOBS} clean
728 time make -s -j${BUILD_JOBS} world-bin
730 # cross-compile to windows
732 mingw_cross_warning_script: |
734 --host=x86_64-w64-mingw32 \
737 CC="ccache x86_64-w64-mingw32-gcc" \
738 CXX="ccache x86_64-w64-mingw32-g++"
739 make -s -j${BUILD_JOBS} clean
740 time make -s -j${BUILD_JOBS} world-bin
743 # Verify docs can be built
745 # XXX: Only do this if there have been changes in doc/ since last build
753 make -s -j${BUILD_JOBS} clean
754 time make -s -j${BUILD_JOBS} -C doc
757 # Verify headerscheck / cpluspluscheck succeed
759 # - Don't use ccache, the files are uncacheable, polluting ccache's
761 # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose
762 # - XXX have to disable ICU to avoid errors:
763 # https://postgr.es/m/20220323002024.f2g6tivduzrktgfa%40alap3.anarazel.de
766 headers_headerscheck_script: |
768 ${LINUX_CONFIGURE_FEATURES} \
771 CC="gcc" CXX"=g++" CLANG="clang"
772 make -s -j${BUILD_JOBS} clean
773 time make -s headerscheck EXTRAFLAGS='-fmax-errors=10'
774 headers_cpluspluscheck_script: |
775 time make -s cpluspluscheck EXTRAFLAGS='-fmax-errors=10'
778 upload_caches: ccache