Skip to content

Commit

Permalink
Correctly fetch same-named homeserver branches (#1129)
Browse files Browse the repository at this point in the history
In #1115 I didn't correctly handle the situation where there's a corresponding synapse/dendrite branch to fetch. #1128 fell victim to this.

Fix: reuse the shell script from matrix-org/synapse#10160, i.e. consult a wider range of GHA's environment variables.

Co-authored-by: Andrew Morgan <[email protected]>
  • Loading branch information
David Robertson and anoadragon453 committed Sep 8, 2021
1 parent 650da60 commit e8d6a9c
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,30 @@ jobs:
with:
path: sytest

# TODO the shell script below is nicked from complement. We use this pattern
# in a few places. Can we make this an Action so it's easier to reuse?
- name: Fetch corresponding synapse branch
shell: bash
run: |
BRANCH=${GITHUB_REF#refs/heads/}
(wget -O - https://github.com/matrix-org/synapse/archive/$BRANCH.tar.gz || wget -O - https://github.com/matrix-org/synapse/archive/develop.tar.gz) \
| tar -xz --strip-components=1 -C /src/
# Attempt to use the version of synapse which best matches the current
# build. 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 synapse branch ("develop").
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "develop"; 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/synapse/archive/$BRANCH_NAME.tar.gz" \
| tar -xz --strip-components=1 -C /src/) \
&& echo "Successfully downloaded and extracted $BRANCH_NAME.tar.gz" \
&& break
done
- name: Prepare blacklist file for running with workers
if: ${{ matrix.workers }}
Expand Down Expand Up @@ -129,12 +147,30 @@ jobs:
with:
path: sytest

# TODO the shell script below is nicked from complement. We use this pattern
# in a few places. Can we make this an Action so it's easier to reuse?
- name: Fetch corresponding dendrite branch
shell: bash
run: |
BRANCH=${GITHUB_REF#refs/heads/}
(wget -O - https://github.com/matrix-org/dendrite/archive/$BRANCH.tar.gz || wget -O - https://github.com/matrix-org/dendrite/archive/master.tar.gz) \
| tar -xz --strip-components=1 -C /src/
# Attempt to use the version of dendrite which best matches the current
# build. 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 dendrite branch ("master").
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "master"; 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/dendrite/archive/$BRANCH_NAME.tar.gz" \
| tar -xz --strip-components=1 -C /src/) \
&& echo "Successfully downloaded and extracted $BRANCH_NAME.tar.gz" \
&& break
done
- name: Run sytest
run: |
Expand Down

0 comments on commit e8d6a9c

Please sign in to comment.