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 \
473 # system python doesn't provide headers
474 sudo /opt/local/bin/port select python3 python312
475 # Make macports install visible for subsequent steps
476 echo PATH=/opt/local/sbin/:/opt/local/bin/:$PATH >> $CIRRUS_ENV
477 upload_caches: macports
482 export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/"
485 -Dextra_include_dirs=/opt/local/include \
486 -Dextra_lib_dirs=/opt/local/lib \
488 -Duuid=e2fs -Ddtrace=auto \
489 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
492 build_script: ninja -C build -j${BUILD_JOBS}
493 upload_caches: ccache
496 ulimit -c unlimited # default is 0
497 ulimit -n 1024 # default is 256, pretty low
498 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
501 <<: *on_failure_meson
502 cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores"
505 WINDOWS_ENVIRONMENT_BASE: &WINDOWS_ENVIRONMENT_BASE
507 # Half the allowed per-user CPU cores
510 # The default cirrus working dir is in a directory msbuild complains about
511 CIRRUS_WORKING_DIR: "c:/cirrus"
512 # git's tar doesn't deal with drive letters, see
513 # https://postgr.es/m/b6782dc3-a7b0-ed56-175f-f8f54cb08d67%40dunslane.net
514 TAR: "c:/windows/system32/tar.exe"
515 # Avoids port conflicts between concurrent tap test runs
516 PG_TEST_USE_UNIX_SOCKETS: 1
517 PG_REGRESS_SOCK_DIR: "c:/cirrus/"
523 powershell -Command get-psdrive -psprovider filesystem
528 name: Windows - Server 2019, VS 2019 - Meson & ninja
529 << : *WINDOWS_ENVIRONMENT_BASE
532 TEST_JOBS: 8 # wild guess, data based value welcome
534 # Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That
535 # prevents crash reporting from working unless binaries do SetErrorMode()
536 # themselves. Furthermore, it appears that either python or, more likely,
537 # the C runtime has a bug where SEM_NOGPFAULTERRORBOX can very
538 # occasionally *trigger* a crash on process exit - which is hard to debug,
539 # given that it explicitly prevents crash dumps from working...
540 # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX
541 CIRRUS_WINDOWS_ERROR_MODE: 0x8001
542 IMAGE_FAMILY: pg-ci-windows-ci-vs-2019
544 <<: *windows_task_template
546 depends_on: SanityCheck
547 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
549 setup_additional_packages_script: |
550 REM choco install -y --no-progress ...
552 setup_hosts_file_script: |
553 echo 127.0.0.1 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
554 echo 127.0.0.2 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
555 echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
556 type c:\Windows\System32\Drivers\etc\hosts
558 # Use /DEBUG:FASTLINK to avoid high memory usage during linking
561 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
567 check_world_script: |
569 meson test %MTEST_ARGS% --num-processes %TEST_JOBS%
572 <<: *on_failure_meson
574 path: "crashlog-*.txt"
579 << : *WINDOWS_ENVIRONMENT_BASE
580 name: Windows - Server 2019, MinGW64 - Meson
582 # due to resource constraints we don't run this task by default for now
584 # worth using only_if despite being manual, otherwise this task will show up
585 # when e.g. ci-os-only: linux is used.
586 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*mingw.*'
587 # otherwise it'll be sorted before other tasks
588 depends_on: SanityCheck
591 TEST_JOBS: 4 # higher concurrency causes occasional failures
592 CCACHE_DIR: C:/msys64/ccache
593 CCACHE_MAXSIZE: "500M"
594 CCACHE_SLOPPINESS: pch_defines,time_macros
596 # for some reason mingw plpython cannot find its installation without this
597 PYTHONHOME: C:/msys64/ucrt64
598 # prevents MSYS bash from resetting error mode
600 # Start bash in current working directory
602 BASH: C:\msys64\usr\bin\bash.exe -l
603 IMAGE_FAMILY: pg-ci-windows-ci-mingw64
605 <<: *windows_task_template
608 folder: ${CCACHE_DIR}
610 setup_additional_packages_script: |
611 REM C:\msys64\usr\bin\pacman.exe -S --noconfirm ...
614 %BASH% -c "where gcc"
615 %BASH% -c "gcc --version"
616 %BASH% -c "where perl"
617 %BASH% -c "perl --version"
619 # disable -Dnls as the number of files it creates cause a noticable slowdown
621 %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
624 %BASH% -c "ninja -C build"
626 upload_caches: ccache
629 %BASH% -c "meson test %MTEST_ARGS% --num-processes %TEST_JOBS%"
632 <<: *on_failure_meson
634 path: "crashlog-*.txt"
639 name: CompilerWarnings
641 # To limit unnecessary work only run this once the SanityCheck
642 # succeeds. This is particularly important for this task as we intentionally
643 # use always: to continue after failures. Task that did not run count as a
644 # success, so we need to recheck SanityChecks's condition here ...
645 depends_on: SanityCheck
646 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*'
651 IMAGE_FAMILY: pg-ci-bullseye
653 # Use larger ccache cache, as this task compiles with multiple compilers /
656 CCACHE_DIR: "/tmp/ccache_dir"
658 LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
659 LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
661 <<: *linux_task_template
667 ulimit -a -H && ulimit -a -S
675 setup_additional_packages_script: |
677 #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
680 # Test that code can be built with gcc/clang without warnings
683 setup_script: echo "COPT=-Werror" > src/Makefile.custom
685 # Trace probes have a history of getting accidentally broken. Use the
686 # different compilers to build with different combinations of dtrace on/off
687 # and cassert on/off.
689 # gcc, cassert off, dtrace on
691 gcc_warning_script: |
695 ${LINUX_CONFIGURE_FEATURES} \
696 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
697 make -s -j${BUILD_JOBS} clean
698 time make -s -j${BUILD_JOBS} world-bin
700 # gcc, cassert on, dtrace off
702 gcc_a_warning_script: |
706 ${LINUX_CONFIGURE_FEATURES} \
707 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
708 make -s -j${BUILD_JOBS} clean
709 time make -s -j${BUILD_JOBS} world-bin
711 # clang, cassert off, dtrace off
713 clang_warning_script: |
715 --cache clang.cache \
716 ${LINUX_CONFIGURE_FEATURES} \
717 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
718 make -s -j${BUILD_JOBS} clean
719 time make -s -j${BUILD_JOBS} world-bin
721 # clang, cassert on, dtrace on
723 clang_a_warning_script: |
725 --cache clang.cache \
728 ${LINUX_CONFIGURE_FEATURES} \
729 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
730 make -s -j${BUILD_JOBS} clean
731 time make -s -j${BUILD_JOBS} world-bin
733 # cross-compile to windows
735 mingw_cross_warning_script: |
737 --host=x86_64-w64-mingw32 \
740 CC="ccache x86_64-w64-mingw32-gcc" \
741 CXX="ccache x86_64-w64-mingw32-g++"
742 make -s -j${BUILD_JOBS} clean
743 time make -s -j${BUILD_JOBS} world-bin
746 # Verify docs can be built
748 # XXX: Only do this if there have been changes in doc/ since last build
756 make -s -j${BUILD_JOBS} clean
757 time make -s -j${BUILD_JOBS} -C doc
760 # Verify headerscheck / cpluspluscheck succeed
762 # - Don't use ccache, the files are uncacheable, polluting ccache's
764 # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose
765 # - XXX have to disable ICU to avoid errors:
766 # https://postgr.es/m/20220323002024.f2g6tivduzrktgfa%40alap3.anarazel.de
769 headers_headerscheck_script: |
771 ${LINUX_CONFIGURE_FEATURES} \
774 CC="gcc" CXX"=g++" CLANG="clang"
775 make -s -j${BUILD_JOBS} clean
776 time make -s headerscheck EXTRAFLAGS='-fmax-errors=10'
777 headers_cpluspluscheck_script: |
778 time make -s cpluspluscheck EXTRAFLAGS='-fmax-errors=10'
781 upload_caches: ccache