This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Proof of concept for GitHub Actions #9661
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9572716
Proof of concept for GitHub Actions
callahad 4561f18
Fixup SyTest behavior on failure
callahad 6a0951b
Reflow yaml
callahad e955013
Address review feedback
callahad 54a1e14
Fixup log dumping
callahad ba038bb
Fixup log dumping for Sytest
callahad 532b6c4
Upload Sytest logs as artifacts
callahad 6666985
Temporarily always run SyTest
callahad 574da27
s/uploat/upload/
callahad f6b43aa
...fix Sytest invocation
callahad a20e12b
Fix newsfile linting conditions
callahad 49686c4
Correct test ordering
callahad 30f5708
Merge remote-tracking branch 'origin/develop' into callahad/actions
callahad 9a26295
Address review comments
callahad 368e20b
Drop Py35
callahad 92174d0
Merge remote-tracking branch 'origin/develop' into callahad/actions
callahad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,322 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: ["develop", "release-*"] | ||
pull_request: | ||
|
||
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 | ||
- uses: actions/setup-python@v2 | ||
- run: pip install tox | ||
- name: Patch Buildkite-specific test script | ||
run: | | ||
sed -i -e 's/\$BUILDKITE_PULL_REQUEST/${{ github.event.number }}/' \ | ||
scripts-dev/check-newsfragment | ||
- run: scripts-dev/check-newsfragment | ||
|
||
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: | ||
if: ${{ always() }} # Run this even if prior jobs were skipped | ||
needs: [lint, lint-crlf, lint-newsfile, lint-sdist] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: "true" | ||
|
||
trial: | ||
if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail | ||
needs: linting-done | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.6", "3.7", "3.8", "3.9"] | ||
database: ["sqlite"] | ||
include: | ||
# Newest Python without optional deps | ||
- python-version: "3.9" | ||
toxenv: "py-noextras,combine" | ||
|
||
# Oldest Python with PostgreSQL | ||
- python-version: "3.6" | ||
database: "postgres" | ||
postgres-version: "9.6" | ||
|
||
# Newest Python with PostgreSQL | ||
- python-version: "3.9" | ||
database: "postgres" | ||
postgres-version: "13" | ||
|
||
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 | ||
- run: tox -e py,combine | ||
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 | ||
# 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: | ||
if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail | ||
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 | ||
entrypoint: .buildkite/scripts/test_old_deps.sh | ||
env: | ||
TRIAL_FLAGS: "--jobs=2" | ||
- name: Dump logs | ||
# 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' | ||
if: ${{ contains(github.ref, 'pypy') && !failure() }} | ||
needs: linting-done | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["pypy-3.6"] | ||
|
||
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 | ||
- run: tox -e py,combine | ||
env: | ||
TRIAL_FLAGS: "--jobs=2" | ||
- name: Dump logs | ||
# 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: | ||
if: ${{ !failure() }} | ||
needs: linting-done | ||
runs-on: ubuntu-latest | ||
container: | ||
image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }} | ||
volumes: | ||
- ${{ github.workspace }}:/src | ||
env: | ||
BUILDKITE_BRANCH: ${{ github.head_ref }} | ||
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' }} | ||
|
||
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 | ||
run: cat sytest-blacklist .buildkite/worker-blacklist > synapse-blacklist-with-workers | ||
- name: Run SyTest | ||
run: /bootstrap.sh synapse | ||
working-directory: /src | ||
- name: Dump results.tap | ||
if: ${{ always() }} | ||
run: cat /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* | ||
|
||
portdb: | ||
if: ${{ !failure() }} # Allow previous steps to be skipped, but not fail | ||
needs: linting-done | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- python-version: "3.6" | ||
postgres-version: "9.6" | ||
|
||
- python-version: "3.9" | ||
postgres-version: "13" | ||
|
||
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 }} | ||
- name: Patch Buildkite-specific test scripts | ||
run: | | ||
sed -i -e 's/host="postgres"/host="localhost"/' .buildkite/scripts/create_postgres_db.py | ||
sed -i -e 's/host: postgres/host: localhost/' .buildkite/postgres-config.yaml | ||
sed -i -e 's|/src/||' .buildkite/{sqlite,postgres}-config.yaml | ||
sed -i -e 's/\$TOP/\$GITHUB_WORKSPACE/' .coveragerc | ||
- run: .buildkite/scripts/test_synapse_port_db.sh | ||
|
||
complement: | ||
if: ${{ !failure() }} | ||
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 | ||
|
||
- name: Run actions/checkout@v2 for complement | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: "matrix-org/complement" | ||
path: complement | ||
|
||
# Build initial Synapse image | ||
- run: docker build -t matrixdotorg/synapse:latest -f docker/Dockerfile . | ||
working-directory: synapse | ||
|
||
# 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 | ||
- run: go test -v -tags synapse_blacklist ./tests | ||
env: | ||
COMPLEMENT_BASE_IMAGE: complement-synapse:latest | ||
working-directory: complement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Experiment with GitHub Actions for CI. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be made that it also runs if the PR/commit name has "pypy"? (preferably PR name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could, but I think the expression would be quite a bit longer?
I think it'd be something like
github.event == 'pull_request' && (contains(github.event.pull_request.title, 'pypy') || contains(github.ref, 'pypy') ) && !failure())
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and I don't think the expression being longer is a problem, most people wouldn't see this unless they were editing this specific part of the pipeline.
Adding some comments to deconstruct what is happening could help, tho.