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 Jul 21, 2023
1 parent 8a2b1b1 commit 0d9be2f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
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
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
# 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
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
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
# 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
# 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
2 changes: 1 addition & 1 deletion src/tools/ci/gcp_freebsd_repartition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ du -hs $CIRRUS_WORKING_DIR
mv $CIRRUS_WORKING_DIR $CIRRUS_WORKING_DIR.orig
mkdir $CIRRUS_WORKING_DIR
mount -o noatime /dev/da0p3 $CIRRUS_WORKING_DIR
cp -r $CIRRUS_WORKING_DIR.orig/* $CIRRUS_WORKING_DIR/
cp -r $CIRRUS_WORKING_DIR.orig/ $CIRRUS_WORKING_DIR/
51 changes: 51 additions & 0 deletions src/tools/ci/install_meson_and_rebase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /bin/sh

set -e
set -x

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

# install meson by using pip
install_meson () {
python3 -m 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 loses the executable bit, causing an unnecessary diff
git config core.filemode false
# windows changes file endings to crlf, causing test failures
git config core.autocrlf false
git remote add default-postgres https://github.com/postgres/postgres.git
git fetch default-postgres master
echo "Rebasing onto: $(git show --no-patch --abbrev-commit --pretty=oneline default-postgres/master)"
git rebase --autostash --no-verify default-postgres/master
}

# Rebase current branch onto Postgres HEAD
rebase_onto_postgres () {
# safe directory need to be set because of dubious ownership error
# debian complains $HOME not set when --global is used
# macOS complains about permissions when --system is used
# so, use --global for macOS and --system for others
case $CIRRUS_OS in
darwin)
git config --global --add safe.directory /tmp/cirrus-ci-build
;;
*)
git config --system --add safe.directory /tmp/cirrus-ci-build
;;
esac
run_rebase_commands
}

install_meson
rebase_onto_postgres

0 comments on commit 0d9be2f

Please sign in to comment.