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 # Source of images / containers
9 GCP_PROJECT: pg-ci-images
10 IMAGE_PROJECT: $GCP_PROJECT
11 CONTAINER_REPO: us-docker.pkg.dev/${GCP_PROJECT}/ci
13 # The lower depth accelerates git clone. Use a bit of depth so that
14 # concurrent tasks and retrying older jobs have a chance of working.
15 CIRRUS_CLONE_DEPTH: 500
16 # Useful to be able to analyse what in a script takes long
17 CIRRUS_LOG_TIMESTAMP: true
19 CCACHE_MAXSIZE: "250M"
21 # target to test, for all but windows
22 CHECK: check-world PROVE_FLAGS=$PROVE_FLAGS
25 MTEST_ARGS: --print-errorlogs --no-rebuild -C build
26 PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests
27 TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
28 PG_TEST_EXTRA: kerberos ldap ssl
31 # What files to preserve in case tests fail
32 on_failure_ac: &on_failure_ac
40 on_failure_meson: &on_failure_meson
43 - "build*/testrun/**/*.log"
44 - "build*/testrun/**/*.diffs"
45 - "build*/testrun/**/regress_log_*"
48 # In theory it'd be nice to upload the junit files meson generates, so that
49 # cirrus will nicely annotate the commit. Unfortunately the files don't
50 # contain identifiable file + line numbers right now, so the annotations
51 # don't end up useful. We could probably improve on that with a some custom
52 # conversion script, but ...
54 path: "build*/meson-logs/*.txt"
58 # To avoid unnecessarily spinning up a lot of VMs / containers for entirely
59 # broken commits, have a minimal task that all others depend on.
63 # If a specific OS is requested, don't run the sanity check. This shortens
64 # push-wait-for-ci cycle time a bit when debugging operating system specific
65 # failures. Uses skip instead of only_if, as cirrus otherwise warns about
66 # only_if conditions not matching.
67 skip: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:.*'
73 CCACHE_DIR: ${CIRRUS_WORKING_DIR}/ccache_dir
74 # no options enabled, should be small
75 CCACHE_MAXSIZE: "150M"
77 # Container starts up quickly, but is slower at runtime, particularly for
78 # tests. Good for the briefly running sanity check.
80 image: $CONTAINER_REPO/linux_debian_bullseye_ci:latest
88 chown -R postgres:postgres .
89 mkdir -p ${CCACHE_DIR}
90 chown -R postgres:postgres ${CCACHE_DIR}
91 echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf
92 su postgres -c "ulimit -l -H && ulimit -l -S"
93 # Can't change container's kernel.core_pattern. Postgres user can't write
94 # to / normally. Change that.
102 --auto-features=disabled \
103 -Dtap_tests=enabled \
108 ninja -C build -j${BUILD_JOBS}
110 upload_caches: ccache
112 # Run a minimal set of tests. The main regression tests take too long for
113 # this purpose. For now this is a random quick pg_regress style test, and a
114 # tap test that exercises both a frontend binary and the backend.
115 test_minimal_script: |
118 meson test $MTEST_ARGS --num-processes ${TEST_JOBS} \
119 tmp_install cube/regress pg_ctl/001_start_stop
123 <<: *on_failure_meson
125 mkdir -m 770 /tmp/cores
126 find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \;
127 src/tools/ci/cores_backtrace.sh linux /tmp/cores
131 name: FreeBSD - 13 - Meson
134 # FreeBSD on GCP is slow when running with larger number of CPUS /
135 # jobs. Using one more job than cpus seems to work best.
140 CCACHE_DIR: /tmp/ccache_dir
141 CPPFLAGS: -DRELCACHE_FORCE_RELEASE -DCOPY_PARSE_PLAN_TREES -DWRITE_READ_PARSE_PLAN_TREES -DRAW_EXPRESSION_COVERAGE_TEST
144 depends_on: SanityCheck
145 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*freebsd.*'
147 compute_engine_instance:
148 image_project: $IMAGE_PROJECT
149 image: family/pg-ci-freebsd-13
158 ulimit -a -H && ulimit -a -S
163 # Work around performance issues due to 32KB block size
164 repartition_script: src/tools/ci/gcp_freebsd_repartition.sh
165 create_user_script: |
167 chown -R postgres:postgres .
168 mkdir -p ${CCACHE_DIR}
169 chown -R postgres:postgres ${CCACHE_DIR}
170 setup_core_files_script: |
171 mkdir -m 770 /tmp/cores
172 chown root:postgres /tmp/cores
173 sysctl kern.corefile='/tmp/cores/%N.%P.core'
174 setup_additional_packages_script: |
177 # NB: Intentionally build without -Dllvm. The freebsd image size is already
178 # large enough to make VM startup slow, and even without llvm freebsd
179 # already takes longer than other platforms except for windows.
184 -Dcassert=true -Dssl=openssl -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
185 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
186 -Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
189 build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
190 upload_caches: ccache
195 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
198 # test runningcheck, freebsd chosen because it's currently fast enough
199 test_running_script: |
203 meson test $MTEST_ARGS --quiet --suite setup
204 export LD_LIBRARY_PATH="$(pwd)/build/tmp_install/usr/local/pgsql/lib/:$LD_LIBRARY_PATH"
205 mkdir -p build/testrun
206 build/tmp_install/usr/local/pgsql/bin/initdb -N build/runningcheck --no-instructions -A trust
207 echo "include '$(pwd)/src/tools/ci/pg_ci_base.conf'" >> build/runningcheck/postgresql.conf
208 build/tmp_install/usr/local/pgsql/bin/pg_ctl -c -o '-c fsync=off' -D build/runningcheck -l build/testrun/runningcheck.log start
209 meson test $MTEST_ARGS --num-processes ${TEST_JOBS} --setup running
210 build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop
214 # if the server continues running, it often causes cirrus-ci to fail
215 # during upload, as it doesn't expect artifacts to change size
216 stop_running_script: |
218 build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop || true
220 <<: *on_failure_meson
221 cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores
224 # configure feature flags, shared between the task running the linux tests and
225 # the CompilerWarnings task
226 LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
240 --with-tcl --with-tclconfig=/usr/lib/tcl8.6/
244 LINUX_MESON_FEATURES: &LINUX_MESON_FEATURES >-
254 TEST_JOBS: 8 # experimentally derived to be a decent choice
256 CCACHE_DIR: /tmp/ccache_dir
257 DEBUGINFOD_URLS: "https://debuginfod.debian.net"
259 # Enable a reasonable set of sanitizers. Use the linux task for that, as
260 # it's one of the fastest tasks (without sanitizers). Also several of the
261 # sanitizers work best on linux.
263 # The overhead of alignment sanitizer is low, undefined behaviour has
264 # moderate overhead. Test alignment sanitizer in the meson task, as it
265 # does both 32 and 64 bit builds and is thus more likely to expose
268 # Address sanitizer in contrast is somewhat expensive. Enable it in the
269 # autoconf task, as the meson task tests both 32 and 64bit.
271 # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes
272 # print_stacktraces=1,verbosity=2, duh
273 # detect_leaks=0: too many uninteresting leak errors in short-lived binaries
274 UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2
275 ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0
277 # SANITIZER_FLAGS is set in the tasks below
278 CFLAGS: -Og -ggdb -fno-sanitize-recover=all $SANITIZER_FLAGS
280 LDFLAGS: $SANITIZER_FLAGS
284 LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
285 LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
287 depends_on: SanityCheck
288 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*linux.*'
290 compute_engine_instance:
291 image_project: $IMAGE_PROJECT
292 image: family/pg-ci-bullseye
298 folder: ${CCACHE_DIR}
304 ulimit -a -H && ulimit -a -S
306 create_user_script: |
308 chown -R postgres:postgres .
309 mkdir -p ${CCACHE_DIR}
310 chown -R postgres:postgres ${CCACHE_DIR}
311 echo '* - memlock 134217728' > /etc/security/limits.d/postgres.conf
312 su postgres -c "ulimit -l -H && ulimit -l -S"
313 setup_core_files_script: |
314 mkdir -m 770 /tmp/cores
315 chown root:postgres /tmp/cores
316 sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core'
317 setup_additional_packages_script: |
319 #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
322 - name: Linux - Debian Bullseye - Autoconf
325 SANITIZER_FLAGS: -fsanitize=address
330 --enable-cassert --enable-debug --enable-tap-tests \
332 --with-segsize-blocks=8 \
334 ${LINUX_CONFIGURE_FEATURES} \
338 build_script: su postgres -c "make -s -j${BUILD_JOBS} world-bin"
339 upload_caches: ccache
343 ulimit -c unlimited # default is 0
344 make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
350 - name: Linux - Debian Bullseye - Meson
353 CCACHE_MAXSIZE: "400M" # tests two different builds
354 SANITIZER_FLAGS: -fsanitize=alignment,undefined
361 ${LINUX_MESON_FEATURES} \
362 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
366 # Also build & test in a 32bit build - it's gotten rare to test that
368 configure_32_script: |
370 export CC='ccache gcc -m32'
374 ${LINUX_MESON_FEATURES} \
376 --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
377 -DPERL=perl5.32-i386-linux-gnu \
378 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
382 build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
383 build_32_script: su postgres -c 'ninja -C build-32 -j${BUILD_JOBS}'
385 upload_caches: ccache
390 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
392 # so that we don't upload 64bit logs if 32bit fails
395 # There's currently no coverage of icu with LANG=C in the buildfarm. We
396 # can easily provide some here by running one of the sets of tests that
397 # way. Newer versions of python insist on changing the LC_CTYPE away
398 # from C, prevent that with PYTHONCOERCECLOCALE.
399 test_world_32_script: |
402 PYTHONCOERCECLOCALE=0 LANG=C meson test $MTEST_ARGS -C build-32 --num-processes ${TEST_JOBS}
406 <<: *on_failure_meson
409 cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores
413 name: macOS - Ventura - Meson
416 CPUS: 4 # always get that much for cirrusci macOS instances
418 # Test performance regresses noticably when using all cores. 8 seems to
420 # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de
423 CIRRUS_WORKING_DIR: ${HOME}/pgsql/
424 CCACHE_DIR: ${HOME}/ccache
425 HOMEBREW_CACHE: ${HOME}/homebrew-cache
426 PERL5LIB: ${HOME}/perl5/lib/perl5
430 CPPFLAGS: -DRANDOMIZE_ALLOCATED_MEMORY
434 depends_on: SanityCheck
435 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*(macos|darwin|osx).*'
438 image: ghcr.io/cirruslabs/macos-ventura-base:latest
443 ulimit -a -H && ulimit -a -S
446 setup_core_files_script:
447 - mkdir ${HOME}/cores
448 - sudo sysctl kern.corefile="${HOME}/cores/core.%P"
453 - perl -mIPC::Run -e 1 || cpan -T IPC::Run
454 - perl -mIO::Pty -e 1 || cpan -T IO::Pty
458 # XXX: Could we instead install homebrew into a cached directory? The
459 # homebrew installation takes a good bit of time every time, even if the
460 # packages do not need to be downloaded.
462 folder: $HOMEBREW_CACHE
463 setup_additional_packages_script: |
478 brew cleanup -s # to reduce cache size
479 upload_caches: homebrew
484 brewpath="/opt/homebrew"
485 PKG_CONFIG_PATH="${brewpath}/lib/pkgconfig:${PKG_CONFIG_PATH}"
487 for pkg in icu4c krb5 openldap openssl zstd ; do
488 pkgpath="${brewpath}/opt/${pkg}"
489 PKG_CONFIG_PATH="${pkgpath}/lib/pkgconfig:${PKG_CONFIG_PATH}"
490 PATH="${pkgpath}/bin:${pkgpath}/sbin:$PATH"
493 export PKG_CONFIG_PATH PATH
497 -Dextra_include_dirs=${brewpath}/include \
498 -Dextra_lib_dirs=${brewpath}/lib \
500 -Dssl=openssl -Duuid=e2fs -Ddtrace=auto \
502 -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
505 build_script: ninja -C build -j${BUILD_JOBS}
506 upload_caches: ccache
509 ulimit -c unlimited # default is 0
510 ulimit -n 1024 # default is 256, pretty low
511 meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
514 <<: *on_failure_meson
515 cores_script: src/tools/ci/cores_backtrace.sh macos "${HOME}/cores"
518 WINDOWS_ENVIRONMENT_BASE: &WINDOWS_ENVIRONMENT_BASE
520 # Half the allowed per-user CPU cores
523 # The default cirrus working dir is in a directory msbuild complains about
524 CIRRUS_WORKING_DIR: "c:/cirrus"
525 # git's tar doesn't deal with drive letters, see
526 # https://postgr.es/m/b6782dc3-a7b0-ed56-175f-f8f54cb08d67%40dunslane.net
527 TAR: "c:/windows/system32/tar.exe"
528 # Avoids port conflicts between concurrent tap test runs
529 PG_TEST_USE_UNIX_SOCKETS: 1
530 PG_REGRESS_SOCK_DIR: "c:/cirrus/"
535 powershell -Command get-psdrive -psprovider filesystem
540 name: Windows - Server 2019, VS 2019 - Meson & ninja
541 << : *WINDOWS_ENVIRONMENT_BASE
544 TEST_JOBS: 8 # wild guess, data based value welcome
546 # Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That
547 # prevents crash reporting from working unless binaries do SetErrorMode()
548 # themselves. Furthermore, it appears that either python or, more likely,
549 # the C runtime has a bug where SEM_NOGPFAULTERRORBOX can very
550 # occasionally *trigger* a crash on process exit - which is hard to debug,
551 # given that it explicitly prevents crash dumps from working...
552 # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX
553 CIRRUS_WINDOWS_ERROR_MODE: 0x8001
555 depends_on: SanityCheck
556 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
558 compute_engine_instance:
559 image_project: $IMAGE_PROJECT
560 image: family/pg-ci-windows-ci-vs-2019
565 setup_additional_packages_script: |
566 REM choco install -y --no-progress ...
568 # Use /DEBUG:FASTLINK to avoid high memory usage during linking
571 meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Db_pch=true -Dssl=openssl -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
577 check_world_script: |
579 meson test %MTEST_ARGS% --num-processes %TEST_JOBS%
582 <<: *on_failure_meson
584 path: "crashlog-*.txt"
589 << : *WINDOWS_ENVIRONMENT_BASE
590 name: Windows - Server 2019, MinGW64 - Meson
592 # due to resource constraints we don't run this task by default for now
594 # worth using only_if despite being manual, otherwise this task will show up
595 # when e.g. ci-os-only: linux is used.
596 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*mingw.*'
597 # otherwise it'll be sorted before other tasks
598 depends_on: SanityCheck
600 compute_engine_instance:
601 image_project: $IMAGE_PROJECT
602 image: family/pg-ci-windows-ci-mingw64
608 TEST_JOBS: 4 # higher concurrency causes occasional failures
609 CCACHE_DIR: C:/msys64/ccache
610 CCACHE_MAXSIZE: "500M"
611 CCACHE_SLOPPINESS: pch_defines,time_macros
613 # for some reason mingw plpython cannot find its installation without this
614 PYTHONHOME: C:/msys64/ucrt64
615 # prevents MSYS bash from resetting error mode
617 # Start bash in current working directory
619 BASH: C:\msys64\usr\bin\bash.exe -l
622 folder: ${CCACHE_DIR}
624 setup_additional_packages_script: |
625 REM C:\msys64\usr\bin\pacman.exe -S --noconfirm ...
628 %BASH% -c "where gcc"
629 %BASH% -c "gcc --version"
630 %BASH% -c "where perl"
631 %BASH% -c "perl --version"
633 # disable -Dnls as the number of files it creates cause a noticable slowdown
635 %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
638 %BASH% -c "ninja -C build"
640 upload_caches: ccache
643 %BASH% -c "meson test %MTEST_ARGS% --num-processes %TEST_JOBS%"
646 <<: *on_failure_meson
648 path: "crashlog-*.txt"
653 name: CompilerWarnings
655 # To limit unnecessary work only run this once the SanityCheck
656 # succeeds. This is particularly important for this task as we intentionally
657 # use always: to continue after failures. Task that did not run count as a
658 # success, so we need to recheck SanityChecks's condition here ...
659 depends_on: SanityCheck
660 only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*'
666 # Use larger ccache cache, as this task compiles with multiple compilers /
668 CCACHE_MAXSIZE: "1GB"
669 CCACHE_DIR: "/tmp/ccache_dir"
671 LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
672 LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
675 image: $CONTAINER_REPO/linux_debian_bullseye_ci:latest
682 ulimit -a -H && ulimit -a -S
690 setup_additional_packages_script: |
692 #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
695 # Test that code can be built with gcc/clang without warnings
698 setup_script: echo "COPT=-Werror" > src/Makefile.custom
700 # Trace probes have a history of getting accidentally broken. Use the
701 # different compilers to build with different combinations of dtrace on/off
702 # and cassert on/off.
704 # gcc, cassert off, dtrace on
706 gcc_warning_script: |
710 ${LINUX_CONFIGURE_FEATURES} \
711 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
712 make -s -j${BUILD_JOBS} clean
713 time make -s -j${BUILD_JOBS} world-bin
715 # gcc, cassert on, dtrace off
717 gcc_a_warning_script: |
721 ${LINUX_CONFIGURE_FEATURES} \
722 CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
723 make -s -j${BUILD_JOBS} clean
724 time make -s -j${BUILD_JOBS} world-bin
726 # clang, cassert off, dtrace off
728 clang_warning_script: |
730 --cache clang.cache \
731 ${LINUX_CONFIGURE_FEATURES} \
732 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
733 make -s -j${BUILD_JOBS} clean
734 time make -s -j${BUILD_JOBS} world-bin
736 # clang, cassert on, dtrace on
738 clang_a_warning_script: |
740 --cache clang.cache \
743 ${LINUX_CONFIGURE_FEATURES} \
744 CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
745 make -s -j${BUILD_JOBS} clean
746 time make -s -j${BUILD_JOBS} world-bin
748 # cross-compile to windows
750 mingw_cross_warning_script: |
752 --host=x86_64-w64-mingw32 \
754 CC="ccache x86_64-w64-mingw32-gcc" \
755 CXX="ccache x86_64-w64-mingw32-g++"
756 make -s -j${BUILD_JOBS} clean
757 time make -s -j${BUILD_JOBS} world-bin
760 # Verify docs can be built
762 # XXX: Only do this if there have been changes in doc/ since last build
770 make -s -j${BUILD_JOBS} clean
771 time make -s -j${BUILD_JOBS} -C doc
774 # Verify headerscheck / cpluspluscheck succeed
776 # - Don't use ccache, the files are uncacheable, polluting ccache's
778 # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose
779 # - XXX have to disable ICU to avoid errors:
780 # https://postgr.es/m/20220323002024.f2g6tivduzrktgfa%40alap3.anarazel.de
783 headers_headerscheck_script: |
785 ${LINUX_CONFIGURE_FEATURES} \
788 CC="gcc" CXX"=g++" CLANG="clang"
789 make -s -j${BUILD_JOBS} clean
790 time make -s headerscheck EXTRAFLAGS='-fmax-errors=10'
791 headers_cpluspluscheck_script: |
792 time make -s cpluspluscheck EXTRAFLAGS='-fmax-errors=10'
795 upload_caches: ccache