From be69bd292a6f623b09030a4c7f87cb5bd4e2ce8e Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 20 May 2022 12:15:04 +0100 Subject: [PATCH 01/11] Run Complement with workers in CI --- .github/workflows/tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index efa35b71df18..ce4c30d698c1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -310,6 +310,16 @@ jobs: needs: linting-done runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + # GHA requires all matrix configurations to have at least one value. We don't want to set one here though. + - _: monolith + + # Test with workers + - workers: workers + steps: # 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. # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path @@ -356,7 +366,7 @@ jobs: - run: | set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt shell: bash name: Run Complement Tests From 322d22f04e942f260b01ffa3187c1c640b95d347 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 20 May 2022 12:16:04 +0100 Subject: [PATCH 02/11] Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/12810.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12810.misc diff --git a/changelog.d/12810.misc b/changelog.d/12810.misc new file mode 100644 index 000000000000..fe5fb81d5e46 --- /dev/null +++ b/changelog.d/12810.misc @@ -0,0 +1 @@ +Test Synapse against Complement with workers. \ No newline at end of file From a974ccbdb084a02f5b72d87d6b194e8c2ee8b47a Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Mon, 23 May 2022 14:06:13 +0100 Subject: [PATCH 03/11] Split workers' tests by regex into 4 different jobs for now --- .github/workflows/tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ce4c30d698c1..24e02021d587 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -319,6 +319,16 @@ jobs: # Test with workers - workers: workers + regex: 'A-Ea-e' + + - workers: workers + regex: 'F-Lf-l' + + - workers: workers + regex: 'M-Qm-q' + + - workers: workers + regex: 'R-Zr-z' steps: # 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. @@ -366,7 +376,7 @@ jobs: - run: | set -o pipefail - WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json ${{ matrix.regex && format('-run Test[{0}]', matrix.regex) || '' }} 2>&1 | gotestfmt shell: bash name: Run Complement Tests From 9b3cdebd9af32254e9879bc0e0e8204e7303b3b5 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 11:43:51 +0100 Subject: [PATCH 04/11] Restrict Complement workers tests to develop branch --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24e02021d587..a334eeaf8bae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -306,7 +306,8 @@ jobs: - run: .ci/scripts/test_synapse_port_db.sh complement: - if: ${{ !failure() && !cancelled() }} + # We only run the workers tests on `develop` for now, because they're too slow to wait for on PRs. + if: "${{ !failure() && !cancelled() && (!matrix.workers || (github.ref == 'refs/heads/develop')) }}" needs: linting-done runs-on: ubuntu-latest From 7f9870efac0253fb913adcfd4fb6e8de5bc68fb8 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 11:44:18 +0100 Subject: [PATCH 05/11] Cut out the regex rubbish --- .github/workflows/tests.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a334eeaf8bae..9d6489453a28 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -320,16 +320,6 @@ jobs: # Test with workers - workers: workers - regex: 'A-Ea-e' - - - workers: workers - regex: 'F-Lf-l' - - - workers: workers - regex: 'M-Qm-q' - - - workers: workers - regex: 'R-Zr-z' steps: # 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. @@ -377,7 +367,7 @@ jobs: - run: | set -o pipefail - WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json ${{ matrix.regex && format('-run Test[{0}]', matrix.regex) || '' }} 2>&1 | gotestfmt + WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt shell: bash name: Run Complement Tests From d539339fa7153fef3e679c517cf56eb30246ec6e Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 11:56:49 +0100 Subject: [PATCH 06/11] Work around the lack of YAML anchors or other easy reuse primitives, the ugly way --- .github/workflows/tests.yml | 65 +++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d6489453a28..96807635d986 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -306,8 +306,7 @@ jobs: - run: .ci/scripts/test_synapse_port_db.sh complement: - # We only run the workers tests on `develop` for now, because they're too slow to wait for on PRs. - if: "${{ !failure() && !cancelled() && (!matrix.workers || (github.ref == 'refs/heads/develop')) }}" + if: "${{ !failure() && !cancelled() }}" needs: linting-done runs-on: ubuntu-latest @@ -318,6 +317,68 @@ jobs: # GHA requires all matrix configurations to have at least one value. We don't want to set one here though. - _: monolith + steps: + # 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. + # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path + - name: "Set Go Version" + run: | + # Add Go 1.17 to the PATH: see https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-2 + echo "$GOROOT_1_17_X64/bin" >> $GITHUB_PATH + # Add the Go path to the PATH: We need this so we can call gotestfmt + echo "~/go/bin" >> $GITHUB_PATH + + - name: "Install Complement Dependencies" + run: | + sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev + go get -v github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest + + - name: Run actions/checkout@v2 for synapse + uses: actions/checkout@v2 + with: + path: synapse + + # Attempt to check out the same branch of Complement as the PR. If it + # doesn't exist, fallback to HEAD. + - name: Checkout complement + shell: bash + run: | + mkdir -p complement + # Attempt to use the version of complement 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 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 + + - run: | + set -o pipefail + WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + shell: bash + name: Run Complement Tests + + # We only run the workers tests on `develop` for now, because they're too slow to wait for on PRs. + # Sadly, you can't have an `if` condition on the value of a matrix, so this is a temporary, separate job for now. + # GitHub Actions doesn't support YAML anchors, so it's full-on duplication for now. + complement-developonly: + if: "${{ !failure() && !cancelled() && (github.ref == 'refs/heads/develop') }}" + needs: linting-done + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: # Test with workers - workers: workers From 50a92643d68981d18c4426cfa1571029ac46d0cb Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 12:33:19 +0100 Subject: [PATCH 07/11] Move checkout to a script --- .ci/scripts/checkout_complement.sh | 20 ++++++++++++++ .github/workflows/tests.yml | 42 ++---------------------------- 2 files changed, 22 insertions(+), 40 deletions(-) create mode 100755 .ci/scripts/checkout_complement.sh diff --git a/.ci/scripts/checkout_complement.sh b/.ci/scripts/checkout_complement.sh new file mode 100755 index 000000000000..b44da679c9a8 --- /dev/null +++ b/.ci/scripts/checkout_complement.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +mkdir -p complement +# Attempt to use the version of complement 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 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 96807635d986..a2255c02ea23 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -340,26 +340,7 @@ jobs: # Attempt to check out the same branch of Complement as the PR. If it # doesn't exist, fallback to HEAD. - name: Checkout complement - shell: bash - run: | - mkdir -p complement - # Attempt to use the version of complement 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 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 + run: .ci/scripts/checkout_complement.sh - run: | set -o pipefail @@ -405,26 +386,7 @@ jobs: # Attempt to check out the same branch of Complement as the PR. If it # doesn't exist, fallback to HEAD. - name: Checkout complement - shell: bash - run: | - mkdir -p complement - # Attempt to use the version of complement 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 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 + run: .ci/scripts/checkout_complement.sh - run: | set -o pipefail From 06b1221a228446aaec1ada32e4eb7a73f1667191 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 12:34:01 +0100 Subject: [PATCH 08/11] Flatten develop-only --- .github/workflows/tests.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a2255c02ea23..eb0eef38afa6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -356,13 +356,6 @@ jobs: needs: linting-done runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - # Test with workers - - workers: workers - steps: # 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. # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path @@ -390,7 +383,7 @@ jobs: - run: | set -o pipefail - WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + WORKERS=1 COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt shell: bash name: Run Complement Tests From 5f1efa4483384033c90fb0cba7a6dad6e440c2eb Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 12:34:06 +0100 Subject: [PATCH 09/11] Flatten normal (reversible later) --- .github/workflows/tests.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb0eef38afa6..a99c221d4ace 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -310,13 +310,6 @@ jobs: needs: linting-done runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - # GHA requires all matrix configurations to have at least one value. We don't want to set one here though. - - _: monolith - steps: # 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. # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path @@ -344,7 +337,7 @@ jobs: - run: | set -o pipefail - WORKERS=${{ matrix.workers && 1 }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt shell: bash name: Run Complement Tests From b99841668fb87ca6fd4cb8c0bf4748384b42b4de Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 31 May 2022 12:50:45 +0100 Subject: [PATCH 10/11] Fix path to script --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a99c221d4ace..3693cf06c3d1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -333,7 +333,7 @@ jobs: # Attempt to check out the same branch of Complement as the PR. If it # doesn't exist, fallback to HEAD. - name: Checkout complement - run: .ci/scripts/checkout_complement.sh + run: synapse/.ci/scripts/checkout_complement.sh - run: | set -o pipefail From 58819e1daf7478a7809afae6752ed69e8aa920f5 Mon Sep 17 00:00:00 2001 From: reivilibre Date: Tue, 31 May 2022 13:24:50 +0100 Subject: [PATCH 11/11] Update .ci/scripts/checkout_complement.sh Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- .ci/scripts/checkout_complement.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/checkout_complement.sh b/.ci/scripts/checkout_complement.sh index b44da679c9a8..379f5d4387a7 100755 --- a/.ci/scripts/checkout_complement.sh +++ b/.ci/scripts/checkout_complement.sh @@ -1,9 +1,14 @@ #!/bin/bash +# +# Fetches a version of complement which best matches the current build. +# +# The tarball is unpacked into `./complement`. +set -e mkdir -p complement -# Attempt to use the version of complement which best matches the current -# build. Depending on whether this is a PR or release, etc. we need to -# use different fallbacks. + +# 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).