From d3386afe40e67ae9de163b7a12df79f311dccd60 Mon Sep 17 00:00:00 2001 From: Sean Quah <8349537+squahtx@users.noreply.github.com> Date: Mon, 14 Mar 2022 13:10:13 +0000 Subject: [PATCH] CI: Fix Twisted trunk to run under poetry Signed-off-by: Sean Quah --- .ci/patch_for_twisted_trunk.sh | 20 ++++++++++++++++--- .github/workflows/twisted_trunk.yml | 31 +++++++++++++++++++---------- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/.ci/patch_for_twisted_trunk.sh b/.ci/patch_for_twisted_trunk.sh index f524581986..96368f9ba2 100755 --- a/.ci/patch_for_twisted_trunk.sh +++ b/.ci/patch_for_twisted_trunk.sh @@ -1,8 +1,22 @@ #!/bin/sh -# replaces the dependency on Twisted in `python_dependencies` with trunk. +# replaces the dependency on Twisted with Twisted's trunk. -set -e +set -xe cd "$(dirname "$0")"/.. -sed -i -e 's#"Twisted.*"#"Twisted @ git+https://github.com/twisted/twisted"#' synapse/python_dependencies.py +# We could make full use of the poetry machinery (rather than just `pip install ...`) +# so that we can catch dependency resolver problems that could arise from twisted +# bumping its dependencies... +# sed -ibackup -e 's!^Twisted = .*!Twisted = { git = "https://github.com/twisted/twisted.git", rev = "trunk" }!' pyproject.toml +# poetry lock --no-update +# poetry install --no-interaction --extras "all test" + +# ...except we run into https://github.com/python-poetry/poetry/issues/5311, where +# poetry insists on installing an old version of treq, which isn't actually compatible +# with recent twisted releases. So let's just install twisted trunk using pip. +poetry install --no-interaction --extras "all test" +poetry run pip install git+https://github.com/twisted/twisted.git@trunk + +# Confirm the version of twisted in use +poetry run pip show twisted diff --git a/.github/workflows/twisted_trunk.yml b/.github/workflows/twisted_trunk.yml index 5ec259ca68..c58d300137 100644 --- a/.github/workflows/twisted_trunk.yml +++ b/.github/workflows/twisted_trunk.yml @@ -7,16 +7,22 @@ on: workflow_dispatch: pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: mypy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: matrix-org/setup-python-poetry@v1 + with: + python-version: "3.x" + extras: "all" - run: .ci/patch_for_twisted_trunk.sh - - run: pip install tox - - run: tox -e mypy + - run: poetry run mypy trial: runs-on: ubuntu-latest @@ -24,14 +30,12 @@ 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: 3.7 + python-version: "3.x" + extras: "all test" - run: .ci/patch_for_twisted_trunk.sh - - run: pip install tox - - run: tox -e py - env: - TRIAL_FLAGS: "--jobs=2" + - run: poetry run trial --jobs 2 tests - name: Dump logs # Logs are most useful when the command fails, always include them. @@ -56,11 +60,18 @@ jobs: steps: - uses: actions/checkout@v2 - name: Patch dependencies - run: .ci/patch_for_twisted_trunk.sh + run: >- + ln -s -T /venv /src/.venv && + .ci/patch_for_twisted_trunk.sh && + unlink /src/.venv working-directory: /src - name: Run SyTest run: /bootstrap.sh synapse working-directory: /src + env: + # Use offline mode to avoid reinstalling the pinned version of + # twisted. + OFFLINE: 1 - name: Summarise results.tap if: ${{ always() }} run: /sytest/scripts/tap_to_gha.pl /logs/results.tap