Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add feature to use different meson versions #82

Open
wants to merge 1 commit into
base: meson-upstream-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably worth just doing this for all tasks, rather than just this one in the matrix.

I'd really like if we could put the invocation into a single place instead of needing to repeat it in many places. But it's not exactly obvious how. Looks like I should have made all tasks in postgres' .cirrus inline the same yaml block, to make it easier to do stuff like this.

I was wondering if we could use https://cirrus-ci.org/guide/programming-tasks/ to make this easier, but I couldn't find a way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, copying same thing on multiple places doesn't seem good but I couldn't find a way too.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, not as part of this PR, whether we should something like

task_prep: &task_prep
  # add scripts to be executed at the start of all tasks here

task_finish: &task_finish
  # add scripts to be executed at the end of all tasks here

I would like to filter the set of artifacts uploaded in case of failures, which would be a lot easier if we had something like this...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was thinking if we could ask for a feature request for something like this to cirrus?

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