diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 30b7c002..6290b0f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,9 +25,11 @@ jobs: include: - homeserver: Synapse tags: synapse_blacklist,msc2403,msc2946,msc3083 + default_branch: develop - homeserver: Dendrite tags: msc2836 dendrite_blacklist + default_branch: master container: image: matrixdotorg/complement # dockerfiles/ComplementCIBuildkite.Dockerfile @@ -41,6 +43,38 @@ jobs: steps: - uses: actions/checkout@v2 + + - name: "Checkout corresponding ${{ matrix.homeserver }} branch" + # This is only done for Synapse since Dendrite's docker file pulls in + # the Dendrite sources directly. + if: ${{ matrix.homeserver == 'Synapse' }} + shell: bash + run: | + mkdir -p homeserver + # Attempt to use the version of the homeserver 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. Use the default homeserver branch. + for BRANCH_NAME in "$GITHUB_HEAD_REF" "${GITHUB_REF#refs/heads/}" "${{ matrix.default_branch }}"; 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/${{ matrix.homeserver }}/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C homeserver) && break + done + + # Build initial homeserver image + - run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile . + # We only do this for Synapse since Dendrite's docker file pulls in + # the Dendrite sources directly (instead of being based on a previously + # built docker image). + if: ${{ matrix.homeserver == 'Synapse' }} + working-directory: homeserver + - run: docker build -t homeserver -f dockerfiles/${{ matrix.homeserver }}.Dockerfile dockerfiles/ - run: go test -p 2 -v -tags "${{ matrix.tags }}" ./tests/... env: