From a95183a81eefa031e80cf68ccd148091f1bfab70 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 24 Jan 2022 16:11:58 +0000 Subject: [PATCH 1/6] CI: run Complement on the VM, not inside Docker This requires https://github.com/matrix-org/complement/pull/289 We now run Complement on the VM instead of inside a Docker container. This is to allow Complement to bind to any high-numbered port when it starts up its own federation servers. We want to do this to allow for more concurrency when running complement tests. Previously, Complement only ever bound to `:8448` when running its own federation server. This prevented multiple federation tests running at the same time as they would fight each other on the port. This did however allow Complement to run in Docker, as the host could just port forward `:8448` to allow homeserver containers to communicate to Complement. Now that we are using random ports however, we cannot use Docker to run Complement. This ends up being a good thing because: - Running Complement tests locally is closer to how they run in CI. - Allows the `CI` env var to be removed in Complement. - Slightly speeds up runs as we don't need to pull down the Complement image prior to running tests. This assumes GHA caches actions sensibly. --- .github/workflows/tests.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e47671102ec9..dce15fa0b674 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -323,17 +323,22 @@ jobs: if: ${{ !failure() && !cancelled() }} needs: linting-done runs-on: ubuntu-latest - container: - # https://github.com/matrix-org/complement/blob/master/dockerfiles/ComplementCIBuildkite.Dockerfile - image: matrixdotorg/complement:latest - env: - CI: true - ports: - - 8448:8448 - volumes: - - /var/run/docker.sock:/var/run/docker.sock steps: + # Env vars are set file a file given by $GITHUB_PATH. We need both Go 1.17 and GOPATH on env 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: | + echo "$GOROOT_1_17_X64/bin" >> $GITHUB_PATH + echo "~/go/bin" >> $GITHUB_PATH + + - name: "Install Complement Dependencies" + # We don't need to install Go because it is included on the Ubuntu 20.04 image: + # See https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md specifically GOROOT_1_17_X64 + 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: @@ -376,8 +381,11 @@ jobs: working-directory: complement/dockerfiles # Run Complement - - run: set -o pipefail && go test -v -json -tags synapse_blacklist,msc2403 ./tests/... 2>&1 | gotestfmt + - run: | + set -o pipefail && + go test -v -json -tags synapse_blacklist,msc2403 ./tests/... 2>&1 | gotestfmt shell: bash + name: Run Complement Tests env: COMPLEMENT_BASE_IMAGE: complement-synapse:latest working-directory: complement From 030c580cd58d74ba88dad6a5590636ce61c18348 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 24 Jan 2022 16:19:44 +0000 Subject: [PATCH 2/6] Changelog --- changelog.d/11811.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/11811.misc diff --git a/changelog.d/11811.misc b/changelog.d/11811.misc new file mode 100644 index 000000000000..b92bdc982fa2 --- /dev/null +++ b/changelog.d/11811.misc @@ -0,0 +1 @@ +Run Complement on the Github Actions VM and not inside a Docker container \ No newline at end of file From 2072e191d7f3d334f6952da71122308ff29df0f4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 24 Jan 2022 16:21:55 +0000 Subject: [PATCH 3/6] Full stop --- changelog.d/11811.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/11811.misc b/changelog.d/11811.misc index b92bdc982fa2..b911a2d042d2 100644 --- a/changelog.d/11811.misc +++ b/changelog.d/11811.misc @@ -1 +1 @@ -Run Complement on the Github Actions VM and not inside a Docker container \ No newline at end of file +Run Complement on the Github Actions VM and not inside a Docker container. \ No newline at end of file From b1b5cf8191f8a18cca90cf4304e6014043ef8273 Mon Sep 17 00:00:00 2001 From: kegsay Date: Tue, 25 Jan 2022 10:16:26 +0000 Subject: [PATCH 4/6] Update .github/workflows/tests.yml Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dce15fa0b674..b0095cd8446a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -329,6 +329,7 @@ jobs: # 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 echo "~/go/bin" >> $GITHUB_PATH From 9b23cc51e85eca1b10509c48a7f3b45285b5bf9a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 25 Jan 2022 10:20:48 +0000 Subject: [PATCH 5/6] Review comments --- .github/workflows/tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b0095cd8446a..ac2d8d6075cd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -325,17 +325,16 @@ jobs: runs-on: ubuntu-latest steps: - # Env vars are set file a file given by $GITHUB_PATH. We need both Go 1.17 and GOPATH on env to run Complement. + # 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" - # We don't need to install Go because it is included on the Ubuntu 20.04 image: - # See https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md specifically GOROOT_1_17_X64 run: | sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev go get -v github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest From f5834f6b3e0d4991e1e48fa3508195b7fd4ffa1c Mon Sep 17 00:00:00 2001 From: kegsay Date: Tue, 25 Jan 2022 14:07:55 +0000 Subject: [PATCH 6/6] Update .github/workflows/tests.yml Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- .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 ac2d8d6075cd..e0f80aaaa783 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -382,7 +382,7 @@ jobs: # Run Complement - run: | - set -o pipefail && + set -o pipefail go test -v -json -tags synapse_blacklist,msc2403 ./tests/... 2>&1 | gotestfmt shell: bash name: Run Complement Tests