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

Commit 7851a2c

Browse files
author
David Robertson
authored
CI: Get the portdb job to run under poetry (#12412)
1 parent 78e4d96 commit 7851a2c

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +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-
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"
3428
# TODO: this invocation of synapse_port_db (and others below) used to be prepended with `coverage run`,
3529
# but coverage seems unable to find the entrypoints installed by `pip install -e .`.
36-
synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
30+
poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml
3731

3832
# We should be able to run twice against the same database.
3933
echo "+++ Run synapse_port_db a second time"
40-
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
4135

4236
#####
4337

@@ -48,12 +42,12 @@ echo "--- Prepare empty SQLite database"
4842
# we do this by deleting the sqlite db, and then doing the same again.
4943
rm .ci/test_db.db
5044

51-
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
5246

5347
# re-create the PostgreSQL database.
54-
.ci/scripts/postgres_exec.py \
48+
poetry run .ci/scripts/postgres_exec.py \
5549
"DROP DATABASE synapse" \
5650
"CREATE DATABASE synapse"
5751

5852
echo "+++ Run synapse_port_db against empty database"
59-
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

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,10 @@ jobs:
307307
steps:
308308
- uses: actions/checkout@v2
309309
- run: sudo apt-get -qq install xmlsec1
310-
- uses: actions/setup-python@v2
310+
- uses: matrix-org/setup-python-poetry@v1
311311
with:
312312
python-version: ${{ matrix.python-version }}
313+
extras: "postgres"
313314
- run: .ci/scripts/test_synapse_port_db.sh
314315

315316
complement:

changelog.d/12412.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run the CI portdb script in the locked poetry environment.

0 commit comments

Comments
 (0)