summary refs log tree commit diff
path: root/.ci/scripts
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-05-31 14:02:00 +0100
committerGitHub <noreply@github.com>2022-05-31 13:02:00 +0000
commitbf01e51554ad87528d3e8612d0f02c52f8c0e562 (patch)
treecc633455acf12b53e26d86814f5d8b25373d712c /.ci/scripts
parentReduce DB load of /sync when using presence (#12885) (diff)
downloadsynapse-bf01e51554ad87528d3e8612d0f02c52f8c0e562.tar.xz
Test Synapse against Complement with workers. (#12810)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Diffstat (limited to '.ci/scripts')
-rwxr-xr-x.ci/scripts/checkout_complement.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/.ci/scripts/checkout_complement.sh b/.ci/scripts/checkout_complement.sh
new file mode 100755
index 0000000000..379f5d4387
--- /dev/null
+++ b/.ci/scripts/checkout_complement.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Fetches a version of complement which best matches the current build.
+#
+# The tarball is unpacked into `./complement`.
+
+set -e
+mkdir -p complement
+
+# Pick an appropriate version of complement. Depending on whether this is a PR or release,
+# etc. we need to use different fallbacks:
+#
+# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
+#    for pull requests, otherwise GITHUB_REF).
+# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
+#    (GITHUB_BASE_REF for pull requests).
+# 3. Use the default complement branch ("HEAD").
+for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
+  # Skip empty branch names and merge commits.
+  if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
+    continue
+  fi
+
+  (wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
+done