Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit bf01e51

Browse files
reivilibrerichvdh
andauthored
Test Synapse against Complement with workers. (#12810)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
1 parent c8684e6 commit bf01e51

File tree

3 files changed

+66
-20
lines changed

3 files changed

+66
-20
lines changed

.ci/scripts/checkout_complement.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Fetches a version of complement which best matches the current build.
4+
#
5+
# The tarball is unpacked into `./complement`.
6+
7+
set -e
8+
mkdir -p complement
9+
10+
# Pick an appropriate version of complement. Depending on whether this is a PR or release,
11+
# etc. we need to use different fallbacks:
12+
#
13+
# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
14+
# for pull requests, otherwise GITHUB_REF).
15+
# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
16+
# (GITHUB_BASE_REF for pull requests).
17+
# 3. Use the default complement branch ("HEAD").
18+
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
19+
# Skip empty branch names and merge commits.
20+
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
21+
continue
22+
fi
23+
24+
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
25+
done

.github/workflows/tests.yml

+40-20
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ jobs:
306306
- run: .ci/scripts/test_synapse_port_db.sh
307307

308308
complement:
309-
if: ${{ !failure() && !cancelled() }}
309+
if: "${{ !failure() && !cancelled() }}"
310310
needs: linting-done
311311
runs-on: ubuntu-latest
312312

@@ -333,30 +333,50 @@ jobs:
333333
# Attempt to check out the same branch of Complement as the PR. If it
334334
# doesn't exist, fallback to HEAD.
335335
- name: Checkout complement
336+
run: synapse/.ci/scripts/checkout_complement.sh
337+
338+
- run: |
339+
set -o pipefail
340+
COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt
336341
shell: bash
342+
name: Run Complement Tests
343+
344+
# We only run the workers tests on `develop` for now, because they're too slow to wait for on PRs.
345+
# Sadly, you can't have an `if` condition on the value of a matrix, so this is a temporary, separate job for now.
346+
# GitHub Actions doesn't support YAML anchors, so it's full-on duplication for now.
347+
complement-developonly:
348+
if: "${{ !failure() && !cancelled() && (github.ref == 'refs/heads/develop') }}"
349+
needs: linting-done
350+
runs-on: ubuntu-latest
351+
352+
steps:
353+
# The path is set via a file given by $GITHUB_PATH. We need both Go 1.17 and GOPATH on the path to run Complement.
354+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
355+
- name: "Set Go Version"
337356
run: |
338-
mkdir -p complement
339-
# Attempt to use the version of complement which best matches the current
340-
# build. Depending on whether this is a PR or release, etc. we need to
341-
# use different fallbacks.
342-
#
343-
# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
344-
# for pull requests, otherwise GITHUB_REF).
345-
# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
346-
# (GITHUB_BASE_REF for pull requests).
347-
# 3. Use the default complement branch ("HEAD").
348-
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
349-
# Skip empty branch names and merge commits.
350-
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
351-
continue
352-
fi
353-
354-
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
355-
done
357+
# Add Go 1.17 to the PATH: see https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-2
358+
echo "$GOROOT_1_17_X64/bin" >> $GITHUB_PATH
359+
# Add the Go path to the PATH: We need this so we can call gotestfmt
360+
echo "~/go/bin" >> $GITHUB_PATH
361+
362+
- name: "Install Complement Dependencies"
363+
run: |
364+
sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev
365+
go get -v github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
366+
367+
- name: Run actions/checkout@v2 for synapse
368+
uses: actions/checkout@v2
369+
with:
370+
path: synapse
371+
372+
# Attempt to check out the same branch of Complement as the PR. If it
373+
# doesn't exist, fallback to HEAD.
374+
- name: Checkout complement
375+
run: .ci/scripts/checkout_complement.sh
356376

357377
- run: |
358378
set -o pipefail
359-
COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt
379+
WORKERS=1 COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt
360380
shell: bash
361381
name: Run Complement Tests
362382

changelog.d/12810.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test Synapse against Complement with workers.

0 commit comments

Comments
 (0)