Skip to content

Commit c6876df

Browse files
committed
ci: Add feature to use different meson versions
We want to have a branch that uses a specific branch of meson for all tasks. Then, we can create a Cirrus cron "job" that tests Postgres againts different meson branches. Set a different meson branch by using `MESON_REPO` and `MESON_BRANCH` environment variables. Use a bash script to install this specific meson branch and rebase current Postgres branch onto Postgres HEAD. Fixes anarazel#81.
1 parent 8a2b1b1 commit c6876df

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.cirrus.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ env:
2727
TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
2828
PG_TEST_EXTRA: kerberos ldap ssl load_balance
2929

30+
# default variables to use in local meson installations
31+
MESON_REPO: https://github.com/mesonbuild/meson.git
32+
MESON_BRANCH: master
33+
3034

3135
# What files to preserve in case tests fail
3236
on_failure_ac: &on_failure_ac
@@ -95,6 +99,9 @@ task:
9599
chown root:postgres /
96100
chmod g+rwx /
97101
102+
install_meson_and_rebase_script: |
103+
bash src/tools/ci/install_meson_and_rebase.sh ${MESON_REPO} ${MESON_BRANCH} linux
104+
98105
configure_script: |
99106
su postgres <<-EOF
100107
meson setup \
@@ -174,6 +181,9 @@ task:
174181
setup_additional_packages_script: |
175182
#pkg install -y ...
176183
184+
install_meson_and_rebase_script: |
185+
bash src/tools/ci/install_meson_and_rebase.sh ${MESON_REPO} ${MESON_BRANCH} freebsd
186+
177187
# NB: Intentionally build without -Dllvm. The freebsd image size is already
178188
# large enough to make VM startup slow, and even without llvm freebsd
179189
# already takes longer than other platforms except for windows.
@@ -360,6 +370,9 @@ task:
360370
CCACHE_MAXSIZE: "400M" # tests two different builds
361371
SANITIZER_FLAGS: -fsanitize=alignment,undefined
362372

373+
install_meson_and_rebase_script: |
374+
bash src/tools/ci/install_meson_and_rebase.sh ${MESON_REPO} ${MESON_BRANCH} linux
375+
363376
configure_script: |
364377
su postgres <<-EOF
365378
meson setup \
@@ -485,6 +498,9 @@ task:
485498
brew cleanup -s # to reduce cache size
486499
upload_caches: homebrew
487500

501+
install_meson_and_rebase_script: |
502+
bash src/tools/ci/install_meson_and_rebase.sh ${MESON_REPO} ${MESON_BRANCH} macos
503+
488504
ccache_cache:
489505
folder: $CCACHE_DIR
490506
configure_script: |
@@ -578,6 +594,9 @@ task:
578594
echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
579595
type c:\Windows\System32\Drivers\etc\hosts
580596
597+
install_meson_and_rebase_script: |
598+
bash src/tools/ci/install_meson_and_rebase.sh %MESON_REPO% %MESON_BRANCH% windows
599+
581600
# Use /DEBUG:FASTLINK to avoid high memory usage during linking
582601
configure_script: |
583602
vcvarsall x64
@@ -643,6 +662,9 @@ task:
643662
%BASH% -c "where perl"
644663
%BASH% -c "perl --version"
645664
665+
install_meson_and_rebase_script: |
666+
%BASH% src/tools/ci/install_meson_and_rebase.sh %MESON_REPO% %MESON_BRANCH% mingw
667+
646668
# disable -Dnls as the number of files it creates cause a noticable slowdown
647669
configure_script: |
648670
%BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#! /bin/sh
2+
3+
set -e
4+
set -x
5+
6+
MESON_REPO=$1
7+
MESON_BRANCH=$2
8+
CURRENT_OS=$3
9+
10+
if [ $# -ne 3 ]; then
11+
echo "install_meson_and_rebase.sh <MESON_REPO> <MESON_BRANCH> <OS>"
12+
exit 1
13+
fi
14+
15+
case $CURRENT_OS in
16+
freebsd|linux|macos|windows|mingw)
17+
;;
18+
*)
19+
echo "unsupported operating system ${CURRENT_OS}"
20+
exit 1
21+
;;
22+
esac
23+
24+
# After repartition, hidden files are not copied. Copy them to
25+
# working dir
26+
if [ "$CURRENT_OS" = 'freebsd' ]; then
27+
cp -r $CIRRUS_WORKING_DIR.orig/.[^.]* $CIRRUS_WORKING_DIR/
28+
chown -R postgres:postgres .[^.]*
29+
fi
30+
31+
# pip is not installed as a default on some OSes. First install
32+
# pip, then install meson by using pip.
33+
install_meson () {
34+
case $CURRENT_OS in
35+
linux)
36+
apt update
37+
apt install python3-pip -y
38+
pip install git+${MESON_REPO}@${MESON_BRANCH}
39+
;;
40+
freebsd)
41+
python3 -m ensurepip --upgrade
42+
pip3 install git+${MESON_REPO}@${MESON_BRANCH}
43+
;;
44+
macos)
45+
python3 -m site --user-base && \
46+
PATH="`python3 -m site --user-base`/bin:$PATH"
47+
pip3 install git+${MESON_REPO}@${MESON_BRANCH}
48+
;;
49+
mingw)
50+
pacman -S --needed --noconfirm ucrt64/mingw-w64-ucrt-x86_64-python-pip
51+
pip3 install git+${MESON_REPO}@${MESON_BRANCH}
52+
;;
53+
windows)
54+
pip install git+${MESON_REPO}@${MESON_BRANCH}
55+
;;
56+
esac
57+
}
58+
59+
# Rebase current branch onto Postgres HEAD
60+
rebase_onto_postgres () {
61+
case $CURRENT_OS in
62+
freebsd|linux)
63+
su postgres <<-EOF
64+
git config user.email '[email protected]'
65+
git config user.name 'Postgres CI'
66+
git remote add default-postgres https://github.com/postgres/postgres.git
67+
git fetch default-postgres master
68+
git rebase --no-verify default-postgres/master
69+
EOF
70+
;;
71+
windows|mingw|macos)
72+
git config user.email '[email protected]'
73+
git config user.name 'Postgres CI'
74+
# There are file permission issues on Windows. Set filemode to
75+
# false for windows, then reset
76+
git config core.filemode false
77+
git reset --hard
78+
git remote add default-postgres https://github.com/postgres/postgres.git
79+
git fetch default-postgres master
80+
git rebase --no-verify default-postgres/master
81+
;;
82+
esac
83+
}
84+
85+
install_meson
86+
rebase_onto_postgres

0 commit comments

Comments
 (0)