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

Commit 0323a9b

Browse files
committed
Merge branch 'daniel-aloni/threepid-login-error' of https://github.com/globekeeper/synapse into daniel-aloni/threepid-login-error
2 parents 3a9fa27 + 7e78b71 commit 0323a9b

File tree

844 files changed

+62829
-42509
lines changed

Some content is hidden

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

844 files changed

+62829
-42509
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: CI run against latest deps is failing
3+
---
4+
See https://github.com/{{env.GITHUB_REPOSITORY}}/actions/runs/{{env.GITHUB_RUN_ID}}

.ci/patch_for_twisted_trunk.sh

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

.ci/scripts/checkout_complement.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Fetches a version of complement which best matches the current build.
4+
#
5+
# The tarball is unpacked into `./complement`.
6+
7+
set -e
8+
mkdir -p complement
9+
10+
# Pick an appropriate version of complement. Depending on whether this is a PR or release,
11+
# etc. we need to use different fallbacks:
12+
#
13+
# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
14+
# for pull requests, otherwise GITHUB_REF).
15+
# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
16+
# (GITHUB_BASE_REF for pull requests).
17+
# 3. Use the default complement branch ("HEAD").
18+
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
19+
# Skip empty branch names and merge commits.
20+
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
21+
continue
22+
fi
23+
24+
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
25+
done

.ci/scripts/test_export_data_command.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22

33
# Test for the export-data admin command against sqlite and postgres
44

5+
# Expects Synapse to have been already installed with `poetry install --extras postgres`.
6+
# Expects `poetry` to be available on the `PATH`.
7+
58
set -xe
69
cd "$(dirname "$0")/../.."
710

8-
echo "--- Install dependencies"
9-
10-
# Install dependencies for this test.
11-
pip install psycopg2
12-
13-
# Install Synapse itself. This won't update any libraries.
14-
pip install -e .
15-
1611
echo "--- Generate the signing key"
1712

1813
# Generate the server's signing key.
19-
python -m synapse.app.homeserver --generate-keys -c .ci/sqlite-config.yaml
14+
poetry run synapse_homeserver --generate-keys -c .ci/sqlite-config.yaml
2015

2116
echo "--- Prepare test database"
2217

2318
# Make sure the SQLite3 database is using the latest schema and has no pending background update.
24-
scripts/update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
19+
poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
2520

2621
# Run the export-data command on the sqlite test database
27-
python -m synapse.app.admin_cmd -c .ci/sqlite-config.yaml export-data @anon-20191002_181700-832:localhost:8800 \
22+
poetry run python -m synapse.app.admin_cmd -c .ci/sqlite-config.yaml export-data @anon-20191002_181700-832:localhost:8800 \
2823
--output-directory /tmp/export_data
2924

3025
# Test that the output directory exists and contains the rooms directory
@@ -37,14 +32,14 @@ else
3732
fi
3833

3934
# Create the PostgreSQL database.
40-
.ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
35+
poetry run .ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
4136

4237
# Port the SQLite databse to postgres so we can check command works against postgres
4338
echo "+++ Port SQLite3 databse to postgres"
44-
scripts/synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
39+
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
4540

4641
# Run the export-data command on postgres database
47-
python -m synapse.app.admin_cmd -c .ci/postgres-config.yaml export-data @anon-20191002_181700-832:localhost:8800 \
42+
poetry run python -m synapse.app.admin_cmd -c .ci/postgres-config.yaml export-data @anon-20191002_181700-832:localhost:8800 \
4843
--output-directory /tmp/export_data2
4944

5045
# Test that the output directory exists and contains the rooms directory

.ci/scripts/test_old_deps.sh

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,81 @@
11
#!/usr/bin/env bash
2+
# this script is run by GitHub Actions in a plain `focal` container; it
3+
# - installs the minimal system requirements, and poetry;
4+
# - patches the project definition file to refer to old versions only;
5+
# - creates a venv with these old versions using poetry; and finally
6+
# - invokes `trial` to run the tests with old deps.
27

3-
# this script is run by GitHub Actions in a plain `bionic` container; it installs the
4-
# minimal requirements for tox and hands over to the py3-old tox environment.
8+
# Prevent tzdata from asking for user input
9+
export DEBIAN_FRONTEND=noninteractive
510

611
set -ex
712

813
apt-get update
9-
apt-get install -y python3 python3-dev python3-pip libxml2-dev libxslt-dev xmlsec1 zlib1g-dev tox
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
1017

1118
export LANG="C.UTF-8"
1219

1320
# Prevent virtualenv from auto-updating pip to an incompatible version
1421
export VIRTUALENV_NO_DOWNLOAD=1
1522

16-
exec tox -e py3-old,combine
23+
# TODO: in the future, we could use an implementation of
24+
# https://github.com/python-poetry/poetry/issues/3527
25+
# https://github.com/pypa/pip/issues/8085
26+
# to select the lowest possible versions, rather than resorting to this sed script.
27+
28+
# Patch the project definitions in-place:
29+
# - Replace all lower and tilde bounds with exact bounds
30+
# - Make the pyopenssl 17.0, which is the oldest version that works with
31+
# a `cryptography` compiled against OpenSSL 1.1.
32+
# - Delete all lines referring to psycopg2 --- so no testing of postgres support.
33+
# - Omit systemd: we're not logging to journal here.
34+
35+
# TODO: also replace caret bounds, see https://python-poetry.org/docs/dependency-specification/#version-constraints
36+
# We don't use these yet, but IIRC they are the default bound used when you `poetry add`.
37+
# The sed expression 's/\^/==/g' ought to do the trick. But it would also change
38+
# `python = "^3.7"` to `python = "==3.7", which would mean we fail because olddeps
39+
# runs on 3.8 (#12343).
40+
41+
sed -i \
42+
-e "s/[~>]=/==/g" \
43+
-e "/psycopg2/d" \
44+
-e 's/pyOpenSSL = "==16.0.0"/pyOpenSSL = "==17.0.0"/' \
45+
-e '/systemd/d' \
46+
pyproject.toml
47+
48+
# Use poetry to do the installation. This ensures that the versions are all mutually
49+
# compatible (as far the package metadata declares, anyway); pip's package resolver
50+
# is more lax.
51+
#
52+
# Rather than `poetry install --no-dev`, we drop all dev dependencies from the
53+
# toml file. This means we don't have to ensure compatibility between old deps and
54+
# dev tools.
55+
56+
pip install --user toml
57+
58+
REMOVE_DEV_DEPENDENCIES="
59+
import toml
60+
with open('pyproject.toml', 'r') as f:
61+
data = toml.loads(f.read())
62+
63+
del data['tool']['poetry']['dev-dependencies']
64+
65+
with open('pyproject.toml', 'w') as f:
66+
toml.dump(data, f)
67+
"
68+
python3 -c "$REMOVE_DEV_DEPENDENCIES"
69+
70+
pipx install poetry==1.1.12
71+
~/.local/bin/poetry lock
72+
73+
echo "::group::Patched pyproject.toml"
74+
cat pyproject.toml
75+
echo "::endgroup::"
76+
echo "::group::Lockfile after patch"
77+
cat poetry.lock
78+
echo "::endgroup::"
79+
80+
~/.local/bin/poetry install -E "all test"
81+
~/.local/bin/poetry run trial --jobs=2 tests
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
#!/usr/bin/env bash
22
#
33
# Test script for 'synapse_port_db'.
4-
# - sets up synapse and deps
4+
# - configures synapse and a postgres server.
55
# - runs the port script on a prepopulated test sqlite db
66
# - also runs it against an new sqlite db
7-
7+
#
8+
# Expects Synapse to have been already installed with `poetry install --extras postgres`.
9+
# Expects `poetry` to be available on the `PATH`.
810

911
set -xe
1012
cd "$(dirname "$0")/../.."
1113

12-
echo "--- Install dependencies"
13-
14-
# Install dependencies for this test.
15-
pip install psycopg2 coverage coverage-enable-subprocess
16-
17-
# Install Synapse itself. This won't update any libraries.
18-
pip install -e .
19-
2014
echo "--- Generate the signing key"
2115

2216
# Generate the server's signing key.
23-
python -m synapse.app.homeserver --generate-keys -c .ci/sqlite-config.yaml
17+
poetry run synapse_homeserver --generate-keys -c .ci/sqlite-config.yaml
2418

2519
echo "--- Prepare test database"
2620

2721
# Make sure the SQLite3 database is using the latest schema and has no pending background update.
28-
scripts/update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
22+
poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
2923

3024
# Create the PostgreSQL database.
31-
.ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
25+
poetry run .ci/scripts/postgres_exec.py "CREATE DATABASE synapse"
3226

3327
echo "+++ Run synapse_port_db against test database"
34-
coverage run scripts/synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
28+
# TODO: this invocation of synapse_port_db (and others below) used to be prepended with `coverage run`,
29+
# but coverage seems unable to find the entrypoints installed by `pip install -e .`.
30+
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
3531

3632
# We should be able to run twice against the same database.
3733
echo "+++ Run synapse_port_db a second time"
38-
coverage run scripts/synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
34+
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
3935

4036
#####
4137

@@ -46,12 +42,12 @@ echo "--- Prepare empty SQLite database"
4642
# we do this by deleting the sqlite db, and then doing the same again.
4743
rm .ci/test_db.db
4844

49-
scripts/update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
45+
poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates
5046

5147
# re-create the PostgreSQL database.
52-
.ci/scripts/postgres_exec.py \
48+
poetry run .ci/scripts/postgres_exec.py \
5349
"DROP DATABASE synapse" \
5450
"CREATE DATABASE synapse"
5551

5652
echo "+++ Run synapse_port_db against empty database"
57-
coverage run scripts/synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
53+
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml

.dockerignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
# things to include
55
!docker
6-
!scripts
76
!synapse
8-
!MANIFEST.in
97
!README.rst
10-
!setup.py
11-
!synctl
8+
!pyproject.toml
9+
!poetry.lock
1210

1311
**/__pycache__

.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TODO: incorporate this into pyproject.toml if flake8 supports it in the future.
2+
# See https://github.com/PyCQA/flake8/issues/234
3+
[flake8]
4+
# see https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
5+
# for error codes. The ones we ignore are:
6+
# W503: line break before binary operator
7+
# W504: line break after binary operator
8+
# E203: whitespace before ':' (which is contrary to pep8?)
9+
# E731: do not assign a lambda expression, use a def
10+
# E501: Line too long (black enforces this for us)
11+
ignore=W503,W504,E203,E731,E501

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ aff1eb7c671b0a3813407321d2702ec46c71fa56
66

77
# Update black to 20.8b1 (#9381).
88
0a00b7ff14890987f09112a2ae696c61001e6cf1
9+
10+
# Convert tests/rest/admin/test_room.py to unix file endings (#7953).
11+
c4268e3da64f1abb5b31deaeb5769adb6510c0a7

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Use markdown where necessary, mostly for `code blocks`.
99
- End with either a period (.) or an exclamation mark (!).
1010
- Start with a capital letter.
11+
- Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
1112
* [ ] Pull request includes a [sign off](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#sign-off)
1213
* [ ] [Code style](https://matrix-org.github.io/synapse/latest/code_style.html) is correct
1314
(run the [linters](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

0 commit comments

Comments
 (0)