Skip to content

Commit 262283d

Browse files
committed
ci: Fix cached MacPorts installation management
1. The error reporting of "port setrequested list-of-packages..." changed, hiding errors we were relying on to know if all packages in our list were already installed. Use a loop instead. 2. The cached MacPorts installation was shared between PostgreSQL major branches, though each branch wanted different packages. Add the list of packages to cache key, so that different branches, when tested in one github account/repo such as postgres/postgres, stop fighting with each other, adding and removing packages. Back-patch to 15 where CI began. Author: Thomas Munro <[email protected]> Author: Nazir Bilal Yavuz <[email protected]> Suggested-by: Andres Freund <[email protected]> Discussion: https://postgr.es/m/au2uqfuy2nf43nwy2txmc5t2emhwij7kzupygto3d2ffgtrdgr%40ckvrlwyflnh2
1 parent 61171a6 commit 262283d

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

.cirrus.tasks.yml

+18-16
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,20 @@ task:
427427
CCACHE_DIR: ${HOME}/ccache
428428
MACPORTS_CACHE: ${HOME}/macports-cache
429429

430+
MACOS_PACKAGE_LIST: >-
431+
ccache
432+
icu
433+
kerberos5
434+
lz4
435+
meson
436+
openldap
437+
openssl
438+
p5.34-io-tty
439+
p5.34-ipc-run
440+
python312
441+
tcl
442+
zstd
443+
430444
CC: ccache cc
431445
CXX: ccache c++
432446
CFLAGS: -Og -ggdb
@@ -463,26 +477,14 @@ task:
463477
macports_cache:
464478
folder: ${MACPORTS_CACHE}
465479
fingerprint_script: |
466-
# Include the OS major version in the cache key. If the OS image changes
467-
# to a different major version, we need to reinstall.
480+
# Reinstall packages if the OS major version, the list of the packages
481+
# to install or the MacPorts install script changes.
468482
sw_vers -productVersion | sed 's/\..*//'
469-
# Also start afresh if we change our MacPorts install script.
483+
echo $MACOS_PACKAGE_LIST
470484
md5 src/tools/ci/ci_macports_packages.sh
471485
reupload_on_changes: true
472486
setup_additional_packages_script: |
473-
sh src/tools/ci/ci_macports_packages.sh \
474-
ccache \
475-
icu \
476-
kerberos5 \
477-
lz4 \
478-
meson \
479-
openldap \
480-
openssl \
481-
p5.34-io-tty \
482-
p5.34-ipc-run \
483-
python312 \
484-
tcl \
485-
zstd
487+
sh src/tools/ci/ci_macports_packages.sh $MACOS_PACKAGE_LIST
486488
# system python doesn't provide headers
487489
sudo /opt/local/bin/port select python3 python312
488490
# Make macports install visible for subsequent steps

src/tools/ci/ci_macports_packages.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ if [ -n "$(port -q installed installed)" ] ; then
5959
sudo port unsetrequested installed
6060
fi
6161

62-
# if setting all the required packages as requested fails, we need
63-
# to install at least one of them
64-
if ! sudo port setrequested $packages > /dev/null 2>&1 ; then
65-
echo not all required packages installed, doing so now
62+
# If setting all the required packages as requested fails, we need
63+
# to install at least one of them. Need to do so one-by-one as
64+
# port setrequested only reports failures for the first package.
65+
echo "checking if all required packages are installed"
66+
for package in $packages ; do
67+
if ! sudo port setrequested $package > /dev/null 2>&1 ; then
6668
update_cached_image=1
69+
fi
70+
done
71+
echo "done"
72+
if [ "$update_cached_image" -eq 1 ]; then
73+
echo not all required packages installed, doing so now
6774
# to keep the image small, we deleted the ports tree from the image...
6875
sudo port selfupdate
6976
# XXX likely we'll need some other way to force an upgrade at some

0 commit comments

Comments
 (0)