Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 69beef2

Browse files
committed
Merge remote-tracking branch 'origin/develop' into shay/batch_events
2 parents 6630dab + c737744 commit 69beef2

File tree

238 files changed

+4313
-1876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+4313
-1876
lines changed

.ci/complement_package.gotpl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ which is under the Unlicense licence.
2727
{{- . -}}{{- "\n" -}}
2828
{{- end -}}
2929
{{- with .TestCases -}}
30-
{{- /* Failing tests are first */ -}}
30+
{{- /* Passing tests are first */ -}}
3131
{{- range . -}}
32-
{{- if and (ne .Result "PASS") (ne .Result "SKIP") -}}
33-
::group::{{ "\033" }}[0;31m❌{{ " " }}{{- .Name -}}
32+
{{- if eq .Result "PASS" -}}
33+
::group::{{ "\033" }}[0;32m✅{{ " " }}{{- .Name -}}
3434
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
3535
{{- with .Coverage -}}
3636
, coverage: {{ . }}%
@@ -47,7 +47,6 @@ which is under the Unlicense licence.
4747
{{- end -}}
4848
{{- end -}}
4949

50-
5150
{{- /* Then skipped tests are second */ -}}
5251
{{- range . -}}
5352
{{- if eq .Result "SKIP" -}}
@@ -68,11 +67,10 @@ which is under the Unlicense licence.
6867
{{- end -}}
6968
{{- end -}}
7069

71-
72-
{{- /* Then passing tests are last */ -}}
70+
{{- /* and failing tests are last */ -}}
7371
{{- range . -}}
74-
{{- if eq .Result "PASS" -}}
75-
::group::{{ "\033" }}[0;32m✅{{ " " }}{{- .Name -}}
72+
{{- if and (ne .Result "PASS") (ne .Result "SKIP") -}}
73+
::group::{{ "\033" }}[0;31m❌{{ " " }}{{- .Name -}}
7674
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
7775
{{- with .Coverage -}}
7876
, coverage: {{ . }}%

.ci/scripts/calculate_jobs.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env python
2+
# Copyright 2022 The Matrix.org Foundation C.I.C.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Calculate the trial jobs to run based on if we're in a PR or not.
17+
18+
import json
19+
import os
20+
21+
IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/")
22+
23+
# First calculate the various trial jobs.
24+
#
25+
# For each type of test we only run on Py3.7 on PRs
26+
27+
trial_sqlite_tests = [
28+
{
29+
"python-version": "3.7",
30+
"database": "sqlite",
31+
"extras": "all",
32+
}
33+
]
34+
35+
if not IS_PR:
36+
trial_sqlite_tests.extend(
37+
{
38+
"python-version": version,
39+
"database": "sqlite",
40+
"extras": "all",
41+
}
42+
for version in ("3.8", "3.9", "3.10")
43+
)
44+
45+
46+
trial_postgres_tests = [
47+
{
48+
"python-version": "3.7",
49+
"database": "postgres",
50+
"postgres-version": "10",
51+
"extras": "all",
52+
}
53+
]
54+
55+
if not IS_PR:
56+
trial_postgres_tests.append(
57+
{
58+
"python-version": "3.10",
59+
"database": "postgres",
60+
"postgres-version": "14",
61+
"extras": "all",
62+
}
63+
)
64+
65+
trial_no_extra_tests = [
66+
{
67+
"python-version": "3.7",
68+
"database": "sqlite",
69+
"extras": "",
70+
}
71+
]
72+
73+
print("::group::Calculated trial jobs")
74+
print(
75+
json.dumps(
76+
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests, indent=4
77+
)
78+
)
79+
print("::endgroup::")
80+
81+
test_matrix = json.dumps(
82+
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests
83+
)
84+
print(f"::set-output name=trial_test_matrix::{test_matrix}")
85+
86+
87+
# First calculate the various sytest jobs.
88+
#
89+
# For each type of test we only run on focal on PRs
90+
91+
92+
sytest_tests = [
93+
{
94+
"sytest-tag": "focal",
95+
},
96+
{
97+
"sytest-tag": "focal",
98+
"postgres": "postgres",
99+
},
100+
{
101+
"sytest-tag": "focal",
102+
"postgres": "multi-postgres",
103+
"workers": "workers",
104+
},
105+
]
106+
107+
if not IS_PR:
108+
sytest_tests.extend(
109+
[
110+
{
111+
"sytest-tag": "testing",
112+
"postgres": "postgres",
113+
},
114+
{
115+
"sytest-tag": "buster",
116+
"postgres": "multi-postgres",
117+
"workers": "workers",
118+
},
119+
]
120+
)
121+
122+
123+
print("::group::Calculated sytest jobs")
124+
print(json.dumps(sytest_tests, indent=4))
125+
print("::endgroup::")
126+
127+
test_matrix = json.dumps(sytest_tests)
128+
print(f"::set-output name=sytest_test_matrix::{test_matrix}")

.ci/scripts/gotestfmt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
# wraps `gotestfmt`, hiding output from successful packages unless
4+
# all tests passed.
5+
6+
set -o pipefail
7+
set -e
8+
9+
# tee the test results to a log, whilst also piping them into gotestfmt,
10+
# telling it to hide successful results, so that we can clearly see
11+
# unsuccessful results.
12+
tee complement.log | gotestfmt -hide successful-packages
13+
14+
# gotestfmt will exit non-zero if there were any failures, so if we got to this
15+
# point, we must have had a successful result.
16+
echo "All tests successful; showing all test results"
17+
18+
# Pipe the test results back through gotestfmt, showing all results.
19+
# The log file consists of JSON lines giving the test results, interspersed
20+
# with regular stdout lines (including reports of downloaded packages).
21+
grep '^{"Time":' complement.log | gotestfmt

.ci/scripts/test_old_deps.sh renamed to .ci/scripts/prepare_old_deps.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@
55
# - creates a venv with these old versions using poetry; and finally
66
# - invokes `trial` to run the tests with old deps.
77

8-
# Prevent tzdata from asking for user input
9-
export DEBIAN_FRONTEND=noninteractive
10-
118
set -ex
129

13-
apt-get update
14-
apt-get install -y \
15-
python3 python3-dev python3-pip python3-venv pipx \
16-
libxml2-dev libxslt-dev xmlsec1 zlib1g-dev libjpeg-dev libwebp-dev
17-
18-
export LANG="C.UTF-8"
19-
2010
# Prevent virtualenv from auto-updating pip to an incompatible version
2111
export VIRTUALENV_NO_DOWNLOAD=1
2212

@@ -33,12 +23,6 @@ export VIRTUALENV_NO_DOWNLOAD=1
3323
# a `cryptography` compiled against OpenSSL 1.1.
3424
# - Omit systemd: we're not logging to journal here.
3525

36-
# TODO: also replace caret bounds, see https://python-poetry.org/docs/dependency-specification/#version-constraints
37-
# We don't use these yet, but IIRC they are the default bound used when you `poetry add`.
38-
# The sed expression 's/\^/==/g' ought to do the trick. But it would also change
39-
# `python = "^3.7"` to `python = "==3.7", which would mean we fail because olddeps
40-
# runs on 3.8 (#12343).
41-
4226
sed -i \
4327
-e "s/[~>]=/==/g" \
4428
-e '/^python = "^/!s/\^/==/g' \
@@ -55,7 +39,7 @@ sed -i \
5539
# toml file. This means we don't have to ensure compatibility between old deps and
5640
# dev tools.
5741

58-
pip install --user toml
42+
pip install toml wheel
5943

6044
REMOVE_DEV_DEPENDENCIES="
6145
import toml
@@ -69,15 +53,12 @@ with open('pyproject.toml', 'w') as f:
6953
"
7054
python3 -c "$REMOVE_DEV_DEPENDENCIES"
7155

72-
pipx install poetry==1.1.14
73-
~/.local/bin/poetry lock
56+
pip install poetry==1.2.0
57+
poetry lock
7458

7559
echo "::group::Patched pyproject.toml"
7660
cat pyproject.toml
7761
echo "::endgroup::"
7862
echo "::group::Lockfile after patch"
7963
cat poetry.lock
8064
echo "::endgroup::"
81-
82-
~/.local/bin/poetry install -E "all test"
83-
~/.local/bin/poetry run trial --jobs=2 tests

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
# things to include
55
!docker
66
!synapse
7+
!rust
78
!README.rst
89
!pyproject.toml
910
!poetry.lock
11+
!build_rust.py
12+
13+
rust/target
1014

1115
**/__pycache__

.github/workflows/latest_deps.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# As an overview this workflow:
77
# - checks out develop,
8-
# - installs from source, pulling in the dependencies like a fresh `pip install` would, and
8+
# - installs from source, pulling in the dependencies like a fresh `pip install` would, and
99
# - runs mypy and test suites in that checkout.
1010
#
1111
# Based on the twisted trunk CI job.
@@ -26,12 +26,19 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@v2
29+
- name: Install Rust
30+
uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: stable
33+
override: true
34+
- uses: Swatinem/rust-cache@v2
35+
2936
# The dev dependencies aren't exposed in the wheel metadata (at least with current
3037
# poetry-core versions), so we install with poetry.
3138
- uses: matrix-org/setup-python-poetry@v1
3239
with:
3340
python-version: "3.x"
34-
poetry-version: "1.2.0b1"
41+
poetry-version: "1.2.0"
3542
extras: "all"
3643
# Dump installed versions for debugging.
3744
- run: poetry run pip list > before.txt
@@ -53,6 +60,14 @@ jobs:
5360

5461
steps:
5562
- uses: actions/checkout@v2
63+
64+
- name: Install Rust
65+
uses: actions-rs/toolchain@v1
66+
with:
67+
toolchain: stable
68+
override: true
69+
- uses: Swatinem/rust-cache@v2
70+
5671
- run: sudo apt-get -qq install xmlsec1
5772
- name: Set up PostgreSQL ${{ matrix.postgres-version }}
5873
if: ${{ matrix.postgres-version }}
@@ -69,6 +84,12 @@ jobs:
6984
if: ${{ matrix.postgres-version }}
7085
timeout-minutes: 2
7186
run: until pg_isready -h localhost; do sleep 1; done
87+
88+
# We nuke the local copy, as we've installed synapse into the virtualenv
89+
# (rather than use an editable install, which we no longer support). If we
90+
# don't do this then python can't find the native lib.
91+
- run: rm -rf synapse/
92+
7293
- run: python -m twisted.trial --jobs=2 tests
7394
env:
7495
SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }}
@@ -113,6 +134,14 @@ jobs:
113134

114135
steps:
115136
- uses: actions/checkout@v2
137+
138+
- name: Install Rust
139+
uses: actions-rs/toolchain@v1
140+
with:
141+
toolchain: stable
142+
override: true
143+
- uses: Swatinem/rust-cache@v2
144+
116145
- name: Ensure sytest runs `pip install`
117146
# Delete the lockfile so sytest will `pip install` rather than `poetry install`
118147
run: rm /src/poetry.lock
@@ -163,7 +192,7 @@ jobs:
163192

164193
- run: |
165194
set -o pipefail
166-
TEST_ONLY_IGNORE_POETRY_LOCKFILE=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt
195+
TEST_ONLY_IGNORE_POETRY_LOCKFILE=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
167196
shell: bash
168197
name: Run Complement Tests
169198
@@ -187,4 +216,3 @@ jobs:
187216
with:
188217
update_existing: true
189218
filename: .ci/latest_deps_build_failed_issue_template.md
190-

0 commit comments

Comments
 (0)