From dda9929b74fbc50cc5f60b6caf6e37cf5248699d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 14:48:08 -0500 Subject: [PATCH 01/18] Initial version to dump schema versions. --- scripts-dev/schema_versions.py | 121 +++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100755 scripts-dev/schema_versions.py diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py new file mode 100755 index 000000000000..e5278a7b7410 --- /dev/null +++ b/scripts-dev/schema_versions.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# Copyright 2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import io +from typing import Iterator, Optional, Tuple + +import git +from packaging import version + +# The schema version has moved around over the years. +SCHEMA_VERSION_FILES = ( + "synapse/storage/schema/__init__.py", + "synapse/storage/prepare_database.py", + "synapse/storage/__init__.py", + "synapse/app/homeserver.py", +) + + +def get_schema_versions(tag: git.Tag) -> Tuple[Optional[int], Optional[int]]: + """Get the schema and schema compat versions for a tag.""" + schema_version = None + schema_compat_version = None + + for file in SCHEMA_VERSION_FILES: + try: + schema_file = tag.commit.tree / file + except KeyError: + continue + + # We (usually) can't execute the code since it might have unknown imports. + if file != "synapse/storage/schema/__init__.py": + with io.BytesIO(schema_file.data_stream.read()) as f: + for line in f.readlines(): + if line.startswith(b"SCHEMA_VERSION"): + schema_version = int(line.split()[2]) + + # Bail early. + if schema_version: + break + else: + # SCHEMA_COMPAT_VERSION is sometimes across multiple lines, the easist + # thing to do is exec the code. Luckily it has only ever existed in + # a file which imports nothing else from Synapse. + locals = {} + exec(schema_file.data_stream.read().decode("utf-8"), {}, locals) + schema_version = locals["SCHEMA_VERSION"] + schema_compat_version = locals.get("SCHEMA_COMPAT_VERSION") + + return schema_version, schema_compat_version + + +def get_tags(repo: git.Repo) -> Iterator[git.Tag]: + """Return an iterator of tags sorted by version.""" + tags = [] + for tag in repo.tags: + # All "real" Synapse tags are of the form vX.Y.Z. + if not tag.name.startswith("v"): + continue + + # There's a weird tag from the initial react UI. + if tag.name == "v0.1": + continue + + try: + tag_version = version.parse(tag.name) + except version.InvalidVersion: + # Skip invalid versions. + continue + + # Skip pre- and post-release versions. + if tag_version.is_prerelease or tag_version.is_postrelease or tag_version.local: + continue + + tags.append((tag_version, tag)) + + # Sort based on the version number (not lexically). + return (tag for _, tag in sorted(tags, key=lambda t: t[0])) + + +if __name__ == "__main__": + repo = git.Repo(path=".") + + schema_version = None + schema_compat_version = None + + # Maps of schema versions -> Synapse version. + schema_versions = {} + schema_compat_versions = {} + + for tag in get_tags(repo): + cur_schema_version, cur_schema_compat_version = get_schema_versions(tag) + + if schema_version != cur_schema_version: + schema_versions[cur_schema_version] = tag.name + schema_version = cur_schema_version + if schema_compat_version != cur_schema_compat_version: + schema_compat_versions[cur_schema_compat_version] = tag.name + schema_compat_version = cur_schema_compat_version + + # Generate a table of which maps a version to the version it can be rolled back to. + print("| Synapse version | Backwards compatible version |") + print("|-----------------|------------------------------|") + # v1.37.0 was when the schema compat version was added. + # + # See https://github.com/matrix-org/synapse/pull/9933. + for schema_compat_version, synapse_version in schema_compat_versions.items(): + print( + f"| {synapse_version: ^15} | {schema_versions[schema_compat_version]: ^28} |" + ) From 7cbee468edf3b02d651fad419f7e4e83a824d2c4 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 15:08:27 -0500 Subject: [PATCH 02/18] More accurately calculate schema versions. --- scripts-dev/schema_versions.py | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index e5278a7b7410..d180e5b8f609 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -14,6 +14,7 @@ # limitations under the License. import io +from collections import defaultdict from typing import Iterator, Optional, Tuple import git @@ -95,27 +96,27 @@ def get_tags(repo: git.Repo) -> Iterator[git.Tag]: schema_version = None schema_compat_version = None - # Maps of schema versions -> Synapse version. - schema_versions = {} - schema_compat_versions = {} + # Map of schema version -> Synapse versions at that schema. + schema_versions = defaultdict(list) + # Find ranges of versions which are compatible with a schema version. + # + # There are two modes of operation: + # + # 1. If schema_compat_version is None, then Synapse can only move to a new + # version with schema_version >= its current version. + # 2. If schema_compat_version is *not* None, then Synapse can move to a new + # version with schema version >= schema_compat_version. + # + # See https://github.com/matrix-org/synapse/pull/9933 which was included in v1.37.0. for tag in get_tags(repo): - cur_schema_version, cur_schema_compat_version = get_schema_versions(tag) + schema_version, schema_compat_version = get_schema_versions(tag) - if schema_version != cur_schema_version: - schema_versions[cur_schema_version] = tag.name - schema_version = cur_schema_version - if schema_compat_version != cur_schema_compat_version: - schema_compat_versions[cur_schema_compat_version] = tag.name - schema_compat_version = cur_schema_compat_version + # If a schema compat version is given, prefer that over the schema version. + schema_versions[schema_compat_version or schema_version].append(tag.name) # Generate a table of which maps a version to the version it can be rolled back to. print("| Synapse version | Backwards compatible version |") print("|-----------------|------------------------------|") - # v1.37.0 was when the schema compat version was added. - # - # See https://github.com/matrix-org/synapse/pull/9933. - for schema_compat_version, synapse_version in schema_compat_versions.items(): - print( - f"| {synapse_version: ^15} | {schema_versions[schema_compat_version]: ^28} |" - ) + for synapse_versions in schema_versions.values(): + print(f"| {synapse_versions[-1]: ^15} | {synapse_versions[0]: ^28} |") From 16a3236178056a1ef9c71829eb716cc364a272a1 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 15:24:25 -0500 Subject: [PATCH 03/18] Integrate with mdbook. --- book.toml | 5 ++++- docs/upgrade.md | 7 +++++++ scripts-dev/schema_versions.py | 30 ++++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/book.toml b/book.toml index fa83d86ffc1c..ed3f6151e06a 100644 --- a/book.toml +++ b/book.toml @@ -36,4 +36,7 @@ additional-css = [ "docs/website_files/indent-section-headers.css", ] additional-js = ["docs/website_files/table-of-contents.js"] -theme = "docs/website_files/theme" \ No newline at end of file +theme = "docs/website_files/theme" + +[preprocessor.schema_versions] +command = "./scripts-dev/schema_versions.py" diff --git a/docs/upgrade.md b/docs/upgrade.md index ba2f7703bc75..94dd933848d1 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -88,6 +88,13 @@ process, for example: dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb ``` +Generally Synapse database schemas are compatiblea cross the following versions. +The left column is the latest Synapse version which can be rolled back to the right +column. E.g. Synapse versions v1.13.0 through v1.44.0 can be rolled back safely to +v1.13.0. + + + # Upgrading to v1.93.0 ## Minimum supported Rust version diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index d180e5b8f609..f500e9677fa8 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -14,6 +14,8 @@ # limitations under the License. import io +import json +import sys from collections import defaultdict from typing import Iterator, Optional, Tuple @@ -90,7 +92,7 @@ def get_tags(repo: git.Repo) -> Iterator[git.Tag]: return (tag for _, tag in sorted(tags, key=lambda t: t[0])) -if __name__ == "__main__": +def calculate_version_chart() -> str: repo = git.Repo(path=".") schema_version = None @@ -116,7 +118,27 @@ def get_tags(repo: git.Repo) -> Iterator[git.Tag]: schema_versions[schema_compat_version or schema_version].append(tag.name) # Generate a table of which maps a version to the version it can be rolled back to. - print("| Synapse version | Backwards compatible version |") - print("|-----------------|------------------------------|") + result = "| Synapse version | Backwards compatible version |\n" + result += "|-----------------|------------------------------|\n" for synapse_versions in schema_versions.values(): - print(f"| {synapse_versions[-1]: ^15} | {synapse_versions[0]: ^28} |") + result += f"| {synapse_versions[-1]: ^15} | {synapse_versions[0]: ^28} |\n" + + return result + + +if __name__ == "__main__": + if len(sys.argv) == 3 and sys.argv[1] == "supports": + # We don't care about the renderer which is being used, which is the second argument. + sys.exit(0) + else: + # Expect JSON data on stdin. + context, book = json.load(sys.stdin) + + for section in book["sections"]: + if "Chapter" in section and section["Chapter"]["path"] == "upgrade.md": + section["Chapter"]["content"] = section["Chapter"]["content"].replace( + "", calculate_version_chart() + ) + + # Print the result back out to stdout. + print(json.dumps(book)) From 687e2e49909b994884921b9e15c839638443b900 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 15:27:29 -0500 Subject: [PATCH 04/18] Newsfragment --- changelog.d/16661.doc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16661.doc diff --git a/changelog.d/16661.doc b/changelog.d/16661.doc new file mode 100644 index 000000000000..74f8fc84b8f7 --- /dev/null +++ b/changelog.d/16661.doc @@ -0,0 +1 @@ +Add schema rollback information to documentation. From 56067907368abff99bad9d68921e817d16d5af8d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 15:28:52 -0500 Subject: [PATCH 05/18] Remove unneeded conditional. --- scripts-dev/schema_versions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index f500e9677fa8..7d92f7a11d80 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -49,8 +49,7 @@ def get_schema_versions(tag: git.Tag) -> Tuple[Optional[int], Optional[int]]: if line.startswith(b"SCHEMA_VERSION"): schema_version = int(line.split()[2]) - # Bail early. - if schema_version: + # Bail early. break else: # SCHEMA_COMPAT_VERSION is sometimes across multiple lines, the easist From 4b918d5b5d08fdb3a92a0909ed19f068c79268b9 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 17 Nov 2023 15:31:39 -0500 Subject: [PATCH 06/18] Lint --- scripts-dev/schema_versions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 7d92f7a11d80..8f4ca523423d 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -17,7 +17,7 @@ import json import sys from collections import defaultdict -from typing import Iterator, Optional, Tuple +from typing import Any, Dict, Iterator, Optional, Tuple import git from packaging import version @@ -55,7 +55,7 @@ def get_schema_versions(tag: git.Tag) -> Tuple[Optional[int], Optional[int]]: # SCHEMA_COMPAT_VERSION is sometimes across multiple lines, the easist # thing to do is exec the code. Luckily it has only ever existed in # a file which imports nothing else from Synapse. - locals = {} + locals: Dict[str, Any] = {} exec(schema_file.data_stream.read().decode("utf-8"), {}, locals) schema_version = locals["SCHEMA_VERSION"] schema_compat_version = locals.get("SCHEMA_COMPAT_VERSION") From 7ab7374bd78a40e33f0be2821a4bbb7c8919880d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 10:14:03 -0500 Subject: [PATCH 07/18] Fix typo. Co-authored-by: reivilibre --- docs/upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade.md b/docs/upgrade.md index 94dd933848d1..bcccfae7bb7a 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -88,7 +88,7 @@ process, for example: dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb ``` -Generally Synapse database schemas are compatiblea cross the following versions. +Generally Synapse database schemas are compatible across the following versions. The left column is the latest Synapse version which can be rolled back to the right column. E.g. Synapse versions v1.13.0 through v1.44.0 can be rolled back safely to v1.13.0. From 0cc9e7ea9ee7c944505d867990df64aa258bfc70 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 13:34:06 -0500 Subject: [PATCH 08/18] Fix building docs in CI. --- .github/workflows/docs-pr.yaml | 7 +++++++ .github/workflows/docs.yaml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/docs-pr.yaml b/.github/workflows/docs-pr.yaml index 3704bd66e2ce..fb229473498a 100644 --- a/.github/workflows/docs-pr.yaml +++ b/.github/workflows/docs-pr.yaml @@ -19,6 +19,13 @@ jobs: with: mdbook-version: '0.4.17' + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - run: "pip install 'GitPython>=3.1.20'" + - name: Build the documentation # mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md. # However, we're using docs/README.md for other purposes and need to pick a new page diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index c7cb2d78e504..b388bf5f447c 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -57,6 +57,13 @@ jobs: with: mdbook-version: '0.4.17' + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - run: "pip install 'GitPython>=3.1.20'" + - name: Build the documentation # mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md. # However, we're using docs/README.md for other purposes and need to pick a new page From 0701e8196d0666eed29f6c935dd68bed51ea2b17 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 13:38:44 -0500 Subject: [PATCH 09/18] Support dumping to the command line. --- scripts-dev/schema_versions.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 8f4ca523423d..08c15c6b62c6 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -13,6 +13,26 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A script to calculate which versions of Synapse have backwards-compatible +database schemas. It creates a Markdown table of Synapse versions and the earliest +compatible version. + +It is compatible with the mdbook protocol for preprocessors (see +https://rust-lang.github.io/mdBook/for_developers/preprocessors.html#implementing-a-preprocessor-with-a-different-language): + +Exit 0 to denote support for all renderers: + + ./scripts-dev/schema_versions.py supports + +Parse a JSON list from stdin and add the table to the proper documetnation page: + + ./scripts-dev/schema_versions.py + +Additionally, the script supports dumping the table to stdout for debugging: + + ./scripts-dev/schema_versions.py dump +""" + import io import json import sys @@ -129,6 +149,8 @@ def calculate_version_chart() -> str: if len(sys.argv) == 3 and sys.argv[1] == "supports": # We don't care about the renderer which is being used, which is the second argument. sys.exit(0) + elif len(sys.argv) == 2 and sys.argv[1] == "dump": + print(calculate_version_chart()) else: # Expect JSON data on stdin. context, book = json.load(sys.stdin) From e5676493f8f7ab95dbf3f4ced0d7b5182997c176 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 13:45:51 -0500 Subject: [PATCH 10/18] Install packaging. --- .github/workflows/docs-pr.yaml | 3 ++- .github/workflows/docs.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-pr.yaml b/.github/workflows/docs-pr.yaml index fb229473498a..026f29af6757 100644 --- a/.github/workflows/docs-pr.yaml +++ b/.github/workflows/docs-pr.yaml @@ -6,6 +6,7 @@ on: - docs/** - book.toml - .github/workflows/docs-pr.yaml + - scripts-dev/schema_versions.py jobs: pages: @@ -24,7 +25,7 @@ jobs: with: python-version: "3.x" - - run: "pip install 'GitPython>=3.1.20'" + - run: "pip install 'packaging>=20.0' 'GitPython>=3.1.20'" - name: Build the documentation # mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md. diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index b388bf5f447c..ea3a451a2542 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -62,7 +62,7 @@ jobs: with: python-version: "3.x" - - run: "pip install 'GitPython>=3.1.20'" + - run: "pip install 'packaging>=20.0' 'GitPython>=3.1.20'" - name: Build the documentation # mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md. From a714262827d8fbe40b34675dac15ff4456f1d4d4 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 14:43:12 -0500 Subject: [PATCH 11/18] Clarifications & updates. --- docs/upgrade.md | 10 ++++++---- scripts-dev/schema_versions.py | 34 ++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/upgrade.md b/docs/upgrade.md index bcccfae7bb7a..329c9c778713 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -88,10 +88,12 @@ process, for example: dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb ``` -Generally Synapse database schemas are compatible across the following versions. -The left column is the latest Synapse version which can be rolled back to the right -column. E.g. Synapse versions v1.13.0 through v1.44.0 can be rolled back safely to -v1.13.0. +Generally Synapse database schemas are compatible across multiple versions, once +a version of Synapse is deployed you may not be able to rollback automatically. +The following table gives the version ranges and the earliest version they can +be rolled back to. E.g. Synapse versions v1.58.0 through v1.61.1 can be rolled +back safely to v1.57.0, but starting with v1.62.0 it is only safe to rollback to +v1.61.0. diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 08c15c6b62c6..e699af2f38e8 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -117,30 +117,40 @@ def calculate_version_chart() -> str: schema_version = None schema_compat_version = None - # Map of schema version -> Synapse versions at that schema. + # Map of schema version -> Synapse versions which are at that schema version. schema_versions = defaultdict(list) + # Map of schema version -> Synapse versions which are compatible with that + # schema version. + schema_compat_versions = defaultdict(list) # Find ranges of versions which are compatible with a schema version. # # There are two modes of operation: # - # 1. If schema_compat_version is None, then Synapse can only move to a new - # version with schema_version >= its current version. - # 2. If schema_compat_version is *not* None, then Synapse can move to a new - # version with schema version >= schema_compat_version. + # 1. Pre-schema_compat_version (i.e. schema_compat_version of None), then + # Synapse is compatible up/downgrading to a version with + # schema_version >= its current version. + # + # 2. Post-schema_compat_version (i.e. schema_compat_version is *not* None), + # then Synapse is compatible up/downgrading to a version with + # schema version >= schema_compat_version. + # + # This is more generous and avoids versions that cannot be rolled back. # # See https://github.com/matrix-org/synapse/pull/9933 which was included in v1.37.0. for tag in get_tags(repo): schema_version, schema_compat_version = get_schema_versions(tag) # If a schema compat version is given, prefer that over the schema version. - schema_versions[schema_compat_version or schema_version].append(tag.name) - - # Generate a table of which maps a version to the version it can be rolled back to. - result = "| Synapse version | Backwards compatible version |\n" - result += "|-----------------|------------------------------|\n" - for synapse_versions in schema_versions.values(): - result += f"| {synapse_versions[-1]: ^15} | {synapse_versions[0]: ^28} |\n" + schema_versions[schema_version].append(tag.name) + schema_compat_versions[schema_compat_version or schema_version].append(tag.name) + + # Generate a table which maps the latest Synapse version compatible with each + # schema version. + result = "| Compatible versions | Earliest version |\n" + result += "|{'-' * (19 + 2)}|{'-' * (18 + 2)|\n" + for schema_version, synapse_versions in schema_compat_versions.items(): + result += f"| {synapse_versions[0] + ' - ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n" return result From ac928b087e048fcf2184d1ce5f60a9fe62c9d462 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Nov 2023 16:03:00 -0500 Subject: [PATCH 12/18] f-string --- scripts-dev/schema_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index e699af2f38e8..b7f670567d45 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -148,7 +148,7 @@ def calculate_version_chart() -> str: # Generate a table which maps the latest Synapse version compatible with each # schema version. result = "| Compatible versions | Earliest version |\n" - result += "|{'-' * (19 + 2)}|{'-' * (18 + 2)|\n" + result += f"|{'-' * (19 + 2)}|{'-' * (18 + 2)}|\n" for schema_version, synapse_versions in schema_compat_versions.items(): result += f"| {synapse_versions[0] + ' - ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n" From 25663fd2ff4742287b8c7b7954470e3c0a473625 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 07:28:53 -0500 Subject: [PATCH 13/18] Dash Co-authored-by: Erik Johnston --- scripts-dev/schema_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index e699af2f38e8..0290c11106de 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -150,7 +150,7 @@ def calculate_version_chart() -> str: result = "| Compatible versions | Earliest version |\n" result += "|{'-' * (19 + 2)}|{'-' * (18 + 2)|\n" for schema_version, synapse_versions in schema_compat_versions.items(): - result += f"| {synapse_versions[0] + ' - ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n" + result += f"| {synapse_versions[0] + ' – ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n" return result From a6ee64ede9e3b08ff218cc952babf01b1481b5a7 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 08:04:39 -0500 Subject: [PATCH 14/18] Fix spacing. --- scripts-dev/schema_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 9fb450872823..571780c436b4 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -147,7 +147,7 @@ def calculate_version_chart() -> str: # Generate a table which maps the latest Synapse version compatible with each # schema version. - result = "| Compatible versions | Earliest version |\n" + result = f"| {'Versions': ^19} | Compatible version |\n" result += f"|{'-' * (19 + 2)}|{'-' * (18 + 2)}|\n" for schema_version, synapse_versions in schema_compat_versions.items(): result += f"| {synapse_versions[0] + ' – ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n" From 63bb213a6eaa647f97d9ffa60180e16a72eec00e Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 08:05:04 -0500 Subject: [PATCH 15/18] Remove unused vars. --- scripts-dev/schema_versions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 571780c436b4..01d052d16be0 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -114,9 +114,6 @@ def get_tags(repo: git.Repo) -> Iterator[git.Tag]: def calculate_version_chart() -> str: repo = git.Repo(path=".") - schema_version = None - schema_compat_version = None - # Map of schema version -> Synapse versions which are at that schema version. schema_versions = defaultdict(list) # Map of schema version -> Synapse versions which are compatible with that From 8af8160dd9721eb0a5361d7818de82895c97554f Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 08:08:00 -0500 Subject: [PATCH 16/18] SKip old versions. --- scripts-dev/schema_versions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts-dev/schema_versions.py b/scripts-dev/schema_versions.py index 01d052d16be0..5fd73251cdcb 100755 --- a/scripts-dev/schema_versions.py +++ b/scripts-dev/schema_versions.py @@ -51,6 +51,11 @@ ) +# Skip versions of Synapse < v1.0, they're old and essentially not +# compatible with today's federation. +OLDEST_SHOWN_VERSION = version.parse("v1.0") + + def get_schema_versions(tag: git.Tag) -> Tuple[Optional[int], Optional[int]]: """Get the schema and schema compat versions for a tag.""" schema_version = None @@ -105,6 +110,10 @@ def get_tags(repo: git.Repo) -> Iterator[git.Tag]: if tag_version.is_prerelease or tag_version.is_postrelease or tag_version.local: continue + # Skip old versions. + if tag_version < OLDEST_SHOWN_VERSION: + continue + tags.append((tag_version, tag)) # Sort based on the version number (not lexically). From ec5e7604e9d47249c6ffa61220c2e97ccb155f86 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 09:05:51 -0500 Subject: [PATCH 17/18] Try including tags. --- .github/workflows/docs-pr.yaml | 3 +++ .github/workflows/docs.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/docs-pr.yaml b/.github/workflows/docs-pr.yaml index 026f29af6757..a5c97b1dcd6c 100644 --- a/.github/workflows/docs-pr.yaml +++ b/.github/workflows/docs-pr.yaml @@ -14,6 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + # Fetch all tags so that the schema_versions script works. + fetch-tags: true - name: Setup mdbook uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index ea3a451a2542..45879840c489 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -51,6 +51,9 @@ jobs: - pre steps: - uses: actions/checkout@v4 + with: + # Fetch all tags so that the schema_versions script works. + fetch-tags: true - name: Setup mdbook uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0 From a3718ac3fa2416fe1db7b105c7466f02c346eb49 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 28 Nov 2023 09:10:09 -0500 Subject: [PATCH 18/18] Fetch all history. --- .github/workflows/docs-pr.yaml | 4 ++-- .github/workflows/docs.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-pr.yaml b/.github/workflows/docs-pr.yaml index a5c97b1dcd6c..9cf3d340a419 100644 --- a/.github/workflows/docs-pr.yaml +++ b/.github/workflows/docs-pr.yaml @@ -15,8 +15,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - # Fetch all tags so that the schema_versions script works. - fetch-tags: true + # Fetch all history so that the schema_versions script works. + fetch-depth: 0 - name: Setup mdbook uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 45879840c489..31b9dbe3fea6 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -52,8 +52,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - # Fetch all tags so that the schema_versions script works. - fetch-tags: true + # Fetch all history so that the schema_versions script works. + fetch-depth: 0 - name: Setup mdbook uses: peaceiris/actions-mdbook@adeb05db28a0c0004681db83893d56c0388ea9ea # v1.2.0