|
| 1 | +# Re-usable workflow (https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows) |
| 2 | +name: Reusable Complement testing |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + use_latest_deps: |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + use_twisted_trunk: |
| 11 | + type: boolean |
| 12 | + default: false |
| 13 | + |
| 14 | +# Control the permissions granted to `GITHUB_TOKEN`. |
| 15 | +permissions: |
| 16 | + # `actions/checkout` reads the repository (also see |
| 17 | + # https://github.com/actions/checkout/tree/de0fac2e4500dabe0009e67214ff5f5447ce83dd/#recommended-permissions) |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + RUST_VERSION: 1.87.0 |
| 22 | + |
| 23 | +jobs: |
| 24 | + complement: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + - arrangement: monolith |
| 32 | + database: SQLite |
| 33 | + |
| 34 | + - arrangement: monolith |
| 35 | + database: Postgres |
| 36 | + |
| 37 | + - arrangement: workers |
| 38 | + database: Postgres |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout synapse codebase |
| 42 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 43 | + with: |
| 44 | + path: synapse |
| 45 | + |
| 46 | + # Log Docker system info for debugging (compare with your local environment) and |
| 47 | + # tracking GitHub runner changes over time (can easily compare a run from last |
| 48 | + # week with the current one in question). |
| 49 | + - run: docker system info |
| 50 | + shell: bash |
| 51 | + |
| 52 | + - name: Install Rust |
| 53 | + uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # master |
| 54 | + with: |
| 55 | + toolchain: ${{ env.RUST_VERSION }} |
| 56 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 57 | + |
| 58 | + # We use `poetry` in `complement.sh` |
| 59 | + - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 |
| 60 | + with: |
| 61 | + poetry-version: "2.2.1" |
| 62 | + # Matches the `path` where we checkout Synapse above |
| 63 | + working-directory: "synapse" |
| 64 | + |
| 65 | + - name: Prepare Complement's Prerequisites |
| 66 | + run: synapse/.ci/scripts/setup_complement_prerequisites.sh |
| 67 | + |
| 68 | + - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 69 | + with: |
| 70 | + cache-dependency-path: complement/go.sum |
| 71 | + go-version-file: complement/go.mod |
| 72 | + |
| 73 | + # This step is specific to the 'Twisted trunk' test run: |
| 74 | + - name: Patch dependencies |
| 75 | + if: ${{ inputs.use_twisted_trunk }} |
| 76 | + run: | |
| 77 | + set -x |
| 78 | + DEBIAN_FRONTEND=noninteractive sudo apt-get install -yqq python3 pipx |
| 79 | + pipx install poetry==2.2.1 |
| 80 | +
|
| 81 | + poetry remove -n twisted |
| 82 | + poetry add -n --extras tls git+https://github.com/twisted/twisted.git#trunk |
| 83 | + poetry lock |
| 84 | + working-directory: synapse |
| 85 | + |
| 86 | + # Run the image sanity check test first as this is the first thing we want to know |
| 87 | + # about (are we actually testing what we expect?) and we don't want to debug |
| 88 | + # downstream failures (wild goose chase). |
| 89 | + - name: Sanity check Complement image |
| 90 | + id: run_sanity_check_complement_image_test |
| 91 | + # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes |
| 92 | + # are underpowered and don't like running tons of Synapse instances at once. |
| 93 | + # -json: Output JSON format so that gotestfmt can parse it. |
| 94 | + # |
| 95 | + # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it |
| 96 | + # later on for better formatting with gotestfmt. But we still want the command |
| 97 | + # to output to the terminal as it runs so we can see what's happening in |
| 98 | + # real-time. |
| 99 | + run: | |
| 100 | + set -o pipefail |
| 101 | + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json -run 'TestSynapseVersion/Synapse_version_matches_current_git_checkout' 2>&1 | tee /tmp/gotest-sanity-check-complement.log |
| 102 | + shell: bash |
| 103 | + env: |
| 104 | + POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} |
| 105 | + WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} |
| 106 | + |
| 107 | + - name: Formatted sanity check Complement test logs |
| 108 | + # Always run this step if we attempted to run the Complement tests. |
| 109 | + if: always() && steps.run_sanity_check_complement_image_test.outcome != 'skipped' |
| 110 | + # We do not hide successful tests in `gotestfmt` here as the list of sanity |
| 111 | + # check tests is so short. Feel free to change this when we get more tests. |
| 112 | + # |
| 113 | + # Note that the `-hide` argument is interpreted by `gotestfmt`. From it, |
| 114 | + # it derives several values under `$settings` and passes them to our |
| 115 | + # custom `.ci/complement_package.gotpl` template to render the output. |
| 116 | + run: cat /tmp/gotest-sanity-check-complement.log | gotestfmt -hide "successful-downloads,empty-packages" |
| 117 | + |
| 118 | + - name: Run Complement Tests |
| 119 | + id: run_complement_tests |
| 120 | + # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes |
| 121 | + # are underpowered and don't like running tons of Synapse instances at once. |
| 122 | + # -json: Output JSON format so that gotestfmt can parse it. |
| 123 | + # |
| 124 | + # tee /tmp/gotest-complement.log: We tee the output to a file so that we can re-process it |
| 125 | + # later on for better formatting with gotestfmt. But we still want the command |
| 126 | + # to output to the terminal as it runs so we can see what's happening in |
| 127 | + # real-time. |
| 128 | + run: | |
| 129 | + set -o pipefail |
| 130 | + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -p 1 -json 2>&1 | tee /tmp/gotest-complement.log |
| 131 | + shell: bash |
| 132 | + env: |
| 133 | + POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} |
| 134 | + WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} |
| 135 | + TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps && 1 || '' }} |
| 136 | + TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk && 1 || '' }} |
| 137 | + |
| 138 | + - name: Formatted Complement test logs (only failing are shown) |
| 139 | + # Always run this step if we attempted to run the Complement tests. |
| 140 | + if: always() && steps.run_complement_tests.outcome != 'skipped' |
| 141 | + # Hide successful tests in order to reduce the verbosity of the otherwise very large output. |
| 142 | + # |
| 143 | + # Note that the `-hide` argument is interpreted by `gotestfmt`. From it, |
| 144 | + # it derives several values under `$settings` and passes them to our |
| 145 | + # custom `.ci/complement_package.gotpl` template to render the output. |
| 146 | + run: cat /tmp/gotest-complement.log | gotestfmt -hide "successful-downloads,successful-tests,empty-packages" |
| 147 | + |
| 148 | + - name: Run in-repo Complement Tests |
| 149 | + id: run_in_repo_complement_tests |
| 150 | + # -p=1: We're using `-p 1` to force the test packages to run serially as GHA boxes |
| 151 | + # are underpowered and don't like running tons of Synapse instances at once. |
| 152 | + # -json: Output JSON format so that gotestfmt can parse it. |
| 153 | + # |
| 154 | + # tee /tmp/gotest-in-repo-complement.log: We tee the output to a file so that we can re-process it |
| 155 | + # later on for better formatting with gotestfmt. But we still want the command |
| 156 | + # to output to the terminal as it runs so we can see what's happening in |
| 157 | + # real-time. |
| 158 | + run: | |
| 159 | + set -o pipefail |
| 160 | + COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh --in-repo -p 1 -json 2>&1 | tee /tmp/gotest-in-repo-complement.log |
| 161 | + shell: bash |
| 162 | + env: |
| 163 | + POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }} |
| 164 | + WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }} |
| 165 | + TEST_ONLY_IGNORE_POETRY_LOCKFILE: ${{ inputs.use_latest_deps && 1 || '' }} |
| 166 | + TEST_ONLY_SKIP_DEP_HASH_VERIFICATION: ${{ inputs.use_twisted_trunk && 1 || '' }} |
| 167 | + |
| 168 | + - name: Formatted in-repo Complement test logs (only failing are shown) |
| 169 | + # Always run this step if we attempted to run the Complement tests. |
| 170 | + if: always() && steps.run_in_repo_complement_tests.outcome != 'skipped' |
| 171 | + # Hide successful tests in order to reduce the verbosity of the otherwise very large output. |
| 172 | + # |
| 173 | + # Note that the `-hide` argument is interpreted by `gotestfmt`. From it, |
| 174 | + # it derives several values under `$settings` and passes them to our |
| 175 | + # custom `.ci/complement_package.gotpl` template to render the output. |
| 176 | + run: cat /tmp/gotest-in-repo-complement.log | gotestfmt -hide "successful-downloads,successful-tests,empty-packages" |
0 commit comments