2021-04-09 05:54:30 -04:00
|
|
|
name: Tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: ["develop", "release-*"]
|
|
|
|
pull_request:
|
|
|
|
|
2021-07-22 06:35:06 -04:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2021-08-05 06:22:27 -04:00
|
|
|
|
2021-04-09 05:54:30 -04:00
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
toxenv:
|
|
|
|
- "check-sampleconfig"
|
|
|
|
- "check_codestyle"
|
|
|
|
- "check_isort"
|
|
|
|
- "mypy"
|
|
|
|
- "packaging"
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
- run: pip install tox
|
|
|
|
- run: tox -e ${{ matrix.toxenv }}
|
|
|
|
|
|
|
|
lint-crlf:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Check line endings
|
|
|
|
run: scripts-dev/check_line_terminators.sh
|
|
|
|
|
|
|
|
lint-newsfile:
|
|
|
|
if: ${{ github.base_ref == 'develop' || contains(github.base_ref, 'release-') }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2021-05-26 09:14:43 -04:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
fetch-depth: 0
|
2021-04-09 05:54:30 -04:00
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
- run: pip install tox
|
|
|
|
- run: scripts-dev/check-newsfragment
|
2021-08-10 07:15:10 -04:00
|
|
|
env:
|
|
|
|
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
lint-sdist:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: "3.x"
|
|
|
|
- run: pip install wheel
|
|
|
|
- run: python setup.py sdist bdist_wheel
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: Python Distributions
|
|
|
|
path: dist/*
|
|
|
|
|
|
|
|
# Dummy step to gate other tests on without repeating the whole list
|
|
|
|
linting-done:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !cancelled() }} # Run this even if prior jobs were skipped
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: [lint, lint-crlf, lint-newsfile, lint-sdist]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- run: "true"
|
|
|
|
|
|
|
|
trial:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-12-21 14:37:04 -05:00
|
|
|
python-version: ["3.7", "3.8", "3.9", "3.10"]
|
2021-04-09 05:54:30 -04:00
|
|
|
database: ["sqlite"]
|
2021-10-08 05:05:48 -04:00
|
|
|
toxenv: ["py"]
|
2021-04-09 05:54:30 -04:00
|
|
|
include:
|
|
|
|
# Newest Python without optional deps
|
2021-10-05 07:43:04 -04:00
|
|
|
- python-version: "3.10"
|
2021-10-08 05:05:48 -04:00
|
|
|
toxenv: "py-noextras"
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
# Oldest Python with PostgreSQL
|
2021-12-21 14:37:04 -05:00
|
|
|
- python-version: "3.7"
|
2021-04-09 05:54:30 -04:00
|
|
|
database: "postgres"
|
2021-12-21 14:37:04 -05:00
|
|
|
postgres-version: "10"
|
2021-10-08 05:05:48 -04:00
|
|
|
toxenv: "py"
|
2021-04-09 05:54:30 -04:00
|
|
|
|
2021-10-05 07:43:04 -04:00
|
|
|
# Newest Python with newest PostgreSQL
|
|
|
|
- python-version: "3.10"
|
2021-04-09 05:54:30 -04:00
|
|
|
database: "postgres"
|
2021-10-05 07:43:04 -04:00
|
|
|
postgres-version: "14"
|
2021-10-08 05:05:48 -04:00
|
|
|
toxenv: "py"
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
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: ${{ matrix.python-version }}
|
|
|
|
- run: pip install tox
|
|
|
|
- name: Await PostgreSQL
|
|
|
|
if: ${{ matrix.postgres-version }}
|
|
|
|
timeout-minutes: 2
|
|
|
|
run: until pg_isready -h localhost; do sleep 1; done
|
2021-10-08 05:05:48 -04:00
|
|
|
- run: tox -e ${{ matrix.toxenv }}
|
2021-04-09 05:54:30 -04:00
|
|
|
env:
|
|
|
|
TRIAL_FLAGS: "--jobs=2"
|
|
|
|
SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || '' }}
|
|
|
|
SYNAPSE_POSTGRES_HOST: localhost
|
|
|
|
SYNAPSE_POSTGRES_USER: postgres
|
|
|
|
SYNAPSE_POSTGRES_PASSWORD: postgres
|
|
|
|
- name: Dump logs
|
2021-10-12 16:09:49 -04:00
|
|
|
# Logs are most useful when the command fails, always include them.
|
|
|
|
if: ${{ always() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
# 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
|
|
|
|
|
|
|
|
trial-olddeps:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Test with old deps
|
|
|
|
uses: docker://ubuntu:bionic # For old python and sqlite
|
|
|
|
with:
|
|
|
|
workdir: /github/workspace
|
2021-08-11 14:59:57 -04:00
|
|
|
entrypoint: .ci/scripts/test_old_deps.sh
|
2021-04-09 05:54:30 -04:00
|
|
|
env:
|
|
|
|
TRIAL_FLAGS: "--jobs=2"
|
|
|
|
- name: Dump logs
|
2021-10-12 16:09:49 -04:00
|
|
|
# Logs are most useful when the command fails, always include them.
|
|
|
|
if: ${{ always() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
# 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
|
|
|
|
|
|
|
|
trial-pypy:
|
|
|
|
# Very slow; only run if the branch name includes 'pypy'
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ contains(github.ref, 'pypy') && !failure() && !cancelled() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-12-21 14:37:04 -05:00
|
|
|
python-version: ["pypy-3.7"]
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- run: sudo apt-get -qq install xmlsec1 libxml2-dev libxslt-dev
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- run: pip install tox
|
2021-10-08 05:05:48 -04:00
|
|
|
- run: tox -e py
|
2021-04-09 05:54:30 -04:00
|
|
|
env:
|
|
|
|
TRIAL_FLAGS: "--jobs=2"
|
|
|
|
- name: Dump logs
|
2021-10-12 16:09:49 -04:00
|
|
|
# Logs are most useful when the command fails, always include them.
|
|
|
|
if: ${{ always() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
# 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:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !failure() && !cancelled() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }}
|
|
|
|
volumes:
|
|
|
|
- ${{ github.workspace }}:/src
|
|
|
|
env:
|
2021-09-20 12:35:16 -04:00
|
|
|
SYTEST_BRANCH: ${{ github.head_ref }}
|
2021-04-09 05:54:30 -04:00
|
|
|
POSTGRES: ${{ matrix.postgres && 1}}
|
|
|
|
MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}}
|
|
|
|
WORKERS: ${{ matrix.workers && 1 }}
|
|
|
|
REDIS: ${{ matrix.redis && 1 }}
|
|
|
|
BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }}
|
2021-08-11 15:08:48 -04:00
|
|
|
TOP: ${{ github.workspace }}
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- sytest-tag: bionic
|
|
|
|
|
|
|
|
- sytest-tag: bionic
|
|
|
|
postgres: postgres
|
|
|
|
|
|
|
|
- sytest-tag: testing
|
|
|
|
postgres: postgres
|
|
|
|
|
|
|
|
- sytest-tag: bionic
|
|
|
|
postgres: multi-postgres
|
|
|
|
workers: workers
|
|
|
|
|
|
|
|
- sytest-tag: buster
|
|
|
|
postgres: multi-postgres
|
|
|
|
workers: workers
|
|
|
|
|
|
|
|
- sytest-tag: buster
|
|
|
|
postgres: postgres
|
|
|
|
workers: workers
|
|
|
|
redis: redis
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Prepare test blacklist
|
2021-08-11 14:59:57 -04:00
|
|
|
run: cat sytest-blacklist .ci/worker-blacklist > synapse-blacklist-with-workers
|
2021-04-09 05:54:30 -04:00
|
|
|
- name: Run SyTest
|
|
|
|
run: /bootstrap.sh synapse
|
|
|
|
working-directory: /src
|
2021-06-02 12:10:37 -04:00
|
|
|
- name: Summarise results.tap
|
2021-04-09 05:54:30 -04:00
|
|
|
if: ${{ always() }}
|
2021-06-02 12:10:37 -04:00
|
|
|
run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
|
2021-04-09 05:54:30 -04:00
|
|
|
- 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*
|
|
|
|
|
2021-10-18 11:14:12 -04:00
|
|
|
export-data:
|
|
|
|
if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
|
|
|
|
needs: [linting-done, portdb]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
TOP: ${{ github.workspace }}
|
|
|
|
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
env:
|
|
|
|
POSTGRES_PASSWORD: "postgres"
|
|
|
|
POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- run: sudo apt-get -qq install xmlsec1
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: "3.9"
|
|
|
|
- run: .ci/scripts/test_export_data_command.sh
|
|
|
|
|
2021-04-09 05:54:30 -04:00
|
|
|
portdb:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !failure() && !cancelled() }} # Allow previous steps to be skipped, but not fail
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
2021-08-12 05:41:01 -04:00
|
|
|
env:
|
|
|
|
TOP: ${{ github.workspace }}
|
2021-04-09 05:54:30 -04:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
2021-12-21 14:37:04 -05:00
|
|
|
- python-version: "3.7"
|
|
|
|
postgres-version: "10"
|
2021-04-09 05:54:30 -04:00
|
|
|
|
2021-10-05 07:43:04 -04:00
|
|
|
- python-version: "3.10"
|
|
|
|
postgres-version: "14"
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres:${{ matrix.postgres-version }}
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
env:
|
|
|
|
POSTGRES_PASSWORD: "postgres"
|
|
|
|
POSTGRES_INITDB_ARGS: "--lc-collate C --lc-ctype C --encoding UTF8"
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- run: sudo apt-get -qq install xmlsec1
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2021-08-11 14:59:57 -04:00
|
|
|
- run: .ci/scripts/test_synapse_port_db.sh
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
complement:
|
2021-07-14 09:41:23 -04:00
|
|
|
if: ${{ !failure() && !cancelled() }}
|
2021-04-09 05:54:30 -04:00
|
|
|
needs: linting-done
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
# https://github.com/matrix-org/complement/blob/master/dockerfiles/ComplementCIBuildkite.Dockerfile
|
|
|
|
image: matrixdotorg/complement:latest
|
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
ports:
|
|
|
|
- 8448:8448
|
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Run actions/checkout@v2 for synapse
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
path: synapse
|
|
|
|
|
2021-06-11 08:17:17 -04:00
|
|
|
# Attempt to check out the same branch of Complement as the PR. If it
|
|
|
|
# doesn't exist, fallback to master.
|
|
|
|
- name: Checkout complement
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
mkdir -p complement
|
|
|
|
# Attempt to use the version of complement which best matches the current
|
|
|
|
# build. Depending on whether this is a PR or release, etc. we need to
|
|
|
|
# use different fallbacks.
|
|
|
|
#
|
|
|
|
# 1. First check if there's a similarly named branch (GITHUB_HEAD_REF
|
|
|
|
# for pull requests, otherwise GITHUB_REF).
|
|
|
|
# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
|
|
|
|
# (GITHUB_BASE_REF for pull requests).
|
|
|
|
# 3. Use the default complement branch ("master").
|
|
|
|
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "master"; do
|
|
|
|
# Skip empty branch names and merge commits.
|
|
|
|
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
|
|
|
|
done
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
# Build initial Synapse image
|
|
|
|
- run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile .
|
|
|
|
working-directory: synapse
|
2022-01-12 05:37:57 -05:00
|
|
|
env:
|
|
|
|
DOCKER_BUILDKIT: 1
|
2021-04-09 05:54:30 -04:00
|
|
|
|
|
|
|
# Build a ready-to-run Synapse image based on the initial image above.
|
|
|
|
# This new image includes a config file, keys for signing and TLS, and
|
|
|
|
# other settings to make it suitable for testing under Complement.
|
|
|
|
- run: docker build -t complement-synapse -f Synapse.Dockerfile .
|
|
|
|
working-directory: complement/dockerfiles
|
|
|
|
|
|
|
|
# Run Complement
|
2022-01-10 06:46:40 -05:00
|
|
|
- run: set -o pipefail && go test -v -json -tags synapse_blacklist,msc2403 ./tests/... 2>&1 | gotestfmt
|
|
|
|
shell: bash
|
2021-04-09 05:54:30 -04:00
|
|
|
env:
|
|
|
|
COMPLEMENT_BASE_IMAGE: complement-synapse:latest
|
|
|
|
working-directory: complement
|
2021-07-20 06:41:19 -04:00
|
|
|
|
|
|
|
# a job which marks all the other jobs as complete, thus allowing PRs to be merged.
|
|
|
|
tests-done:
|
2021-07-22 06:10:30 -04:00
|
|
|
if: ${{ always() }}
|
2021-07-20 06:41:19 -04:00
|
|
|
needs:
|
2021-07-22 06:10:30 -04:00
|
|
|
- lint
|
|
|
|
- lint-crlf
|
|
|
|
- lint-newsfile
|
|
|
|
- lint-sdist
|
2021-07-20 06:41:19 -04:00
|
|
|
- trial
|
|
|
|
- trial-olddeps
|
|
|
|
- sytest
|
|
|
|
- portdb
|
|
|
|
- complement
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-07-22 06:10:30 -04:00
|
|
|
- name: Set build result
|
|
|
|
env:
|
|
|
|
NEEDS_CONTEXT: ${{ toJSON(needs) }}
|
2021-08-02 16:06:34 -04:00
|
|
|
# the `jq` incantation dumps out a series of "<job> <result>" lines.
|
|
|
|
# we set it to an intermediate variable to avoid a pipe, which makes it
|
|
|
|
# hard to set $rc.
|
2021-07-22 06:10:30 -04:00
|
|
|
run: |
|
2021-08-02 16:06:34 -04:00
|
|
|
rc=0
|
|
|
|
results=$(jq -r 'to_entries[] | [.key,.value.result] | join(" ")' <<< $NEEDS_CONTEXT)
|
|
|
|
while read job result ; do
|
2021-08-05 06:22:27 -04:00
|
|
|
# The newsfile lint may be skipped on non PR builds
|
|
|
|
if [ $result == "skipped" ] && [ $job == "lint-newsfile" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2021-08-02 16:06:34 -04:00
|
|
|
if [ "$result" != "success" ]; then
|
|
|
|
echo "::set-failed ::Job $job returned $result"
|
|
|
|
rc=1
|
|
|
|
fi
|
|
|
|
done <<< $results
|
|
|
|
exit $rc
|