|
| 1 | +# People who are freshly `pip install`ing from PyPI will pull in the latest versions of |
| 2 | +# dependencies which match the broad requirements. Since most CI runs are against |
| 3 | +# the locked poetry environment, run specifically against the latest dependencies to |
| 4 | +# know if there's an upcoming breaking change. |
| 5 | +# |
| 6 | +# As an overview this workflow: |
| 7 | +# - checks out develop, |
| 8 | +# - installs from source, pulling in the dependencies like a fresh `pip install` would, and |
| 9 | +# - runs mypy and test suites in that checkout. |
| 10 | +# |
| 11 | +# Based on the twisted trunk CI job. |
| 12 | + |
| 13 | +name: Latest dependencies |
| 14 | + |
| 15 | +on: |
| 16 | + schedule: |
| 17 | + - cron: 0 7 * * * |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + mypy: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + # The dev dependencies aren't exposed in the wheel metadata (at least with current |
| 30 | + # poetry-core versions), so we install with poetry. |
| 31 | + - uses: matrix-org/setup-python-poetry@v1 |
| 32 | + with: |
| 33 | + python-version: "3.x" |
| 34 | + poetry-version: "1.2.0b1" |
| 35 | + # Dump installed versions for debugging. |
| 36 | + - run: poetry run pip list > before.txt |
| 37 | + # Upgrade all runtime dependencies only. This is intended to mimic a fresh |
| 38 | + # `pip install matrix-synapse[all]` as closely as possible. |
| 39 | + - run: poetry update --no-dev |
| 40 | + - run: poetry run pip list > after.txt && (diff -u before.txt after.txt || true) |
| 41 | + - run: poetry run mypy |
| 42 | + trial: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + include: |
| 47 | + - database: "sqlite" |
| 48 | + - database: "postgres" |
| 49 | + postgres-version: "14" |
| 50 | + |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v2 |
| 53 | + - run: sudo apt-get -qq install xmlsec1 |
| 54 | + - name: Set up PostgreSQL ${{ matrix.postgres-version }} |
| 55 | + if: ${{ matrix.postgres-version }} |
| 56 | + run: | |
| 57 | + docker run -d -p 5432:5432 \ |
| 58 | + -e POSTGRES_PASSWORD=postgres \ |
| 59 | + -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \ |
| 60 | + postgres:${{ matrix.postgres-version }} |
| 61 | + - uses: actions/setup-python@v2 |
| 62 | + with: |
| 63 | + python-version: "3.x" |
| 64 | + - run: pip install .[all,test] |
| 65 | + - name: Await PostgreSQL |
| 66 | + if: ${{ matrix.postgres-version }} |
| 67 | + timeout-minutes: 2 |
| 68 | + run: until pg_isready -h localhost; do sleep 1; done |
| 69 | + - run: python -m twisted.trial --jobs=2 tests |
| 70 | + env: |
| 71 | + SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }} |
| 72 | + SYNAPSE_POSTGRES_HOST: localhost |
| 73 | + SYNAPSE_POSTGRES_USER: postgres |
| 74 | + SYNAPSE_POSTGRES_PASSWORD: postgres |
| 75 | + - name: Dump logs |
| 76 | + # Logs are most useful when the command fails, always include them. |
| 77 | + if: ${{ always() }} |
| 78 | + # Note: Dumps to workflow logs instead of using actions/upload-artifact |
| 79 | + # This keeps logs colocated with failing jobs |
| 80 | + # It also ignores find's exit code; this is a best effort affair |
| 81 | + run: >- |
| 82 | + find _trial_temp -name '*.log' |
| 83 | + -exec echo "::group::{}" \; |
| 84 | + -exec cat {} \; |
| 85 | + -exec echo "::endgroup::" \; |
| 86 | + || true |
| 87 | +
|
| 88 | +
|
| 89 | + sytest: |
| 90 | + runs-on: ubuntu-latest |
| 91 | + container: |
| 92 | + image: matrixdotorg/sytest-synapse:testing |
| 93 | + volumes: |
| 94 | + - ${{ github.workspace }}:/src |
| 95 | + strategy: |
| 96 | + fail-fast: false |
| 97 | + matrix: |
| 98 | + include: |
| 99 | + - sytest-tag: focal |
| 100 | + |
| 101 | + - sytest-tag: focal |
| 102 | + postgres: postgres |
| 103 | + workers: workers |
| 104 | + redis: redis |
| 105 | + env: |
| 106 | + POSTGRES: ${{ matrix.postgres && 1}} |
| 107 | + WORKERS: ${{ matrix.workers && 1 }} |
| 108 | + REDIS: ${{ matrix.redis && 1 }} |
| 109 | + BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }} |
| 110 | + |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v2 |
| 113 | + - name: Ensure sytest runs `pip install` |
| 114 | + # Delete the lockfile so sytest will `pip install` rather than `poetry install` |
| 115 | + run: rm /src/poetry.lock |
| 116 | + working-directory: /src |
| 117 | + - name: Prepare test blacklist |
| 118 | + run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers |
| 119 | + - name: Run SyTest |
| 120 | + run: /bootstrap.sh synapse |
| 121 | + working-directory: /src |
| 122 | + - name: Summarise results.tap |
| 123 | + if: ${{ always() }} |
| 124 | + run: /sytest/scripts/tap_to_gha.pl /logs/results.tap |
| 125 | + - name: Upload SyTest logs |
| 126 | + uses: actions/upload-artifact@v2 |
| 127 | + if: ${{ always() }} |
| 128 | + with: |
| 129 | + name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }}) |
| 130 | + path: | |
| 131 | + /logs/results.tap |
| 132 | + /logs/**/*.log* |
| 133 | +
|
| 134 | +
|
| 135 | + # TODO: run complement (as with twisted trunk, see #12473). |
| 136 | + |
| 137 | + # open an issue if the build fails, so we know about it. |
| 138 | + open-issue: |
| 139 | + if: failure() |
| 140 | + needs: |
| 141 | + # TODO: should mypy be included here? It feels more brittle than the other two. |
| 142 | + - mypy |
| 143 | + - trial |
| 144 | + - sytest |
| 145 | + |
| 146 | + runs-on: ubuntu-latest |
| 147 | + |
| 148 | + steps: |
| 149 | + - uses: actions/checkout@v2 |
| 150 | + - uses: JasonEtco/create-an-issue@5d9504915f79f9cc6d791934b8ef34f2353dd74d # v2.5.0, 2020-12-06 |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + with: |
| 154 | + update_existing: true |
| 155 | + filename: .ci/latest_deps_build_failed_issue_template.md |
| 156 | + |
0 commit comments