Skip to content

Commit

Permalink
ci: Add feature to use different meson versions
Browse files Browse the repository at this point in the history
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 #81.
  • Loading branch information
nbyavuz committed Jun 23, 2023
1 parent 8a2b1b1 commit 9bf0618
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ env:
TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
PG_TEST_EXTRA: kerberos ldap ssl load_balance

# default variables to use in local meson installations
MESON_REPO: https://github.com/mesonbuild/meson.git
MESON_BRANCH: master


# What files to preserve in case tests fail
on_failure_ac: &on_failure_ac
Expand Down Expand Up @@ -95,6 +99,9 @@ task:
chown root:postgres /
chmod g+rwx /
install_meson_and_rebase_script: |
bash src/tools/ci/install_meson_and_rebase.sh linux
configure_script: |
su postgres <<-EOF
meson setup \
Expand Down Expand Up @@ -174,6 +181,9 @@ task:
setup_additional_packages_script: |
#pkg install -y ...
install_meson_and_rebase_script: |
bash src/tools/ci/install_meson_and_rebase.sh freebsd
# NB: Intentionally build without -Dllvm. The freebsd image size is already
# large enough to make VM startup slow, and even without llvm freebsd
# already takes longer than other platforms except for windows.
Expand Down Expand Up @@ -360,6 +370,9 @@ task:
CCACHE_MAXSIZE: "400M" # tests two different builds
SANITIZER_FLAGS: -fsanitize=alignment,undefined

install_meson_and_rebase_script: |
bash src/tools/ci/install_meson_and_rebase.sh linux
configure_script: |
su postgres <<-EOF
meson setup \
Expand Down Expand Up @@ -485,6 +498,9 @@ task:
brew cleanup -s # to reduce cache size
upload_caches: homebrew

install_meson_and_rebase_script: |
bash src/tools/ci/install_meson_and_rebase.sh macos
ccache_cache:
folder: $CCACHE_DIR
configure_script: |
Expand Down Expand Up @@ -578,6 +594,9 @@ task:
echo 127.0.0.3 pg-loadbalancetest >> c:\Windows\System32\Drivers\etc\hosts
type c:\Windows\System32\Drivers\etc\hosts
install_meson_and_rebase_script: |
bash src/tools/ci/install_meson_and_rebase.sh windows
# Use /DEBUG:FASTLINK to avoid high memory usage during linking
configure_script: |
vcvarsall x64
Expand Down Expand Up @@ -643,6 +662,9 @@ task:
%BASH% -c "where perl"
%BASH% -c "perl --version"
install_meson_and_rebase_script: |
%BASH% src/tools/ci/install_meson_and_rebase.sh mingw
# disable -Dnls as the number of files it creates cause a noticable slowdown
configure_script: |
%BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
Expand Down
70 changes: 70 additions & 0 deletions src/tools/ci/install_meson_and_rebase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#! /bin/sh

set -e
set -x

CURRENT_OS=$1

if [ $# -ne 1 ]; then
echo "install_meson_and_rebase.sh <OS>"
exit 1
fi

case $CURRENT_OS in
freebsd | linux | macos | windows | mingw)
;;
*)
echo "unsupported operating system ${CURRENT_OS}"
exit 1
;;
esac

# After repartition, hidden files are not copied. Copy them to
# working dir
if [ "$CURRENT_OS" = 'freebsd' ]; then
cp -r $CIRRUS_WORKING_DIR.orig/.[^.]* $CIRRUS_WORKING_DIR/
chown -R postgres:postgres .[^.]*
fi


# install meson by using pip
install_meson () {
case $CURRENT_OS in
linux | windows)
PIP=pip
;;
*)
PIP=pip3
;;
esac
${PIP} install git+${MESON_REPO}@${MESON_BRANCH}
}

run_rebase_commands() {
git config user.email 'postgres-ci@example.com'
git config user.name 'Postgres CI'
# windows looses the executable bit, causing an unnecessary diff
git config core.filemode false
git reset --hard
git remote add default-postgres https://github.com/postgres/postgres.git
git fetch default-postgres master
git rebase --no-verify default-postgres/master
}

# Rebase current branch onto Postgres HEAD
rebase_onto_postgres () {
# freebsd and linux run commands as postgres user
case $CURRENT_OS in
freebsd | linux)
su postgres <<-EOF
$(run_rebase_commands)
EOF
;;
*)
run_rebase_commands
;;
esac
}

install_meson
rebase_onto_postgres

0 comments on commit 9bf0618

Please sign in to comment.