diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 000000000..cfcc4f173 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,156 @@ +name: Run sytest +on: + push: + branches: ["develop", "release-*", "github-actions"] + pull_request: + +# Only run this action once per pull request/branch; restart if a new commit arrives. +# C.f. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency +# and https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + synapse: + name: "Synapse: ${{ matrix.label }}" + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - label: Py 3.6, SQLite, Monolith + sytest-tag: bionic + + - label: Py 3.6, PG 10, Monolith + sytest-tag: bionic + postgres: postgres + + - label: Py 3.6, PG 10, Workers + sytest-tag: bionic + postgres: postgres + workers: workers + + - label: Py 3.9, PG 13, Monolith + sytest-tag: testing + postgres: postgres + + - label: Py 3.9, PG 13, Workers + sytest-tag: testing + postgres: postgres + workers: workers + + container: + image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }} + volumes: + # bootstrap.sh expects the sytest source available at /sytest. + # TODO Buildkite mounted /sytest as readonly. Can we do this on GHA? Do we need it? + - ${{ github.workspace }}/sytest:/sytest + # synapse_sytest.sh expects a synapse checkout at /src + - ${{ github.workspace }}/synapse:/src + env: + POSTGRES: ${{ matrix.postgres && 1 }} + WORKERS: ${{ matrix.workers && 1 }} + BLACKLIST: ${{ (matrix.workers && 'synapse-blacklist-with-workers') || 'sytest-blacklist' }} + + steps: + - name: Checkout sytest + uses: actions/checkout@v2 + with: + path: sytest + + - name: Fetch corresponding synapse branch + shell: bash + run: | + BRANCH=${GITHUB_REF#refs/heads/} + (wget -O - https://github.com/matrix-org/synapse/archive/$BRANCH.tar.gz || wget -O - https://github.com/matrix-org/synapse/archive/develop.tar.gz) \ + | tar -xz --strip-components=1 -C /src/ + + - name: Prepare blacklist file for running with workers + if: ${{ matrix.workers }} + run: cat /src/sytest-blacklist /src/.ci/worker-blacklist > /src/synapse-blacklist-with-workers + + - name: Run sytest + run: | + echo POSTGRES=${POSTGRES:-} + echo WORKERS=${WORKERS:-} + echo BLACKLIST=${BLACKLIST:-} + bash -xe /bootstrap.sh synapse + + - name: Summarise results.tap + # Use always() to run this step even if previous ones failed. + 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 }} - (Synapse, ${{ matrix.label }}) + path: | + /logs/results.tap + /logs/**/*.log* + + dendrite: + runs-on: ubuntu-latest + name: "Dendrite: ${{ matrix.label }}" + strategy: + fail-fast: false + matrix: + include: + - label: SQLite + + - label: SQLite, full HTTP APIs + api: full-http + + - label: Postgres + postgres: postgres + + - label: Postgres, full HTTP APIs + postgres: postgres + api: full-http + + container: + image: matrixdotorg/sytest-dendrite + volumes: + # bootstrap.sh expects the sytest source available at /sytest. + # TODO Buildkite mounted /sytest as readonly. Can we do this on GHA? Do we need it? + - ${{ github.workspace }}/sytest:/sytest + # synapse_sytest.sh expects a synapse checkout at /src + - ${{ github.workspace }}/dendrite:/src + env: + POSTGRES: ${{ matrix.postgres && 1 }} + API: ${{ matrix.api && 1 }} + + steps: + - name: Checkout sytest + uses: actions/checkout@v2 + with: + path: sytest + + - name: Fetch corresponding dendrite branch + shell: bash + run: | + BRANCH=${GITHUB_REF#refs/heads/} + (wget -O - https://github.com/matrix-org/dendrite/archive/$BRANCH.tar.gz || wget -O - https://github.com/matrix-org/dendrite/archive/master.tar.gz) \ + | tar -xz --strip-components=1 -C /src/ + + - name: Run sytest + run: | + echo POSTGRES=${POSTGRES:-} + echo API=${API:-} + bash -xe /bootstrap.sh dendrite + + - 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 }} - (Dendrite, ${{ join(matrix.*, ', ') }}) + path: | + /logs/results.tap + /logs/**/*.log* diff --git a/docker/bootstrap.sh b/docker/bootstrap.sh index b700474f4..836f3da3d 100755 --- a/docker/bootstrap.sh +++ b/docker/bootstrap.sh @@ -9,20 +9,18 @@ shift if [ -d "/sytest" ]; then # If the user has mounted in a SyTest checkout, use that. + # This is the case for sytest's GitHub Actions. echo "Using local sytests" else echo "--- Trying to get same-named sytest branch..." - - # Check if we're running in buildkite, if so it can tell us what + # Check if we're running in CI. If so it can tell us what # Synapse/Dendrite branch we're running - if [ -n "$BUILDKITE_BRANCH" ]; then - branch_name=$BUILDKITE_BRANCH + if [ -n "$SYTEST_BRANCH" ]; then + branch_name="$SYTEST_BRANCH" else # Otherwise, try and find the branch that the Synapse/Dendrite checkout # is using. Fall back to develop if unknown. branch_name="$(git --git-dir=/src/.git symbolic-ref HEAD 2>/dev/null)" || branch_name="develop" - fi - if [ "$SYTEST_TARGET" == "dendrite" ] && [ "$branch_name" == "master" ]; then # Dendrite uses master as its main branch. If the branch is master, we probably want sytest develop branch_name="develop" diff --git a/scripts/dendrite_sytest.sh b/scripts/dendrite_sytest.sh index cbe674033..3ce79040d 100755 --- a/scripts/dendrite_sytest.sh +++ b/scripts/dendrite_sytest.sh @@ -68,7 +68,8 @@ echo >&2 "--- Copying assets" # Copy out the logs rsync -r --ignore-missing-args --min-size=1B -av /work/server-0 /work/server-1 /logs --include "*/" --include="*.log.*" --include="*.log" --exclude="*" -if [ $TEST_STATUS -ne 0 ]; then +# Generate annotate.md This is Buildkite-specific. +if [ -n "$BUILDKITE_LABEL" ] && [ $TEST_STATUS -ne 0 ]; then # Build the annotation perl /sytest/scripts/format_tap.pl /logs/results.tap "$BUILDKITE_LABEL" >/logs/annotate.md # If show-expected-fail-tests logged something, put it into the annotation diff --git a/scripts/synapse_sytest.sh b/scripts/synapse_sytest.sh index 8db7c477a..d38227306 100755 --- a/scripts/synapse_sytest.sh +++ b/scripts/synapse_sytest.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -xe # # This script is run by the bootstrap.sh script in the docker image. # @@ -13,7 +13,7 @@ set -e cd "$(dirname $0)/.." -mkdir /work +mkdir -p /work # start the redis server, if desired if [ -n "$REDIS" ]; then @@ -201,7 +201,8 @@ rsync --ignore-missing-args --min-size=1B -av /work/server-0 /work/server-1 /log #export TOP=/src #/venv/bin/coverage combine -if [ $TEST_STATUS -ne 0 ]; then +# Generate annotate.md This is Buildkite-specific. +if [ -n "$BUILDKITE_LABEL" ] && [ $TEST_STATUS -ne 0 ]; then # Build the annotation perl /sytest/scripts/format_tap.pl /logs/results.tap "$BUILDKITE_LABEL" >/logs/annotate.md fi