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

Commit 3a3e6ee

Browse files
author
David Robertson
committed
Merge remote-tracking branch 'origin/develop' into dmr/try-3.11-ci
2 parents 89dc3dd + 2b940d2 commit 3a3e6ee

File tree

436 files changed

+17017
-4709
lines changed

Some content is hidden

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

436 files changed

+17017
-4709
lines changed

Diff for: .ci/scripts/calculate_jobs.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
import json
1919
import os
2020

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+
2128
IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/")
2229

2330
# First calculate the various trial jobs.
@@ -81,7 +88,7 @@
8188
test_matrix = json.dumps(
8289
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests
8390
)
84-
print(f"::set-output name=trial_test_matrix::{test_matrix}")
91+
set_output("trial_test_matrix", test_matrix)
8592

8693

8794
# First calculate the various sytest jobs.
@@ -125,4 +132,4 @@
125132
print("::endgroup::")
126133

127134
test_matrix = json.dumps(sytest_tests)
128-
print(f"::set-output name=sytest_test_matrix::{test_matrix}")
135+
set_output("sytest_test_matrix", test_matrix)

Diff for: .ci/scripts/postgres_exec.py

-31
This file was deleted.

Diff for: .ci/scripts/setup_complement_prerequisites.sh

+1-1
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

Diff for: .ci/scripts/test_export_data_command.sh

+1-1
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"

Diff for: .ci/scripts/test_synapse_port_db.sh

+25-11
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

Diff for: .dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
!README.rst
99
!pyproject.toml
1010
!poetry.lock
11+
!Cargo.lock
12+
!Cargo.toml
1113
!build_rust.py
1214

1315
rust/target
16+
synapse/*.so
1417

1518
**/__pycache__

Diff for: .github/dependabot.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
updates:
3+
- # "pip" is the correct setting for poetry, per https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
4+
package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
9+
- package-ecosystem: "docker"
10+
directory: "/docker"
11+
schedule:
12+
interval: "weekly"
13+
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
19+
- package-ecosystem: "cargo"
20+
directory: "/"
21+
schedule:
22+
interval: "weekly"

Diff for: .github/workflows/dependabot_changelog.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Write changelog for dependabot PR
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened # For debugging!
7+
8+
permissions:
9+
# Needed to be able to push the commit. See
10+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
11+
# for a similar example
12+
contents: write
13+
14+
jobs:
15+
add-changelog:
16+
runs-on: 'ubuntu-latest'
17+
if: ${{ github.actor == 'dependabot[bot]' }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
- name: Write, commit and push changelog
23+
run: |
24+
echo "${{ github.event.pull_request.title }}." > "changelog.d/${{ github.event.pull_request.number }}".misc
25+
git add changelog.d
26+
git config user.email "github-actions[bot]@users.noreply.github.com"
27+
git config user.name "GitHub Actions"
28+
git commit -m "Changelog"
29+
git push
30+
shell: bash
31+
# The `git push` above does not trigger CI on the dependabot PR.
32+
#
33+
# By default, workflows can't trigger other workflows when they're just using the
34+
# default `GITHUB_TOKEN` access token. (This is intended to stop you from writing
35+
# recursive workflow loops by accident, because that'll get very expensive very
36+
# quickly.) Instead, you have to manually call out to another workflow, or else
37+
# make your changes (i.e. the `git push` above) using a personal access token.
38+
# See
39+
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
40+
#
41+
# I have tried and failed to find a way to trigger CI on the "merge ref" of the PR.
42+
# See git commit history for previous attempts. If anyone desperately wants to try
43+
# again in the future, make a matrix-bot account and use its access token to git push.
44+
45+
# THIS WORKFLOW HAS WRITE PERMISSIONS---do not add other jobs here unless they
46+
# are sufficiently locked down to dependabot only as above.

Diff for: .github/workflows/docker.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ jobs:
1717
steps:
1818
- name: Set up QEMU
1919
id: qemu
20-
uses: docker/setup-qemu-action@v1
20+
uses: docker/setup-qemu-action@v2
2121
with:
2222
platforms: arm64
2323

2424
- name: Set up Docker Buildx
2525
id: buildx
26-
uses: docker/setup-buildx-action@v1
26+
uses: docker/setup-buildx-action@v2
2727

2828
- name: Inspect builder
2929
run: docker buildx inspect
30-
30+
3131
- name: Log in to DockerHub
32-
uses: docker/login-action@v1
32+
uses: docker/login-action@v2
3333
with:
3434
username: ${{ secrets.DOCKERHUB_USERNAME }}
3535
password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -48,10 +48,15 @@ jobs:
4848
type=pep440,pattern={{raw}}
4949
5050
- name: Build and push all platforms
51-
uses: docker/build-push-action@v2
51+
uses: docker/build-push-action@v3
5252
with:
5353
push: true
5454
labels: "gitsha1=${{ github.sha }}"
5555
tags: "${{ steps.set-tag.outputs.tags }}"
5656
file: "docker/Dockerfile"
5757
platforms: linux/amd64,linux/arm64
58+
59+
# arm64 builds OOM without the git fetch setting. c.f.
60+
# https://github.com/rust-lang/cargo/issues/10583
61+
build-args: |
62+
CARGO_NET_GIT_FETCH_WITH_CLI=true

Diff for: .github/workflows/docs.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: GitHub Pages
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121

2222
- name: Setup mdbook
2323
uses: peaceiris/actions-mdbook@4b5ef36b314c2599664ca107bb8c02412548d79d # v1.1.14
@@ -54,7 +54,7 @@ jobs:
5454
esac
5555
5656
# finally, set the 'branch-version' var.
57-
echo "::set-output name=branch-version::$branch"
57+
echo "branch-version=$branch" >> "$GITHUB_OUTPUT"
5858
5959
# Deploy to the target directory.
6060
- name: Deploy to gh pages

Diff for: .github/workflows/latest_deps.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
mypy:
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
2929
- name: Install Rust
3030
uses: actions-rs/toolchain@v1
3131
with:
@@ -59,7 +59,7 @@ jobs:
5959
postgres-version: "14"
6060

6161
steps:
62-
- uses: actions/checkout@v2
62+
- uses: actions/checkout@v3
6363

6464
- name: Install Rust
6565
uses: actions-rs/toolchain@v1
@@ -76,7 +76,7 @@ jobs:
7676
-e POSTGRES_PASSWORD=postgres \
7777
-e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \
7878
postgres:${{ matrix.postgres-version }}
79-
- uses: actions/setup-python@v2
79+
- uses: actions/setup-python@v4
8080
with:
8181
python-version: "3.x"
8282
- run: pip install .[all,test]
@@ -133,7 +133,7 @@ jobs:
133133
BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }}
134134

135135
steps:
136-
- uses: actions/checkout@v2
136+
- uses: actions/checkout@v3
137137

138138
- name: Install Rust
139139
uses: actions-rs/toolchain@v1
@@ -155,7 +155,7 @@ jobs:
155155
if: ${{ always() }}
156156
run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
157157
- name: Upload SyTest logs
158-
uses: actions/upload-artifact@v2
158+
uses: actions/upload-artifact@v3
159159
if: ${{ always() }}
160160
with:
161161
name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
@@ -182,8 +182,8 @@ jobs:
182182
database: Postgres
183183

184184
steps:
185-
- name: Run actions/checkout@v2 for synapse
186-
uses: actions/checkout@v2
185+
- name: Run actions/checkout@v3 for synapse
186+
uses: actions/checkout@v3
187187
with:
188188
path: synapse
189189

@@ -201,15 +201,16 @@ jobs:
201201
open-issue:
202202
if: "failure() && github.event_name != 'push' && github.event_name != 'pull_request'"
203203
needs:
204-
# TODO: should mypy be included here? It feels more brittle than the other two.
204+
# TODO: should mypy be included here? It feels more brittle than the others.
205205
- mypy
206206
- trial
207207
- sytest
208+
- complement
208209

209210
runs-on: ubuntu-latest
210211

211212
steps:
212-
- uses: actions/checkout@v2
213+
- uses: actions/checkout@v3
213214
- uses: JasonEtco/create-an-issue@5d9504915f79f9cc6d791934b8ef34f2353dd74d # v2.5.0, 2020-12-06
214215
env:
215216
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)