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

Commit ed5ab47

Browse files
author
David Robertson
committed
Merge branch 'develop' into remove-unused-lru-cache-decorator
# Conflicts: # synapse/util/caches/descriptors.py
2 parents 994fe31 + 04d7f56 commit ed5ab47

File tree

538 files changed

+22146
-6971
lines changed

Some content is hidden

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

538 files changed

+22146
-6971
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: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
22+
def set_output(key: str, value: str):
23+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
24+
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
25+
print(f"{key}={value}", file=f)
26+
27+
28+
IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/")
29+
30+
# First calculate the various trial jobs.
31+
#
32+
# For each type of test we only run on Py3.7 on PRs
33+
34+
trial_sqlite_tests = [
35+
{
36+
"python-version": "3.7",
37+
"database": "sqlite",
38+
"extras": "all",
39+
}
40+
]
41+
42+
if not IS_PR:
43+
trial_sqlite_tests.extend(
44+
{
45+
"python-version": version,
46+
"database": "sqlite",
47+
"extras": "all",
48+
}
49+
for version in ("3.8", "3.9", "3.10")
50+
)
51+
52+
53+
trial_postgres_tests = [
54+
{
55+
"python-version": "3.7",
56+
"database": "postgres",
57+
"postgres-version": "10",
58+
"extras": "all",
59+
}
60+
]
61+
62+
if not IS_PR:
63+
trial_postgres_tests.append(
64+
{
65+
"python-version": "3.10",
66+
"database": "postgres",
67+
"postgres-version": "14",
68+
"extras": "all",
69+
}
70+
)
71+
72+
trial_no_extra_tests = [
73+
{
74+
"python-version": "3.7",
75+
"database": "sqlite",
76+
"extras": "",
77+
}
78+
]
79+
80+
print("::group::Calculated trial jobs")
81+
print(
82+
json.dumps(
83+
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests, indent=4
84+
)
85+
)
86+
print("::endgroup::")
87+
88+
test_matrix = json.dumps(
89+
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests
90+
)
91+
set_output("trial_test_matrix", test_matrix)
92+
93+
94+
# First calculate the various sytest jobs.
95+
#
96+
# For each type of test we only run on focal on PRs
97+
98+
99+
sytest_tests = [
100+
{
101+
"sytest-tag": "focal",
102+
},
103+
{
104+
"sytest-tag": "focal",
105+
"postgres": "postgres",
106+
},
107+
{
108+
"sytest-tag": "focal",
109+
"postgres": "multi-postgres",
110+
"workers": "workers",
111+
},
112+
]
113+
114+
if not IS_PR:
115+
sytest_tests.extend(
116+
[
117+
{
118+
"sytest-tag": "testing",
119+
"postgres": "postgres",
120+
},
121+
{
122+
"sytest-tag": "buster",
123+
"postgres": "multi-postgres",
124+
"workers": "workers",
125+
},
126+
]
127+
)
128+
129+
130+
print("::group::Calculated sytest jobs")
131+
print(json.dumps(sytest_tests, indent=4))
132+
print("::endgroup::")
133+
134+
test_matrix = json.dumps(sytest_tests)
135+
set_output("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/postgres_exec.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

.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

.ci/scripts/setup_complement_prerequisites.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ endblock
2121

2222
block Install Complement Dependencies
2323
sudo apt-get -qq update && sudo apt-get install -qqy libolm3 libolm-dev
24-
go get -v github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
24+
go get -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
2525
endblock
2626

2727
block Install custom gotestfmt template

.ci/scripts/test_export_data_command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ else
3232
fi
3333

3434
# Create the PostgreSQL database.
35-
poetry run .ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
35+
psql -c "CREATE DATABASE synapse"
3636

3737
# Port the SQLite databse to postgres so we can check command works against postgres
3838
echo "+++ Port SQLite3 databse to postgres"

.ci/scripts/test_synapse_port_db.sh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22
#
33
# Test script for 'synapse_port_db'.
44
# - configures synapse and a postgres server.
5-
# - runs the port script on a prepopulated test sqlite db
6-
# - also runs it against an new sqlite db
5+
# - runs the port script on a prepopulated test sqlite db. Checks that the
6+
# return code is zero.
7+
# - reruns the port script on the same sqlite db, targetting the same postgres db.
8+
# Checks that the return code is zero.
9+
# - runs the port script against a new sqlite db. Checks the return code is zero.
710
#
811
# Expects Synapse to have been already installed with `poetry install --extras postgres`.
912
# Expects `poetry` to be available on the `PATH`.
1013

11-
set -xe
14+
set -xe -o pipefail
1215
cd "$(dirname "$0")/../.."
1316

1417
echo "--- Generate the signing key"
15-
16-
# Generate the server's signing key.
1718
poetry run synapse_homeserver --generate-keys -c .ci/sqlite-config.yaml
1819

1920
echo "--- Prepare test database"
20-
21-
# Make sure the SQLite3 database is using the latest schema and has no pending background update.
21+
# Make sure the SQLite3 database is using the latest schema and has no pending background updates.
2222
poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
2323

2424
# Create the PostgreSQL database.
25-
poetry run .ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
25+
psql -c "CREATE DATABASE synapse"
2626

2727
echo "+++ Run synapse_port_db against test database"
2828
# TODO: this invocation of synapse_port_db (and others below) used to be prepended with `coverage run`,
@@ -45,9 +45,23 @@ rm .ci/test_db.db
4545
poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
4646

4747
# re-create the PostgreSQL database.
48-
poetry run .ci/scripts/postgres_exec.py \
49-
"DROP DATABASE synapse" \
50-
"CREATE DATABASE synapse"
48+
psql \
49+
-c "DROP DATABASE synapse" \
50+
-c "CREATE DATABASE synapse"
5151

5252
echo "+++ Run synapse_port_db against empty database"
5353
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
54+
55+
echo "--- Create a brand new postgres database from schema"
56+
cp .ci/postgres-config.yaml .ci/postgres-config-unported.yaml
57+
sed -i -e 's/database: synapse/database: synapse_unported/' .ci/postgres-config-unported.yaml
58+
psql -c "CREATE DATABASE synapse_unported"
59+
poetry run update_synapse_database --database-config .ci/postgres-config-unported.yaml --run-background-updates
60+
61+
echo "+++ Comparing ported schema with unported schema"
62+
# Ignore the tables that portdb creates. (Should it tidy them up when the porting is completed?)
63+
psql synapse -c "DROP TABLE port_from_sqlite3;"
64+
pg_dump --format=plain --schema-only --no-tablespaces --no-acl --no-owner synapse_unported > unported.sql
65+
pg_dump --format=plain --schema-only --no-tablespaces --no-acl --no-owner synapse > ported.sql
66+
# By default, `diff` returns zero if there are no changes and nonzero otherwise
67+
diff -u unported.sql ported.sql | tee schema_diff

.dockerignore

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

1118
**/__pycache__

0 commit comments

Comments
 (0)