|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["develop", "release-*"] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + lint: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + toxenv: |
| 14 | + - "check-sampleconfig" |
| 15 | + - "check_codestyle" |
| 16 | + - "check_isort" |
| 17 | + - "mypy" |
| 18 | + - "packaging" |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v2 |
| 22 | + - uses: actions/setup-python@v2 |
| 23 | + - run: pip install tox |
| 24 | + - run: tox -e ${{ matrix.toxenv }} |
| 25 | + |
| 26 | + lint-crlf: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v2 |
| 30 | + - name: Check line endings |
| 31 | + run: scripts-dev/check_line_terminators.sh |
| 32 | + |
| 33 | + lint-newsfile: |
| 34 | + if: ${{ github.base_ref == 'develop' || contains(github.base_ref, 'release-') }} |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v2 |
| 38 | + - uses: actions/setup-python@v2 |
| 39 | + - run: pip install tox |
| 40 | + - name: Patch Buildkite-specific test script |
| 41 | + run: | |
| 42 | + sed -i -e 's/\$BUILDKITE_PULL_REQUEST/${{ github.event.number }}/' \ |
| 43 | + scripts-dev/check-newsfragment |
| 44 | + - run: scripts-dev/check-newsfragment |
| 45 | + |
| 46 | + lint-sdist: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v2 |
| 50 | + - uses: actions/setup-python@v2 |
| 51 | + with: |
| 52 | + python-version: "3.x" |
| 53 | + - run: pip install wheel |
| 54 | + - run: python setup.py sdist bdist_wheel |
| 55 | + - uses: actions/upload-artifact@v2 |
| 56 | + with: |
| 57 | + name: Python Distributions |
| 58 | + path: dist/* |
| 59 | + |
| 60 | + # Dummy step to gate other tests on without repeating the whole list |
| 61 | + linting-done: |
| 62 | + if: ${{ always() }} # Run this even if prior jobs were skipped |
| 63 | + needs: [lint, lint-crlf, lint-newsfile, lint-sdist] |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - run: "true" |
| 67 | + |
| 68 | + trial: |
| 69 | + if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail |
| 70 | + needs: linting-done |
| 71 | + runs-on: ubuntu-latest |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + python-version: ["3.6", "3.7", "3.8", "3.9"] |
| 75 | + database: ["sqlite"] |
| 76 | + include: |
| 77 | + # Newest Python without optional deps |
| 78 | + - python-version: "3.9" |
| 79 | + toxenv: "py-noextras,combine" |
| 80 | + |
| 81 | + # Oldest Python with PostgreSQL |
| 82 | + - python-version: "3.6" |
| 83 | + database: "postgres" |
| 84 | + postgres-version: "9.6" |
| 85 | + |
| 86 | + # Newest Python with PostgreSQL |
| 87 | + - python-version: "3.9" |
| 88 | + database: "postgres" |
| 89 | + postgres-version: "13" |
| 90 | + |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v2 |
| 93 | + - run: sudo apt-get -qq install xmlsec1 |
| 94 | + - name: Set up PostgreSQL ${{ matrix.postgres-version }} |
| 95 | + if: ${{ matrix.postgres-version }} |
| 96 | + run: | |
| 97 | + docker run -d -p 5432:5432 \ |
| 98 | + -e POSTGRES_PASSWORD=postgres \ |
| 99 | + -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \ |
| 100 | + postgres:${{ matrix.postgres-version }} |
| 101 | + - uses: actions/setup-python@v2 |
| 102 | + with: |
| 103 | + python-version: ${{ matrix.python-version }} |
| 104 | + - run: pip install tox |
| 105 | + - name: Await PostgreSQL |
| 106 | + if: ${{ matrix.postgres-version }} |
| 107 | + timeout-minutes: 2 |
| 108 | + run: until pg_isready -h localhost; do sleep 1; done |
| 109 | + - run: tox -e py,combine |
| 110 | + env: |
| 111 | + TRIAL_FLAGS: "--jobs=2" |
| 112 | + SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }} |
| 113 | + SYNAPSE_POSTGRES_HOST: localhost |
| 114 | + SYNAPSE_POSTGRES_USER: postgres |
| 115 | + SYNAPSE_POSTGRES_PASSWORD: postgres |
| 116 | + - name: Dump logs |
| 117 | + # Note: Dumps to workflow logs instead of using actions/upload-artifact |
| 118 | + # This keeps logs colocated with failing jobs |
| 119 | + # It also ignores find's exit code; this is a best effort affair |
| 120 | + run: >- |
| 121 | + find _trial_temp -name '*.log' |
| 122 | + -exec echo "::group::{}" \; |
| 123 | + -exec cat {} \; |
| 124 | + -exec echo "::endgroup::" \; |
| 125 | + || true |
| 126 | +
|
| 127 | + trial-olddeps: |
| 128 | + if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail |
| 129 | + needs: linting-done |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v2 |
| 133 | + - name: Test with old deps |
| 134 | + uses: docker://ubuntu:bionic # For old python and sqlite |
| 135 | + with: |
| 136 | + workdir: /github/workspace |
| 137 | + entrypoint: .buildkite/scripts/test_old_deps.sh |
| 138 | + env: |
| 139 | + TRIAL_FLAGS: "--jobs=2" |
| 140 | + - name: Dump logs |
| 141 | + # Note: Dumps to workflow logs instead of using actions/upload-artifact |
| 142 | + # This keeps logs colocated with failing jobs |
| 143 | + # It also ignores find's exit code; this is a best effort affair |
| 144 | + run: >- |
| 145 | + find _trial_temp -name '*.log' |
| 146 | + -exec echo "::group::{}" \; |
| 147 | + -exec cat {} \; |
| 148 | + -exec echo "::endgroup::" \; |
| 149 | + || true |
| 150 | +
|
| 151 | + trial-pypy: |
| 152 | + # Very slow; only run if the branch name includes 'pypy' |
| 153 | + if: ${{ contains(github.ref, 'pypy') && !failure() }} |
| 154 | + needs: linting-done |
| 155 | + runs-on: ubuntu-latest |
| 156 | + strategy: |
| 157 | + matrix: |
| 158 | + python-version: ["pypy-3.6"] |
| 159 | + |
| 160 | + steps: |
| 161 | + - uses: actions/checkout@v2 |
| 162 | + - run: sudo apt-get -qq install xmlsec1 libxml2-dev libxslt-dev |
| 163 | + - uses: actions/setup-python@v2 |
| 164 | + with: |
| 165 | + python-version: ${{ matrix.python-version }} |
| 166 | + - run: pip install tox |
| 167 | + - run: tox -e py,combine |
| 168 | + env: |
| 169 | + TRIAL_FLAGS: "--jobs=2" |
| 170 | + - name: Dump logs |
| 171 | + # Note: Dumps to workflow logs instead of using actions/upload-artifact |
| 172 | + # This keeps logs colocated with failing jobs |
| 173 | + # It also ignores find's exit code; this is a best effort affair |
| 174 | + run: >- |
| 175 | + find _trial_temp -name '*.log' |
| 176 | + -exec echo "::group::{}" \; |
| 177 | + -exec cat {} \; |
| 178 | + -exec echo "::endgroup::" \; |
| 179 | + || true |
| 180 | +
|
| 181 | + sytest: |
| 182 | + if: ${{ !failure() }} |
| 183 | + needs: linting-done |
| 184 | + runs-on: ubuntu-latest |
| 185 | + container: |
| 186 | + image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }} |
| 187 | + volumes: |
| 188 | + - ${{ github.workspace }}:/src |
| 189 | + env: |
| 190 | + BUILDKITE_BRANCH: ${{ github.head_ref }} |
| 191 | + POSTGRES: ${{ matrix.postgres && 1}} |
| 192 | + MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}} |
| 193 | + WORKERS: ${{ matrix.workers && 1 }} |
| 194 | + REDIS: ${{ matrix.redis && 1 }} |
| 195 | + BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }} |
| 196 | + |
| 197 | + strategy: |
| 198 | + fail-fast: false |
| 199 | + matrix: |
| 200 | + include: |
| 201 | + - sytest-tag: bionic |
| 202 | + |
| 203 | + - sytest-tag: bionic |
| 204 | + postgres: postgres |
| 205 | + |
| 206 | + - sytest-tag: testing |
| 207 | + postgres: postgres |
| 208 | + |
| 209 | + - sytest-tag: bionic |
| 210 | + postgres: multi-postgres |
| 211 | + workers: workers |
| 212 | + |
| 213 | + - sytest-tag: buster |
| 214 | + postgres: multi-postgres |
| 215 | + workers: workers |
| 216 | + |
| 217 | + - sytest-tag: buster |
| 218 | + postgres: postgres |
| 219 | + workers: workers |
| 220 | + redis: redis |
| 221 | + |
| 222 | + steps: |
| 223 | + - uses: actions/checkout@v2 |
| 224 | + - name: Prepare test blacklist |
| 225 | + run: cat sytest-blacklist .buildkite/worker-blacklist > synapse-blacklist-with-workers |
| 226 | + - name: Run SyTest |
| 227 | + run: /bootstrap.sh synapse |
| 228 | + working-directory: /src |
| 229 | + - name: Dump results.tap |
| 230 | + if: ${{ always() }} |
| 231 | + run: cat /logs/results.tap |
| 232 | + - name: Upload SyTest logs |
| 233 | + uses: actions/upload-artifact@v2 |
| 234 | + if: ${{ always() }} |
| 235 | + with: |
| 236 | + name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }}) |
| 237 | + path: | |
| 238 | + /logs/results.tap |
| 239 | + /logs/**/*.log* |
| 240 | +
|
| 241 | + portdb: |
| 242 | + if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail |
| 243 | + needs: linting-done |
| 244 | + runs-on: ubuntu-latest |
| 245 | + strategy: |
| 246 | + matrix: |
| 247 | + include: |
| 248 | + - python-version: "3.6" |
| 249 | + postgres-version: "9.6" |
| 250 | + |
| 251 | + - python-version: "3.9" |
| 252 | + postgres-version: "13" |
| 253 | + |
| 254 | + services: |
| 255 | + postgres: |
| 256 | + image: postgres:${{ matrix.postgres-version }} |
| 257 | + ports: |
| 258 | + - 5432:5432 |
| 259 | + env: |
| 260 | + POSTGRES_PASSWORD: "postgres" |
| 261 | + POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8" |
| 262 | + options: >- |
| 263 | + --health-cmd pg_isready |
| 264 | + --health-interval 10s |
| 265 | + --health-timeout 5s |
| 266 | + --health-retries 5 |
| 267 | +
|
| 268 | + steps: |
| 269 | + - uses: actions/checkout@v2 |
| 270 | + - run: sudo apt-get -qq install xmlsec1 |
| 271 | + - uses: actions/setup-python@v2 |
| 272 | + with: |
| 273 | + python-version: ${{ matrix.python-version }} |
| 274 | + - name: Patch Buildkite-specific test scripts |
| 275 | + run: | |
| 276 | + sed -i -e 's/host="postgres"/host="localhost"/' .buildkite/scripts/create_postgres_db.py |
| 277 | + sed -i -e 's/host: postgres/host: localhost/' .buildkite/postgres-config.yaml |
| 278 | + sed -i -e 's|/src/||' .buildkite/{sqlite,postgres}-config.yaml |
| 279 | + sed -i -e 's/\$TOP/\$GITHUB_WORKSPACE/' .coveragerc |
| 280 | + - run: .buildkite/scripts/test_synapse_port_db.sh |
| 281 | + |
| 282 | + complement: |
| 283 | + if: ${{ !failure() }} |
| 284 | + needs: linting-done |
| 285 | + runs-on: ubuntu-latest |
| 286 | + container: |
| 287 | + # https://github.com/matrix-org/complement/blob/master/dockerfiles/ComplementCIBuildkite.Dockerfile |
| 288 | + image: matrixdotorg/complement:latest |
| 289 | + env: |
| 290 | + CI: true |
| 291 | + ports: |
| 292 | + - 8448:8448 |
| 293 | + volumes: |
| 294 | + - /var/run/docker.sock:/var/run/docker.sock |
| 295 | + |
| 296 | + steps: |
| 297 | + - name: Run actions/checkout@v2 for synapse |
| 298 | + uses: actions/checkout@v2 |
| 299 | + with: |
| 300 | + path: synapse |
| 301 | + |
| 302 | + - name: Run actions/checkout@v2 for complement |
| 303 | + uses: actions/checkout@v2 |
| 304 | + with: |
| 305 | + repository: "matrix-org/complement" |
| 306 | + path: complement |
| 307 | + |
| 308 | + # Build initial Synapse image |
| 309 | + - run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile . |
| 310 | + working-directory: synapse |
| 311 | + |
| 312 | + # Build a ready-to-run Synapse image based on the initial image above. |
| 313 | + # This new image includes a config file, keys for signing and TLS, and |
| 314 | + # other settings to make it suitable for testing under Complement. |
| 315 | + - run: docker build -t complement-synapse -f Synapse.Dockerfile . |
| 316 | + working-directory: complement/dockerfiles |
| 317 | + |
| 318 | + # Run Complement |
| 319 | + - run: go test -v -tags synapse_blacklist ./tests |
| 320 | + env: |
| 321 | + COMPLEMENT_BASE_IMAGE: complement-synapse:latest |
| 322 | + working-directory: complement |
0 commit comments