From 1b0fd0abc6b53e633b30aed772e1a3cc60e957d5 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 18 Nov 2026 17:14:21 -0600 Subject: [PATCH] Pin Python versions in CI (#20531) Part of https://github.com/element-hq/backend-internal/issues/238 Also discussed in [meeting to improve security release process](https://docs.google.com/document/d/1UUShIXcuhmDX53-auQIEkeuEaLDYedkFfiE6NbSzOuE/edit?tab=t.0#bookmark=id.c2cmusfqw6lc) Spawning from seeing the CI failing in an old LTS branch because it's choosing the newest Python 3.15 which we're not compatible with yet (https://github.com/element-hq/synapse/issues/20340), let alone the old LTS. We also experienced this here in Synapse FOSS codebase which is why https://github.com/element-hq/synapse/pull/20386 was made. --- .github/workflows/complement_tests.yml | 2 ++ .github/workflows/docs-pr.yaml | 5 +++++ .github/workflows/docs.yaml | 4 ++++ .github/workflows/fix_lint.yaml | 2 ++ .github/workflows/latest_deps.yml | 5 +++-- .github/workflows/poetry_lockfile.yaml | 5 ++++- .github/workflows/push_complement_image.yml | 4 ++++ .github/workflows/release-artifacts.yml | 13 ++++++------ .github/workflows/schema.yaml | 7 +++++-- .github/workflows/schema_diff.yml | 5 ++++- .github/workflows/tests.yml | 22 ++++++++++++++------- .github/workflows/twisted_trunk.yml | 5 +++-- changelog.d/20531.misc | 1 + 13 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 changelog.d/20531.misc diff --git a/.github/workflows/complement_tests.yml b/.github/workflows/complement_tests.yml index be2c698077..9c739d3380 100644 --- a/.github/workflows/complement_tests.yml +++ b/.github/workflows/complement_tests.yml @@ -19,6 +19,7 @@ permissions: env: RUST_VERSION: 1.87.0 + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" jobs: complement: @@ -58,6 +59,7 @@ jobs: # We use `poetry` in `complement.sh` - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" # Matches the `path` where we checkout Synapse above working-directory: "synapse" diff --git a/.github/workflows/docs-pr.yaml b/.github/workflows/docs-pr.yaml index 035eb0270c..d62b096c66 100644 --- a/.github/workflows/docs-pr.yaml +++ b/.github/workflows/docs-pr.yaml @@ -10,6 +10,9 @@ on: # If the docs' python dependencies change, rebuild the book and test links. - pyproject.toml +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + jobs: pages: name: GitHub Pages @@ -30,6 +33,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} install-project: "false" groups: "docs" poetry-version: "2.4.1" @@ -66,6 +70,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} install-project: "false" groups: "docs" poetry-version: "2.4.1" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index e638125e5d..7cb34a4792 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -12,6 +12,9 @@ on: workflow_dispatch: +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + jobs: pre: name: Calculate variables for GitHub Pages deployment @@ -68,6 +71,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} install-project: "false" groups: "docs" poetry-version: "2.4.1" diff --git a/.github/workflows/fix_lint.yaml b/.github/workflows/fix_lint.yaml index 9aae68dfc0..885e7790a0 100644 --- a/.github/workflows/fix_lint.yaml +++ b/.github/workflows/fix_lint.yaml @@ -12,6 +12,7 @@ env: # # Note: This should match the nightly rust version in `tests.yml`. RUST_VERSION: nightly-2025-03-27 + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" jobs: fixup: @@ -32,6 +33,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} install-project: "false" poetry-version: "2.4.1" diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index a1b862ac8b..5355badbfb 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -23,6 +23,7 @@ concurrency: env: RUST_VERSION: 1.87.0 + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" jobs: check_repo: @@ -53,7 +54,7 @@ jobs: # poetry-core versions), so we install with poetry. - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" extras: "all" # Dump installed versions for debugging. @@ -95,7 +96,7 @@ jobs: postgres:${{ matrix.postgres-version }} - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: pip install .[all,test] - name: Await PostgreSQL if: ${{ matrix.postgres-version }} diff --git a/.github/workflows/poetry_lockfile.yaml b/.github/workflows/poetry_lockfile.yaml index ff6632f009..e965dfad89 100644 --- a/.github/workflows/poetry_lockfile.yaml +++ b/.github/workflows/poetry_lockfile.yaml @@ -7,6 +7,9 @@ on: paths: - poetry.lock +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -19,5 +22,5 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: ./scripts-dev/check_locked_deps_have_sdists.py diff --git a/.github/workflows/push_complement_image.yml b/.github/workflows/push_complement_image.yml index 8655c5681a..19a9131df4 100644 --- a/.github/workflows/push_complement_image.yml +++ b/.github/workflows/push_complement_image.yml @@ -17,6 +17,9 @@ on: - develop - master +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + # Only run this action once per pull request/branch; restart if a new commit arrives. # C.f. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency # and https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context @@ -50,6 +53,7 @@ jobs: # We use `poetry` in `complement.sh` - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" - name: Login to registry uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index bb2ad975ad..3d3d97867b 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -15,6 +15,9 @@ on: merge_group: workflow_dispatch: +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -30,7 +33,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - id: set-distros run: | # if we're running from a tag, get the full list of distros; otherwise just use debian:sid @@ -80,7 +83,7 @@ jobs: - name: Set up python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - name: Build the packages # see https://github.com/docker/build-push-action/issues/252 @@ -133,9 +136,7 @@ jobs: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - # setup-python@v4 doesn't impose a default python version. Need to use 3.x - # here, because `python` on osx points to Python 2.7. - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - name: Install cibuildwheel run: python -m pip install cibuildwheel==3.2.1 @@ -170,7 +171,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.11" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: pip install build diff --git a/.github/workflows/schema.yaml b/.github/workflows/schema.yaml index ee6904cea0..ff2cdacbde 100644 --- a/.github/workflows/schema.yaml +++ b/.github/workflows/schema.yaml @@ -9,6 +9,9 @@ on: branches: ["develop", "release-*"] workflow_dispatch: +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + jobs: validate-schema: name: Ensure Synapse config schema is valid @@ -17,7 +20,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - name: Install check-jsonschema run: pip install check-jsonschema==0.33.0 @@ -43,7 +46,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - name: Install PyYAML run: pip install PyYAML==6.0.2 diff --git a/.github/workflows/schema_diff.yml b/.github/workflows/schema_diff.yml index 7101b36945..0b29511592 100644 --- a/.github/workflows/schema_diff.yml +++ b/.github/workflows/schema_diff.yml @@ -7,6 +7,9 @@ on: - synapse/storage/schema/*/full_schemas/** - .github/workflows/schema_diff.yml +env: + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -82,9 +85,9 @@ jobs: - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" extras: "postgres" - python-version: "3.x" - name: Wait for Postgres to be up run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 91e20c7e01..57bda5c310 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,8 @@ env: # at which time of day they cut the release and when the nightly is built. # It's safer for future releases to just do the day before. RUST_NIGHTLY_VERSION: nightly-2025-03-27 # last nightly before 1.88.0 + MINIMUM_SUPPORTED_PYTHON_VERSION: "3.11" + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" jobs: # Job to detect what has changed so we don't run e.g. Rust checks on PRs that @@ -114,7 +116,7 @@ jobs: - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" extras: "all" - run: poetry run scripts-dev/generate_sample_config.sh --check @@ -129,7 +131,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: "pip install 'click==8.1.1' 'GitPython>=3.1.20' 'sqlglot>=28.0.0'" - run: scripts-dev/check_schema_delta.py --force-colors @@ -139,7 +141,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: .ci/scripts/check_lockfile.py lint: @@ -154,6 +156,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" install-project: "false" @@ -182,6 +185,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} # We want to make use of type hints in optional dependencies too. extras: all # We have seen odd mypy failures that were resolved when we started @@ -222,7 +226,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: "pip install 'towncrier>=18.6.0rc1'" - run: scripts-dev/check-newsfragment.sh env: @@ -282,6 +286,7 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} # Install like a normal project from source with all optional dependencies extras: all install-project: "true" @@ -347,7 +352,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - run: "pip install rstcheck" - run: "rstcheck --report-level=WARNING README.rst" @@ -396,7 +401,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} - id: get-matrix run: .ci/scripts/calculate_jobs.py outputs: @@ -487,7 +492,9 @@ jobs: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: "3.11" + # olddeps uses the minimum Python version we support to ensure we're actually + # compatible with what we say we are. + python-version: ${{ env.MINIMUM_SUPPORTED_PYTHON_VERSION }} - name: Prepare old deps # Note: we install using `uv` here, not poetry or pip to allow us to test with the @@ -634,6 +641,7 @@ jobs: - run: sudo apt-get -qq install xmlsec1 postgresql-client - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} poetry-version: "2.4.1" extras: "postgres" - run: .ci/scripts/test_export_data_command.sh diff --git a/.github/workflows/twisted_trunk.yml b/.github/workflows/twisted_trunk.yml index 7f01c04741..1614606cca 100644 --- a/.github/workflows/twisted_trunk.yml +++ b/.github/workflows/twisted_trunk.yml @@ -21,6 +21,7 @@ concurrency: env: RUST_VERSION: 1.87.0 + LATEST_SUPPORTED_PYTHON_VERSION: "3.14" jobs: check_repo: @@ -52,7 +53,7 @@ jobs: - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} extras: "all" poetry-version: "2.4.1" - run: | @@ -80,7 +81,7 @@ jobs: - uses: matrix-org/setup-python-poetry@5bbf6603c5c930615ec8a29f1b5d7d258d905aa4 # v2.0.0 with: - python-version: "3.x" + python-version: ${{ env.LATEST_SUPPORTED_PYTHON_VERSION }} extras: "all test" poetry-version: "2.4.1" - run: | diff --git a/changelog.d/20531.misc b/changelog.d/20531.misc new file mode 100644 index 0000000000..d06ed282fd --- /dev/null +++ b/changelog.d/20531.misc @@ -0,0 +1 @@ +Pin Python versions used in CI (avoid using new incompatible Python versions).