From 7667444caff15cc5cd98a760afed50f0e5df3fdc Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 11:22:06 +0100 Subject: [PATCH 01/30] WIP pip install from wheel job --- ...latest_deps_build_failed_issue_template.md | 4 + .github/workflows/latest_deps.yml | 113 ++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 .ci/latest_deps_build_failed_issue_template.md create mode 100644 .github/workflows/latest_deps.yml diff --git a/.ci/latest_deps_build_failed_issue_template.md b/.ci/latest_deps_build_failed_issue_template.md new file mode 100644 index 000000000000..0525402503fd --- /dev/null +++ b/.ci/latest_deps_build_failed_issue_template.md @@ -0,0 +1,4 @@ +--- +title: CI run against latest deps is failing +--- +See https://github.com/{{env.GITHUB_REPOSITORY}}/actions/runs/{{env.GITHUB_RUN_ID}} diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml new file mode 100644 index 000000000000..f6d0143e6899 --- /dev/null +++ b/.github/workflows/latest_deps.yml @@ -0,0 +1,113 @@ +# People who are freshly `pip install`ing from the wheels we publish to PyPI will pull +# in the latest versions of all dependencies. We used to do this in our CI runs, which +# would detect any incompatibilities due to new package releases. Now that we use the +# locked poetry environment, we don't have advance notice of these breakages.defaults: +# +# To plug that hole, this job is a canary which periodically +# - checks out develop, +# - pip installs from source (building a wheel locally using `poetry-core`, +# and `pip install`ing from that), and +# - runs test suites against that checkout. +# +# Based on the twisted trunk CI job. + +name: Latest dependencies + +on: + schedule: + - cron: 0 7 * * * + pull_request: + branches: + - dmr/poetry-wheel-ci + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: +# TODO: do we want a mypy job? The mypy-only dependencies aren't exposed as extras, so +# we would need to do some poetry shenanigans here. +# mypy: + + trial: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - run: sudo apt-get -qq install xmlsec1 + - uses: actions/setup-python@v2 + with: + python-version: "3.x" + - run: trial --jobs 2 tests + + - name: Dump logs + # Logs are most useful when the command fails, always include them. + if: ${{ always() }} + # Note: Dumps to workflow logs instead of using actions/upload-artifact + # This keeps logs colocated with failing jobs + # It also ignores find's exit code; this is a best effort affair + run: >- + find _trial_temp -name '*.log' + -exec echo "::group::{}" \; + -exec cat {} \; + -exec echo "::endgroup::" \; + || true + +# sytest: +# runs-on: ubuntu-latest +# container: +# image: matrixdotorg/sytest-synapse:testing +# volumes: +# - ${{ github.workspace }}:/src +# +# steps: +# - uses: actions/checkout@v2 +# - name: Patch dependencies +# # Note: The poetry commands want to create a virtualenv in /src/.venv/, +# # but the sytest-synapse container expects it to be in /venv/. +# # We symlink it before running poetry so that poetry actually +# # ends up installing to `/venv`. +# run: | +# ln -s -T /venv /src/.venv +# poetry remove twisted +# poetry add --extras tls git+https://github.com/twisted/twisted.git#trunk +# poetry install --no-interaction --extras "all test" +# 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 +# - name: Upload SyTest logs +# uses: actions/upload-artifact@v2 +# if: ${{ always() }} +# with: +# name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }}) +# path: | +# /logs/results.tap +# /logs/**/*.log* + + # open an issue if the build fails, so we know about it. +# open-issue: +# if: failure() +# needs: +# - mypy +# - trial +# - sytest +# +# runs-on: ubuntu-latest +# +# steps: +# - uses: actions/checkout@v2 +# - uses: JasonEtco/create-an-issue@5d9504915f79f9cc6d791934b8ef34f2353dd74d # v2.5.0, 2020-12-06 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# update_existing: true +# filename: .ci/twisted_trunk_build_failed_issue_template.md From b28c551ecb75407861a09f14b90a6ffc2ff27bff Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 11:30:17 +0100 Subject: [PATCH 02/30] Try to run action? --- .github/workflows/latest_deps.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index f6d0143e6899..2f435717837a 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -17,8 +17,9 @@ on: schedule: - cron: 0 7 * * * pull_request: - branches: - - dmr/poetry-wheel-ci + branches: [dmr/poetry-wheel-ci] + push: + branches: [dmr/poetry-wheel-ci] workflow_dispatch: concurrency: From 0a591a1d32ba0515b9b5437f0826d6bbfc70eeb9 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 11:42:05 +0100 Subject: [PATCH 03/30] Try to run postgres tests too --- .github/workflows/latest_deps.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 2f435717837a..715a47e1b8ae 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -33,15 +33,36 @@ jobs: trial: runs-on: ubuntu-latest + strategy: + matrix: + include: + - database: "sqlite" + - database: "postgres" + postgres-version: "14" steps: - uses: actions/checkout@v2 - run: sudo apt-get -qq install xmlsec1 + - name: Set up PostgreSQL ${{ matrix.postgres-version }} + if: ${{ matrix.postgres-version }} + run: | + docker run -d -p 5432:5432 \ + -e POSTGRES_PASSWORD=postgres \ + -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \ + postgres:${{ matrix.postgres-version }} - uses: actions/setup-python@v2 with: python-version: "3.x" - - run: trial --jobs 2 tests - + - name: Await PostgreSQL + if: ${{ matrix.postgres-version }} + timeout-minutes: 2 + run: until pg_isready -h localhost; do sleep 1; done + - run: trial --jobs=2 tests + env: + SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }} + SYNAPSE_POSTGRES_HOST: localhost + SYNAPSE_POSTGRES_USER: postgres + SYNAPSE_POSTGRES_PASSWORD: postgres - name: Dump logs # Logs are most useful when the command fails, always include them. if: ${{ always() }} @@ -55,6 +76,7 @@ jobs: -exec echo "::endgroup::" \; || true + # sytest: # runs-on: ubuntu-latest # container: From 67153241115b3d3e1721aa622ee69afed403e053 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 11:43:50 +0100 Subject: [PATCH 04/30] Install package whoopsie --- .github/workflows/latest_deps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 715a47e1b8ae..0fe0bef43777 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -53,6 +53,7 @@ jobs: - uses: actions/setup-python@v2 with: python-version: "3.x" + - run: pip install -e .[all,test] - name: Await PostgreSQL if: ${{ matrix.postgres-version }} timeout-minutes: 2 From 96e228d96f1dcad4c85151b08f319bfb053c7823 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 12:49:17 +0100 Subject: [PATCH 05/30] sytest? --- .github/workflows/latest_deps.yml | 66 +++++++++++++------------------ 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 0fe0bef43777..d61f7b613669 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -78,44 +78,34 @@ jobs: || true -# sytest: -# runs-on: ubuntu-latest -# container: -# image: matrixdotorg/sytest-synapse:testing -# volumes: -# - ${{ github.workspace }}:/src -# -# steps: -# - uses: actions/checkout@v2 -# - name: Patch dependencies -# # Note: The poetry commands want to create a virtualenv in /src/.venv/, -# # but the sytest-synapse container expects it to be in /venv/. -# # We symlink it before running poetry so that poetry actually -# # ends up installing to `/venv`. -# run: | -# ln -s -T /venv /src/.venv -# poetry remove twisted -# poetry add --extras tls git+https://github.com/twisted/twisted.git#trunk -# poetry install --no-interaction --extras "all test" -# 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 -# - name: Upload SyTest logs -# uses: actions/upload-artifact@v2 -# if: ${{ always() }} -# with: -# name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }}) -# path: | -# /logs/results.tap -# /logs/**/*.log* + sytest: + runs-on: ubuntu-latest + container: + image: matrixdotorg/sytest-synapse:testing + volumes: + - ${{ github.workspace }}:/src + + steps: + - uses: actions/checkout@v2 + - name: Ensure systest runs `pip install` + run: | + # Delete the lockfile so sytest will `pip install` rather than `poetry install` + rm /src/poetry.lock + working-directory: /src + - name: Run SyTest + run: /bootstrap.sh synapse + working-directory: /src + - name: Summarise results.tap + if: ${{ always() }} + run: /sytest/scripts/tap_to_gha.pl /logs/results.tap + - name: Upload SyTest logs + uses: actions/upload-artifact@v2 + if: ${{ always() }} + with: + name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }}) + path: | + /logs/results.tap + /logs/**/*.log* # open an issue if the build fails, so we know about it. # open-issue: From ea9cf7f26ca80887826f49cb8a26e29076ed25f2 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 12:54:13 +0100 Subject: [PATCH 06/30] Changelog --- changelog.d/12472.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12472.misc diff --git a/changelog.d/12472.misc b/changelog.d/12472.misc new file mode 100644 index 000000000000..ed306209cc42 --- /dev/null +++ b/changelog.d/12472.misc @@ -0,0 +1 @@ +Add a CI job which tests Synapse against the latest version of all dependencies. From da400f1b446a3b66918856eade54074a547995e8 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 13:21:50 +0100 Subject: [PATCH 07/30] sytest on postgres too --- .github/workflows/latest_deps.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index d61f7b613669..48d20bfafd7f 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -84,14 +84,30 @@ jobs: image: matrixdotorg/sytest-synapse:testing volumes: - ${{ github.workspace }}:/src + strategy: + fail-fast: false + matrix: + include: + - sytest-tag: focal + + - sytest-tag: focal + postgres: postgres + workers: workers + redis: redis + env: + POSTGRES: ${{ matrix.postgres && 1}} + WORKERS: ${{ matrix.workers && 1 }} + REDIS: ${{ matrix.redis && 1 }} + BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }} steps: - uses: actions/checkout@v2 - name: Ensure systest runs `pip install` - run: | - # Delete the lockfile so sytest will `pip install` rather than `poetry install` - rm /src/poetry.lock + # Delete the lockfile so sytest will `pip install` rather than `poetry install` + run: rm /src/poetry.lock working-directory: /src + - name: Prepare test blacklist + run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers - name: Run SyTest run: /bootstrap.sh synapse working-directory: /src From 094f3101c7b0ed6b367e489bdd60618923ddca82 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 13:23:12 +0100 Subject: [PATCH 08/30] Trypy mypy --- .github/workflows/latest_deps.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 48d20bfafd7f..ee17cd95d7ee 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -27,10 +27,21 @@ concurrency: cancel-in-progress: true jobs: -# TODO: do we want a mypy job? The mypy-only dependencies aren't exposed as extras, so -# we would need to do some poetry shenanigans here. -# mypy: - + # TODO(dmr): I'm not sure if we want to run mypy here, nor if mypy failures should + # merit an issue. + mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # The dev dependencies aren't exposed in the wheel metadata (at least with current + # poetry-core versions). So we'll have to be dirty: `poetry install` to get the + # dev deps, then upgrade them in situ with pip. + - uses: matrix-org/setup-python-poetry@v1 + with: + python-version: "3.x" + # Lacking a `pip install --upgrade-literally-everything` option, concoct our own. + - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs echo pip install --upgrade --upgrade-strategy eager" + - run: poetry run mypy trial: runs-on: ubuntu-latest strategy: From 5b2ddcc6692c464faa96719ff848cc25be42de9a Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 13:23:23 +0100 Subject: [PATCH 09/30] Notes and fixes --- .github/workflows/latest_deps.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index ee17cd95d7ee..5b3f851f9de2 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -134,10 +134,14 @@ jobs: /logs/results.tap /logs/**/*.log* + + # TODO: run complement (as with twisted trunk, see #12473). + # open an issue if the build fails, so we know about it. # open-issue: # if: failure() # needs: +# # TODO: should mypy be included here? It feels more brittle than the other two. # - mypy # - trial # - sytest @@ -151,4 +155,4 @@ jobs: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # with: # update_existing: true -# filename: .ci/twisted_trunk_build_failed_issue_template.md +# filename: .ci/latest_deps_build_failed_issue_template.md From 3fbcf54cfe40647680259048af9182f5aeef8a32 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 14 Apr 2022 13:30:47 +0100 Subject: [PATCH 10/30] Actually upgrade packages --- .github/workflows/latest_deps.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 5b3f851f9de2..4808a6c541af 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -40,7 +40,9 @@ jobs: with: python-version: "3.x" # Lacking a `pip install --upgrade-literally-everything` option, concoct our own. - - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs echo pip install --upgrade --upgrade-strategy eager" + - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs pip install --upgrade --upgrade-strategy eager" + # Dump installed versions for debugging + - run: pip freeze - run: poetry run mypy trial: runs-on: ubuntu-latest From 52cce2cbc0ac539abe6c0fb08e44b0dfeacb3818 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 13:45:15 +0100 Subject: [PATCH 11/30] Clarify comment Co-authored-by: Patrick Cloke --- .github/workflows/latest_deps.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 4808a6c541af..9b782af270d1 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -1,7 +1,7 @@ -# People who are freshly `pip install`ing from the wheels we publish to PyPI will pull -# in the latest versions of all dependencies. We used to do this in our CI runs, which -# would detect any incompatibilities due to new package releases. Now that we use the -# locked poetry environment, we don't have advance notice of these breakages.defaults: +# People who are freshly `pip install`ing from PyPI will pull in the latest versions of all +# dependencies. Since most CI runs are against the locked poetry environment, run +# specifically against the latest dependencies to know if there's an upcoming breaking +# change. # # To plug that hole, this job is a canary which periodically # - checks out develop, From 293c1ee6e1794ea7dd84a693a228919217abd359 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 14:22:42 +0100 Subject: [PATCH 12/30] Commit to running mypy in this job Co-authored-by: Patrick Cloke --- .github/workflows/latest_deps.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 9b782af270d1..6618139381ab 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -27,8 +27,6 @@ concurrency: cancel-in-progress: true jobs: - # TODO(dmr): I'm not sure if we want to run mypy here, nor if mypy failures should - # merit an issue. mypy: runs-on: ubuntu-latest steps: From efda082d476ef54a992d83f863dd0223a6d545f7 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 15:19:57 +0100 Subject: [PATCH 13/30] Make sure we `poetry run pip` We want to modify the package versions in poetry's venv --- .github/workflows/latest_deps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 6618139381ab..e698f023912c 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -38,9 +38,9 @@ jobs: with: python-version: "3.x" # Lacking a `pip install --upgrade-literally-everything` option, concoct our own. - - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs pip install --upgrade --upgrade-strategy eager" + - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs poetry run pip install --upgrade --upgrade-strategy eager" # Dump installed versions for debugging - - run: pip freeze + - run: poetry run pip freeze - run: poetry run mypy trial: runs-on: ubuntu-latest From 76aca202f1367d58082edf6cb811313f112e3870 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 15:20:41 +0100 Subject: [PATCH 14/30] Paranoia: single pip invocation --- .github/workflows/latest_deps.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index e698f023912c..d6de52f17acd 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -38,7 +38,10 @@ jobs: with: python-version: "3.x" # Lacking a `pip install --upgrade-literally-everything` option, concoct our own. - - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs poetry run pip install --upgrade --upgrade-strategy eager" + # Ensure that we only invoke `pip install` once with at most 1000 package names + # by passing `-x -n 1000` to `xargs`. This ensures that pip resolves all + # dependencies together. + - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs -x -n 1000 poetry run pip install --upgrade --upgrade-strategy eager" # Dump installed versions for debugging - run: poetry run pip freeze - run: poetry run mypy From 93652a094f02b5a69f4b33d5dc2514f019e61d09 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 15:58:35 +0100 Subject: [PATCH 15/30] Try to only update runtime packages, not dev deps --- .github/workflows/latest_deps.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index d6de52f17acd..9c1877b8d7e9 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -37,13 +37,13 @@ jobs: - uses: matrix-org/setup-python-poetry@v1 with: python-version: "3.x" - # Lacking a `pip install --upgrade-literally-everything` option, concoct our own. - # Ensure that we only invoke `pip install` once with at most 1000 package names - # by passing `-x -n 1000` to `xargs`. This ensures that pip resolves all - # dependencies together. - - run: "poetry run pip freeze | cut -d' ' -f 1 | xargs -x -n 1000 poetry run pip install --upgrade --upgrade-strategy eager" - # Dump installed versions for debugging - - run: poetry run pip freeze + # Dump installed versions for debugging. + - run: poetry run pip freeze > before.txt + # Upgrade all runtime dependencies only. This is intended to mimic a fresh + # `pip install matrix-synapse[all]` as closely as possible. + - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager + - run: poetry run pip freeze | tee after.txt + - run: diff -u before.txt after.txt || true - run: poetry run mypy trial: runs-on: ubuntu-latest From e6b786e4352816d60a05c6b4c0a4f1d09868a521 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 16:45:28 +0100 Subject: [PATCH 16/30] Comment justifying strategy --- .github/workflows/latest_deps.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 9c1877b8d7e9..533fdb0b554d 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -41,6 +41,10 @@ jobs: - run: poetry run pip freeze > before.txt # Upgrade all runtime dependencies only. This is intended to mimic a fresh # `pip install matrix-synapse[all]` as closely as possible. + # AFAICS this will update transitive dependencies. E.g. try + # pip install requests==2.24.0 idna==2.8 + # pip install --upgrade --upgrade-strategy eager requests + # The second command should update both requests and idna. - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager - run: poetry run pip freeze | tee after.txt - run: diff -u before.txt after.txt || true From 643444d0805dc10d5173f45836619c5a6095ccfa Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 16:45:41 +0100 Subject: [PATCH 17/30] Debug: why is mypy not reading config? --- .github/workflows/latest_deps.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 533fdb0b554d..954ea98a3910 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -48,6 +48,8 @@ jobs: - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager - run: poetry run pip freeze | tee after.txt - run: diff -u before.txt after.txt || true + - run: ls -alth + - run: cat mypy.ini - run: poetry run mypy trial: runs-on: ubuntu-latest From 71ab57415523d4177463a9272cb22c2eb40362e6 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 16:54:38 +0100 Subject: [PATCH 18/30] Back to export --- .github/workflows/latest_deps.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 954ea98a3910..08188ebe72ea 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -41,15 +41,17 @@ jobs: - run: poetry run pip freeze > before.txt # Upgrade all runtime dependencies only. This is intended to mimic a fresh # `pip install matrix-synapse[all]` as closely as possible. - # AFAICS this will update transitive dependencies. E.g. try - # pip install requests==2.24.0 idna==2.8 - # pip install --upgrade --upgrade-strategy eager requests - # The second command should update both requests and idna. - - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager + # Notes: + # - AFAICS this will update transitive dependencies. E.g. try + # pip install requests==2.24.0 idna==2.8 + # pip install --upgrade --upgrade-strategy eager requests + # The second command should update both `requests` and `idna`. + - run: >- + poetry export --extras all + | cut -d '=' -f1 + | xargs poetry run pip install --upgrade --upgrade-strategy eager - run: poetry run pip freeze | tee after.txt - run: diff -u before.txt after.txt || true - - run: ls -alth - - run: cat mypy.ini - run: poetry run mypy trial: runs-on: ubuntu-latest From 54e9dd68cf7e65cad94e515152d5dc85749d56cd Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 17:10:39 +0100 Subject: [PATCH 19/30] Another attempt --- .github/workflows/latest_deps.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 08188ebe72ea..9de87e4a9c99 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -38,20 +38,20 @@ jobs: with: python-version: "3.x" # Dump installed versions for debugging. - - run: poetry run pip freeze > before.txt - # Upgrade all runtime dependencies only. This is intended to mimic a fresh - # `pip install matrix-synapse[all]` as closely as possible. - # Notes: - # - AFAICS this will update transitive dependencies. E.g. try - # pip install requests==2.24.0 idna==2.8 - # pip install --upgrade --upgrade-strategy eager requests - # The second command should update both `requests` and `idna`. + - run: poetry run pip list > before.txt + # Work out which packages we want pip to upgrade. We use sed to strip out the + # version numbers from `poetry export`'s output. - run: >- - poetry export --extras all - | cut -d '=' -f1 - | xargs poetry run pip install --upgrade --upgrade-strategy eager - - run: poetry run pip freeze | tee after.txt + poetry export --extras all --without-hashes + | sed -Ee 's/^([^=]+)==[^;]+/\1/' + > requirements.txt + # Upgrade all runtime dependencies to their latest version. This is intended to + # mimic a fresh `pip install matrix-synapse[all]` as closely as possible. + - run: poetry run pip install --upgrade --upgrade-strategy eager -r requirements.txt + # Dump the changes for confirmation and debugging. + - run: poetry run pip list | tee after.txt - run: diff -u before.txt after.txt || true + # Now we can finally typecheck. - run: poetry run mypy trial: runs-on: ubuntu-latest From 522906c7af619e7a0e875fbf0960563fd2aa7288 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 17:21:59 +0100 Subject: [PATCH 20/30] No, we really should use `pip` because otherwise we're not going to get upper bounds and exclusions from pyproject.toml --- .github/workflows/latest_deps.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 9de87e4a9c99..a6199e29c0b0 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -39,19 +39,18 @@ jobs: python-version: "3.x" # Dump installed versions for debugging. - run: poetry run pip list > before.txt - # Work out which packages we want pip to upgrade. We use sed to strip out the - # version numbers from `poetry export`'s output. - - run: >- - poetry export --extras all --without-hashes - | sed -Ee 's/^([^=]+)==[^;]+/\1/' - > requirements.txt - # Upgrade all runtime dependencies to their latest version. This is intended to - # mimic a fresh `pip install matrix-synapse[all]` as closely as possible. - - run: poetry run pip install --upgrade --upgrade-strategy eager -r requirements.txt - # Dump the changes for confirmation and debugging. - - run: poetry run pip list | tee after.txt - - run: diff -u before.txt after.txt || true - # Now we can finally typecheck. + # Upgrade all runtime dependencies only. This is intended to mimic a fresh + # `pip install matrix-synapse[all]` as closely as possible. + # AFAICS this will update transitive dependencies. E.g. try + # pip install requests==2.24.0 idna==2.8 + # pip install --upgrade --upgrade-strategy eager requests + # The second command should update both requests and idna. + - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager + # Doing the above makes mypy not process its list of ignores for some reason. + # I think this is because the above does a normal install of matrix-synapse rather + # than an editable install. We workaround this by uninstalling matrix-synapse. + - run: poetry run pip uninstall matrix-synapse + - run: poetry run pip list > after.txt && (diff -u before.txt after.txt || true) - run: poetry run mypy trial: runs-on: ubuntu-latest From 0c22165bd3f7cab8fb1d1f6d886c05eb04a4dddb Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 17:25:36 +0100 Subject: [PATCH 21/30] Confirm uninstall --- .github/workflows/latest_deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index a6199e29c0b0..c818e7e4b486 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -49,7 +49,7 @@ jobs: # Doing the above makes mypy not process its list of ignores for some reason. # I think this is because the above does a normal install of matrix-synapse rather # than an editable install. We workaround this by uninstalling matrix-synapse. - - run: poetry run pip uninstall matrix-synapse + - run: poetry run pip uninstall -y matrix-synapse - run: poetry run pip list > after.txt && (diff -u before.txt after.txt || true) - run: poetry run mypy trial: From 9d1ead3456f1c5a36809e1886035677c01ced7c6 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 18:08:23 +0100 Subject: [PATCH 22/30] Try just using poetry --- .github/workflows/latest_deps.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index c818e7e4b486..44835aa83cf6 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -41,15 +41,7 @@ jobs: - run: poetry run pip list > before.txt # Upgrade all runtime dependencies only. This is intended to mimic a fresh # `pip install matrix-synapse[all]` as closely as possible. - # AFAICS this will update transitive dependencies. E.g. try - # pip install requests==2.24.0 idna==2.8 - # pip install --upgrade --upgrade-strategy eager requests - # The second command should update both requests and idna. - - run: poetry run pip install .[all] --upgrade --upgrade-strategy eager - # Doing the above makes mypy not process its list of ignores for some reason. - # I think this is because the above does a normal install of matrix-synapse rather - # than an editable install. We workaround this by uninstalling matrix-synapse. - - run: poetry run pip uninstall -y matrix-synapse + - run: poetry update --no-dev - run: poetry run pip list > after.txt && (diff -u before.txt after.txt || true) - run: poetry run mypy trial: From c841847429fc08d91260fae484e8c291dffc4878 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 19:17:59 +0100 Subject: [PATCH 23/30] try beta poetry --- .github/workflows/latest_deps.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 44835aa83cf6..5091402a9c8f 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -37,6 +37,7 @@ jobs: - uses: matrix-org/setup-python-poetry@v1 with: python-version: "3.x" + poetry-version: "1.2.0b1" # Dump installed versions for debugging. - run: poetry run pip list > before.txt # Upgrade all runtime dependencies only. This is intended to mimic a fresh From 715fb1be8b1dc4556347b06e6f56806d97f3a910 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 19:33:13 +0100 Subject: [PATCH 24/30] Update comment --- .github/workflows/latest_deps.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 5091402a9c8f..21d5f0057b44 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -32,8 +32,7 @@ jobs: steps: - uses: actions/checkout@v2 # The dev dependencies aren't exposed in the wheel metadata (at least with current - # poetry-core versions). So we'll have to be dirty: `poetry install` to get the - # dev deps, then upgrade them in situ with pip. + # poetry-core versions), so we install with poetry. - uses: matrix-org/setup-python-poetry@v1 with: python-version: "3.x" From d0819a934b6593aac2ac49b19387135ad816bf7f Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 19:43:23 +0100 Subject: [PATCH 25/30] Typo fix Co-authored-by: Patrick Cloke --- .github/workflows/latest_deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 21d5f0057b44..541f815efbba 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -115,7 +115,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Ensure systest runs `pip install` + - name: Ensure sytest runs `pip install` # Delete the lockfile so sytest will `pip install` rather than `poetry install` run: rm /src/poetry.lock working-directory: /src From 54d368c7feb7117b5a348fc6206c58ebfd5d1708 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 20:08:12 +0100 Subject: [PATCH 26/30] Try `trial` without installing in editable mode --- .github/workflows/latest_deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 541f815efbba..dc95ac2a8968 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -66,7 +66,7 @@ jobs: - uses: actions/setup-python@v2 with: python-version: "3.x" - - run: pip install -e .[all,test] + - run: pip install .[all,test] - name: Await PostgreSQL if: ${{ matrix.postgres-version }} timeout-minutes: 2 From 0b57eb9e22866100a8dab73599595457605e64fe Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 20:11:51 +0100 Subject: [PATCH 27/30] Another attempt at trial --- .github/workflows/latest_deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index dc95ac2a8968..7382cbf120c2 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -71,7 +71,7 @@ jobs: if: ${{ matrix.postgres-version }} timeout-minutes: 2 run: until pg_isready -h localhost; do sleep 1; done - - run: trial --jobs=2 tests + - run: python -m trial --jobs=2 tests env: SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }} SYNAPSE_POSTGRES_HOST: localhost From 81b98b343445d3afea2109875087fcc101d2e837 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Apr 2022 20:14:12 +0100 Subject: [PATCH 28/30] Third attempt at trial --- .github/workflows/latest_deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 7382cbf120c2..5ac9e9437e39 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -71,7 +71,7 @@ jobs: if: ${{ matrix.postgres-version }} timeout-minutes: 2 run: until pg_isready -h localhost; do sleep 1; done - - run: python -m trial --jobs=2 tests + - run: python -m twisted.trial --jobs=2 tests env: SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }} SYNAPSE_POSTGRES_HOST: localhost From 36ef3c2c20ab3e098eee0d010b26751f54775f2b Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 20 Apr 2022 11:53:18 +0100 Subject: [PATCH 29/30] Update job description comment Co-authored-by: Patrick Cloke --- .github/workflows/latest_deps.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index 5ac9e9437e39..fbf35917ab0e 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -1,13 +1,12 @@ -# People who are freshly `pip install`ing from PyPI will pull in the latest versions of all -# dependencies. Since most CI runs are against the locked poetry environment, run -# specifically against the latest dependencies to know if there's an upcoming breaking -# change. +# People who are freshly `pip install`ing from PyPI will pull in the latest versions of +# dependencies which match the broad requirements. Since most CI runs are against +# the locked poetry environment, run specifically against the latest dependencies to +# know if there's an upcoming breaking change. # -# To plug that hole, this job is a canary which periodically +# As an overview this workflow: # - checks out develop, -# - pip installs from source (building a wheel locally using `poetry-core`, -# and `pip install`ing from that), and -# - runs test suites against that checkout. +# - installs from source, pulling in the dependencies like a fresh `pip install` would, and +# - runs mypy and test suites in that checkout. # # Based on the twisted trunk CI job. From b2f6da20bc01cbcbedf6bfe1da435a5ed0f7c6c3 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 20 Apr 2022 11:53:55 +0100 Subject: [PATCH 30/30] Enable the issue-raiser; remove debug Co-authored-by: Patrick Cloke --- .github/workflows/latest_deps.yml | 41 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/.github/workflows/latest_deps.yml b/.github/workflows/latest_deps.yml index fbf35917ab0e..1a61d179d905 100644 --- a/.github/workflows/latest_deps.yml +++ b/.github/workflows/latest_deps.yml @@ -15,10 +15,6 @@ name: Latest dependencies on: schedule: - cron: 0 7 * * * - pull_request: - branches: [dmr/poetry-wheel-ci] - push: - branches: [dmr/poetry-wheel-ci] workflow_dispatch: concurrency: @@ -139,21 +135,22 @@ jobs: # TODO: run complement (as with twisted trunk, see #12473). # open an issue if the build fails, so we know about it. -# open-issue: -# if: failure() -# needs: -# # TODO: should mypy be included here? It feels more brittle than the other two. -# - mypy -# - trial -# - sytest -# -# runs-on: ubuntu-latest -# -# steps: -# - uses: actions/checkout@v2 -# - uses: JasonEtco/create-an-issue@5d9504915f79f9cc6d791934b8ef34f2353dd74d # v2.5.0, 2020-12-06 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# update_existing: true -# filename: .ci/latest_deps_build_failed_issue_template.md + open-issue: + if: failure() + needs: + # TODO: should mypy be included here? It feels more brittle than the other two. + - mypy + - trial + - sytest + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: JasonEtco/create-an-issue@5d9504915f79f9cc6d791934b8ef34f2353dd74d # v2.5.0, 2020-12-06 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + update_existing: true + filename: .ci/latest_deps_build_failed_issue_template.md +