Skip to content

Commit dccd7c1

Browse files
authored
Attempt to pull the corresponding Synapse branch when running tests. (#177)
1 parent eff9d80 commit dccd7c1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ jobs:
2525
include:
2626
- homeserver: Synapse
2727
tags: synapse_blacklist,msc2403,msc2946,msc3083
28+
default_branch: develop
2829

2930
- homeserver: Dendrite
3031
tags: msc2836 dendrite_blacklist
32+
default_branch: master
3133

3234
container:
3335
image: matrixdotorg/complement # dockerfiles/ComplementCIBuildkite.Dockerfile
@@ -41,6 +43,38 @@ jobs:
4143

4244
steps:
4345
- uses: actions/checkout@v2
46+
47+
- name: "Checkout corresponding ${{ matrix.homeserver }} branch"
48+
# This is only done for Synapse since Dendrite's docker file pulls in
49+
# the Dendrite sources directly.
50+
if: ${{ matrix.homeserver == 'Synapse' }}
51+
shell: bash
52+
run: |
53+
mkdir -p homeserver
54+
# Attempt to use the version of the homeserver which best matches the
55+
# current build. Depending on whether this is a PR or release, etc. we
56+
# need to use different fallbacks.
57+
#
58+
# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
59+
# for pull requests, otherwise GITHUB_REF).
60+
# 2. Use the default homeserver branch.
61+
for BRANCH_NAME in "$GITHUB_HEAD_REF" "${GITHUB_REF#refs/heads/}" "${{ matrix.default_branch }}"; do
62+
# Skip empty branch names and merge commits.
63+
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
64+
continue
65+
fi
66+
67+
(wget -O - "https://github.com/matrix-org/${{ matrix.homeserver }}/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C homeserver) && break
68+
done
69+
70+
# Build initial homeserver image
71+
- run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile .
72+
# We only do this for Synapse since Dendrite's docker file pulls in
73+
# the Dendrite sources directly (instead of being based on a previously
74+
# built docker image).
75+
if: ${{ matrix.homeserver == 'Synapse' }}
76+
working-directory: homeserver
77+
4478
- run: docker build -t homeserver -f dockerfiles/${{ matrix.homeserver }}.Dockerfile dockerfiles/
4579
- run: go test -p 2 -v -tags "${{ matrix.tags }}" ./tests/...
4680
env:

0 commit comments

Comments
 (0)