From 34ff70254dcb5db930a58c2faeefd0ece19f028e Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 6 Mar 2026 11:35:26 -0600 Subject: [PATCH 1/8] Re-usable Complement CI workflow --- .github/workflows/complement_tests.yml | 119 +++++++++++++++++++++++++ .github/workflows/latest_deps.yml | 79 +--------------- .github/workflows/tests.yml | 87 +----------------- .github/workflows/twisted_trunk.yml | 91 +------------------ 4 files changed, 126 insertions(+), 250 deletions(-) create mode 100644 .github/workflows/complement_tests.yml diff --git a/.github/workflows/complement_tests.yml b/.github/workflows/complement_tests.yml new file mode 100644 index 00000000000..0469d32c940 --- /dev/null +++ b/.github/workflows/complement_tests.yml @@ -0,0 +1,119 @@ +# Re-usable workflow (https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows) +name: Reusable Complement testing + +on: + workflow_call: + inputs: + use_latest_deps: + type: boolean + default: false + use_twisted_trunk: + type: boolean + default: false + +env: + RUST_VERSION: 1.87.0 + +jobs: + complement: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - arrangement: monolith + database: SQLite + + - arrangement: monolith + database: Postgres + + - arrangement: workers + database: Postgres + + steps: + - name: Checkout synapse codebase + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: synapse + + # Log Docker system info for debugging (compare with your local environment) and + # tracking GitHub runner changes over time (can easily compare a run from last + # week with the current one in question). + - run: docker system info + shell: bash + + - name: Install Rust + uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # master + with: + toolchain: ${{ env.RUST_VERSION }} + - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 + + - name: Prepare Complement's Prerequisites + run: synapse/.ci/scripts/setup_complement_prerequisites.sh + + - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 + with: + cache-dependency-path: complement/go.sum + go-version-file: complement/go.mod + + # This step is specific to the 'Twisted trunk' test run: + - name: Patch dependencies + if: ${{ inputs.use_twisted_trunk }} + run: | + set -x + DEBIAN_FRONTEND=noninteractive sudo apt-get install -yqq python3 pipx + pipx install poetry==2.1.1 + + poetry remove -n twisted + poetry add -n --extras tls git+https://github.com/twisted/twisted.git#trunk + poetry lock + working-directory: synapse + + - name: Run Complement Tests + id: run_complement_tests + # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes + # are underpowered and don't like running tons of Synapse instances at once. + # -json: Output JSON format so that gotestfmt can parse it. + # + # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it + # later on for better formatting with gotestfmt. But we still want the command + # to output to the terminal as it runs so we can see what's happening in + # real-time. + run: | + set -o pipefail + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | tee /tmp/gotest-complement.log + shell: bash + env: + POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} + WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} + TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps }} + TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk }} + + - name: Formatted Complement test logs + # Always run this step if we attempted to run the Complement tests. + if: always() && steps.run_complement_tests.outcome != 'skipped' + run: cat /tmp/gotest-complement.log | gotestfmt -hide "successful-downloads,empty-packages" + + - name: Run in-repo Complement Tests + id: run_in_repo_complement_tests + # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes + # are underpowered and don't like running tons of Synapse instances at once. + # -json: Output JSON format so that gotestfmt can parse it. + # + # tee /tmp/gotest-in-repo-complement.log: We tee the output to a file so that we can re-process it + # later on for better formatting with gotestfmt. But we still want the command + # to output to the terminal as it runs so we can see what's happening in + # real-time. + run: | + set -o pipefail + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json 2>&1 | tee /tmp/gotest-in-repo-complement.log + shell: bash + env: + POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} + WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} + + - name: Formatted in-repo Complement test logs + # Always run this step if we attempted to run the Complement tests. + if: always() && steps.run_in_repo_complement_tests.outcome != 'skipped' + run: cat /tmp/gotest-in-repo-complement.log | gotestfmt -hide "successful-downloads,empty-packages" diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 5bc78062cda..1cc9863e4c3 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -181,84 +181,11 @@ jobs: /logs/**/*.log* complement: + uses: ./.github/workflows/complement_tests.yml needs: check_repo if: "!failure() && !cancelled() && needs.check_repo.outputs.should_run_workflow == 'true'" - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - include: - - arrangement: monolith - database: SQLite - - - arrangement: monolith - database: Postgres - - - arrangement: workers - database: Postgres - - steps: - - name: Check out synapse codebase - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: synapse - - - name: Prepare Complement's Prerequisites - run: synapse/.ci/scripts/setup_complement_prerequisites.sh - - - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 - with: - cache-dependency-path: complement/go.sum - go-version-file: complement/go.mod - - - name: Run Complement Tests - id: run_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | tee /tmp/gotest-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - TEST_ONLY_IGNORE_POETRY_LOCKFILE: 1 - - - name: Formatted Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-complement.log | gotestfmt -hide "successful-downloads,empty-packages" - - - name: Run in-repo Complement Tests - id: run_in_repo_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-in-repo-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json 2>&1 | tee /tmp/gotest-in-repo-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - TEST_ONLY_IGNORE_POETRY_LOCKFILE: 1 - - - name: Formatted in-repo Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_in_repo_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-in-repo-complement.log | gotestfmt -hide "successful-downloads,empty-packages" + with: + use_latest_deps: true # Open an issue if the build fails, so we know about it. # Only do this if we're not experimenting with this action in a PR. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 98b47130a1c..f75471c8a99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -668,96 +668,11 @@ jobs: schema_diff complement: + uses: ./.github/workflows/complement_tests.yml if: "${{ !failure() && !cancelled() && needs.changes.outputs.integration == 'true' }}" needs: - linting-done - changes - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - include: - - arrangement: monolith - database: SQLite - - - arrangement: monolith - database: Postgres - - - arrangement: workers - database: Postgres - - steps: - - name: Checkout synapse codebase - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: synapse - - # Log Docker system info for debugging (compare with your local environment) and - # tracking GitHub runner changes over time (can easily compare a run from last - # week with the current one in question). - - run: docker system info - shell: bash - - - name: Install Rust - uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # master - with: - toolchain: ${{ env.RUST_VERSION }} - - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - - - name: Prepare Complement's Prerequisites - run: synapse/.ci/scripts/setup_complement_prerequisites.sh - - - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 - with: - cache-dependency-path: complement/go.sum - go-version-file: complement/go.mod - - - name: Run Complement Tests - id: run_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | tee /tmp/gotest-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - - - name: Formatted Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-complement.log | gotestfmt -hide "successful-downloads,empty-packages" - - - name: Run in-repo Complement Tests - id: run_in_repo_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-in-repo-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json 2>&1 | tee /tmp/gotest-in-repo-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - - - name: Formatted in-repo Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_in_repo_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-in-repo-complement.log | gotestfmt -hide "successful-downloads,empty-packages" cargo-test: if: ${{ needs.changes.outputs.rust == 'true' }} diff --git a/.github/workflows/twisted_trunk.yml b/.github/workflows/twisted_trunk.yml index 12fdbbe7c47..c910e28f868 100644 --- a/.github/workflows/twisted_trunk.yml +++ b/.github/workflows/twisted_trunk.yml @@ -154,96 +154,11 @@ jobs: /logs/**/*.log* complement: + uses: ./.github/workflows/complement_tests.yml needs: check_repo if: "!failure() && !cancelled() && needs.check_repo.outputs.should_run_workflow == 'true'" - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - include: - - arrangement: monolith - database: SQLite - - - arrangement: monolith - database: Postgres - - - arrangement: workers - database: Postgres - - steps: - - name: Run actions/checkout@v4 for synapse - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: synapse - - - name: Prepare Complement's Prerequisites - run: synapse/.ci/scripts/setup_complement_prerequisites.sh - - - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 - with: - cache-dependency-path: complement/go.sum - go-version-file: complement/go.mod - - # This step is specific to the 'Twisted trunk' test run: - - name: Patch dependencies - run: | - set -x - DEBIAN_FRONTEND=noninteractive sudo apt-get install -yqq python3 pipx - pipx install poetry==2.1.1 - - poetry remove -n twisted - poetry add -n --extras tls git+https://github.com/twisted/twisted.git#trunk - poetry lock - working-directory: synapse - - - name: Run Complement Tests - id: run_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | tee /tmp/gotest-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: 1 - - - name: Formatted Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-complement.log | gotestfmt -hide "successful-downloads,empty-packages" - - - name: Run in-repo Complement Tests - id: run_in_repo_complement_tests - # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes - # are underpowered and don't like running tons of Synapse instances at once. - # -json: Output JSON format so that gotestfmt can parse it. - # - # tee /tmp/gotest-in-repo-complement.log: We tee the output to a file so that we can re-process it - # later on for better formatting with gotestfmt. But we still want the command - # to output to the terminal as it runs so we can see what's happening in - # real-time. - run: | - set -o pipefail - COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json 2>&1 | tee /tmp/gotest-in-repo-complement.log - shell: bash - env: - POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} - WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: 1 - - - name: Formatted in-repo Complement test logs - # Always run this step if we attempted to run the Complement tests. - if: always() && steps.run_in_repo_complement_tests.outcome != 'skipped' - run: cat /tmp/gotest-in-repo-complement.log | gotestfmt -hide "successful-downloads,empty-packages" + with: + use_twisted_trunk: true # open an issue if the build fails, so we know about it. open-issue: From b6c07213b4f7fff0b6b7c3a2cabae0f133761619 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 6 Mar 2026 11:38:20 -0600 Subject: [PATCH 2/8] Add changelog --- changelog.d/19533.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/19533.misc diff --git a/changelog.d/19533.misc b/changelog.d/19533.misc new file mode 100644 index 00000000000..3224f3a1fd3 --- /dev/null +++ b/changelog.d/19533.misc @@ -0,0 +1 @@ +Update CI to use re-usable Complement GitHub CI workflow. From 98c9e7bb0fad34b48eeeba7da0c53af8a500a8ee Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 6 Mar 2026 12:02:45 -0600 Subject: [PATCH 3/8] Set `permissions` See https://github.com/element-hq/synapse/pull/19533#pullrequestreview-3905073725 --- .github/workflows/complement_tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/complement_tests.yml b/.github/workflows/complement_tests.yml index 0469d32c940..59a0d576292 100644 --- a/.github/workflows/complement_tests.yml +++ b/.github/workflows/complement_tests.yml @@ -11,6 +11,11 @@ on: type: boolean default: false +# Control the permissions granted to `GITHUB_TOKEN`. +permissions: + # `actions/checkout` read the repository (also see + # https://github.com/actions/checkout/tree/de0fac2e4500dabe0009e67214ff5f5447ce83dd/#recommended-permissions) + contents: read env: RUST_VERSION: 1.87.0 From 5a358ebd19def86751ffae6faad3c41716d6d38e Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 6 Mar 2026 12:03:12 -0600 Subject: [PATCH 4/8] Better expression logic --- .github/workflows/complement_tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/complement_tests.yml b/.github/workflows/complement_tests.yml index 59a0d576292..f615a8d070b 100644 --- a/.github/workflows/complement_tests.yml +++ b/.github/workflows/complement_tests.yml @@ -16,6 +16,7 @@ permissions: # `actions/checkout` read the repository (also see # https://github.com/actions/checkout/tree/de0fac2e4500dabe0009e67214ff5f5447ce83dd/#recommended-permissions) contents: read + env: RUST_VERSION: 1.87.0 @@ -92,8 +93,8 @@ jobs: env: POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} - TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps }} - TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk }} + TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps && 1 || '' }} + TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk && 1 || '' }} - name: Formatted Complement test logs # Always run this step if we attempted to run the Complement tests. @@ -117,6 +118,8 @@ jobs: env: POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} + TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps && 1 || '' }} + TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk && 1 || '' }} - name: Formatted in-repo Complement test logs # Always run this step if we attempted to run the Complement tests. From fa08b9816893ffbc322f0658175f6c0c1292e43b Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 6 Mar 2026 15:10:54 -0600 Subject: [PATCH 5/8] Try `use_twisted_trunk` --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f75471c8a99..2aec1c400f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -673,6 +673,8 @@ jobs: needs: - linting-done - changes + with: + use_twisted_trunk: true cargo-test: if: ${{ needs.changes.outputs.rust == 'true' }} From f4e4152c7c9ea0f5a1009eddcc1c91fc42cc74aa Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 9 Mar 2026 01:30:56 -0500 Subject: [PATCH 6/8] Try `use_latest_deps` --- .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 2aec1c400f4..fb109fa014a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -674,7 +674,7 @@ jobs: - linting-done - changes with: - use_twisted_trunk: true + use_latest_deps: true cargo-test: if: ${{ needs.changes.outputs.rust == 'true' }} From 6fcdcd920715e90c17089ed9bdfd2df77f3f283f Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 9 Mar 2026 09:54:14 -0500 Subject: [PATCH 7/8] Remove extras --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb109fa014a..f75471c8a99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -673,8 +673,6 @@ jobs: needs: - linting-done - changes - with: - use_latest_deps: true cargo-test: if: ${{ needs.changes.outputs.rust == 'true' }} From 6d7f13deaf6d0dfa0478cc582fec4a8295a6e0ad Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 9 Mar 2026 09:56:56 -0500 Subject: [PATCH 8/8] Better grammar --- .github/workflows/complement_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/complement_tests.yml b/.github/workflows/complement_tests.yml index f615a8d070b..f98a14e7103 100644 --- a/.github/workflows/complement_tests.yml +++ b/.github/workflows/complement_tests.yml @@ -13,7 +13,7 @@ on: # Control the permissions granted to `GITHUB_TOKEN`. permissions: - # `actions/checkout` read the repository (also see + # `actions/checkout` reads the repository (also see # https://github.com/actions/checkout/tree/de0fac2e4500dabe0009e67214ff5f5447ce83dd/#recommended-permissions) contents: read