From 4045f74c6da03fc561e0c40f3647ce7f37fb4924 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 9 Mar 2022 16:54:29 +0000 Subject: [PATCH 1/3] CI: Fix the portdb job to run under poetry --- .ci/scripts/test_synapse_port_db.sh | 25 +++++++++---------------- .github/workflows/tests.yml | 3 ++- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.ci/scripts/test_synapse_port_db.sh b/.ci/scripts/test_synapse_port_db.sh index 91bd966f32bd..06c14162d3ba 100755 --- a/.ci/scripts/test_synapse_port_db.sh +++ b/.ci/scripts/test_synapse_port_db.sh @@ -5,39 +5,32 @@ # - runs the port script on a prepopulated test sqlite db # - also runs it against an new sqlite db +# Expects Synapse to have been already installed with `poetry install -e .[postgres] set -xe cd "$(dirname "$0")/../.." -echo "--- Install dependencies" - -# Install dependencies for this test. -pip install psycopg2 coverage coverage-enable-subprocess - -# Install Synapse itself. This won't update any libraries. -pip install -e . - echo "--- Generate the signing key" # Generate the server's signing key. -python -m synapse.app.homeserver --generate-keys -c .ci/sqlite-config.yaml +poetry run synapse_homeserver --generate-keys -c .ci/sqlite-config.yaml echo "--- Prepare test database" # Make sure the SQLite3 database is using the latest schema and has no pending background update. -update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates +poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates # Create the PostgreSQL database. -.ci/scripts/postgres_exec.py "CREATE DATABASE synapse" +poetry run .ci/scripts/postgres_exec.py "CREATE DATABASE synapse" echo "+++ Run synapse_port_db against test database" # TODO: this invocation of synapse_port_db (and others below) used to be prepended with `coverage run`, # but coverage seems unable to find the entrypoints installed by `pip install -e .`. -synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml +poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml # We should be able to run twice against the same database. echo "+++ Run synapse_port_db a second time" -synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml +poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml ##### @@ -48,12 +41,12 @@ echo "--- Prepare empty SQLite database" # we do this by deleting the sqlite db, and then doing the same again. rm .ci/test_db.db -update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates +poetry run update_synapse_database --database-config .ci/sqlite-config.yaml --run-background-updates # re-create the PostgreSQL database. -.ci/scripts/postgres_exec.py \ +poetry run .ci/scripts/postgres_exec.py \ "DROP DATABASE synapse" \ "CREATE DATABASE synapse" echo "+++ Run synapse_port_db against empty database" -synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml +poetry run synapse_port_db --sqlite-database .ci/test_db.db --postgres-config .ci/postgres-config.yaml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c29867cc89c..684a4c1e9e4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -307,9 +307,10 @@ jobs: steps: - uses: actions/checkout@v2 - run: sudo apt-get -qq install xmlsec1 - - uses: actions/setup-python@v2 + - uses: matrix-org/setup-python-poetry@v1 with: python-version: ${{ matrix.python-version }} + extras: "postgres" - run: .ci/scripts/test_synapse_port_db.sh complement: From 6916f2e4fa150dea4490ea4cd66c72583b0e661f Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 7 Apr 2022 16:22:27 +0100 Subject: [PATCH 2/3] Tweak a comment --- .ci/scripts/test_synapse_port_db.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/test_synapse_port_db.sh b/.ci/scripts/test_synapse_port_db.sh index 06c14162d3ba..b07a6b5d0862 100755 --- a/.ci/scripts/test_synapse_port_db.sh +++ b/.ci/scripts/test_synapse_port_db.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash # # Test script for 'synapse_port_db'. -# - sets up synapse and deps +# - configures synapse and a postgres server. # - runs the port script on a prepopulated test sqlite db # - also runs it against an new sqlite db - -# Expects Synapse to have been already installed with `poetry install -e .[postgres] +# +# Expects Synapse to have been already installed with `poetry install --extras postgres`. +# Expects `poetry` to be available on the `PATH`. set -xe cd "$(dirname "$0")/../.." From cac06fdff0da57de08e30b061604ed512a5e12ef Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 7 Apr 2022 16:25:15 +0100 Subject: [PATCH 3/3] Changelog --- changelog.d/12412.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12412.misc diff --git a/changelog.d/12412.misc b/changelog.d/12412.misc new file mode 100644 index 000000000000..03c90c556a8b --- /dev/null +++ b/changelog.d/12412.misc @@ -0,0 +1 @@ +Run the CI portdb script in the locked poetry environment. \ No newline at end of file