Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: zulip/python-zulip-api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 50bbad80aa0fa83663c81cf08092dc2ec293c329
Choose a base ref
..
head repository: zulip/python-zulip-api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 67ce679a14e485023e0221fad02d1af98afbdecf
Choose a head ref
Showing with 327 additions and 369 deletions.
  1. +127 −0 .github/workflows/zulip-ci.yml
  2. +6 −5 .github/workflows/zulip-tests.yml
  3. +9 −8 README.md
  4. +5 −2 requirements.txt
  5. +0 −6 tools/.coveragerc
  6. +6 −6 tools/clean-branches
  7. +6 −6 tools/deploy-branch
  8. +1 −1 tools/fetch-rebase-pull-request
  9. +3 −3 tools/lint-commits
  10. +8 −8 tools/review
  11. +0 −76 tools/server_lib/test_handler.py
  12. +0 −146 tools/test-bots
  13. +0 −6 tools/test-botserver
  14. +0 −6 tools/test-lib
  15. +0 −8 tools/test-main
  16. +0 −7 tools/test-main.ps1
  17. +0 −6 tools/test-zulip
  18. +1 −1 zulip/integrations/bridge_with_irc/irc_mirror_backend.py
  19. +2 −1 zulip/integrations/bridge_with_matrix/test_matrix.py
  20. +2 −2 zulip/integrations/bridge_with_slack/bridge_with_slack_config.py
  21. +1 −0 zulip/integrations/bridge_with_slack/requirements.txt
  22. +5 −6 zulip/integrations/git/post-receive
  23. +3 −3 zulip/integrations/git/zulip_git_config.py
  24. +2 −2 zulip/integrations/hg/zulip_changegroup.py
  25. +3 −3 zulip/integrations/nagios/nagios-notify-zulip
  26. +1 −1 zulip/integrations/openshift/post_deploy
  27. +3 −3 zulip/integrations/openshift/zulip_openshift_config.py
  28. +5 −5 zulip/integrations/svn/post-commit
  29. +1 −1 zulip/integrations/zephyr/zephyr_mirror_backend.py
  30. +2 −2 zulip/tests/__init__.py
  31. +5 −6 zulip/tests/test_default_arguments.py
  32. +53 −1 zulip/zulip/__init__.py
  33. +31 −10 zulip_bots/zulip_bots/bots/chessbot/chessbot.py
  34. +2 −1 zulip_bots/zulip_bots/bots/chessbot/requirements.txt
  35. 0 {tools/server_lib → zulip_bots/zulip_bots/bots/merels}/__init__.py
  36. +2 −1 zulip_bots/zulip_bots/bots/merels/merels.py
  37. +1 −1 zulip_bots/zulip_bots/bots/merels/test/test_constants.py
  38. +2 −2 zulip_bots/zulip_bots/bots/merels/test/test_database.py
  39. +2 −2 zulip_bots/zulip_bots/bots/merels/test/test_game.py
  40. +1 −1 zulip_bots/zulip_bots/bots/merels/test/test_interface.py
  41. +2 −2 zulip_bots/zulip_bots/bots/merels/test/test_mechanics.py
  42. +2 −2 zulip_bots/zulip_bots/bots/merels/test_merels.py
  43. +1 −0 zulip_bots/zulip_bots/bots/trello/fixtures/invalid_key.json
  44. +2 −0 zulip_bots/zulip_bots/bots/witai/witai.py
  45. +2 −0 zulip_bots/zulip_bots/finder.py
  46. +4 −1 zulip_bots/zulip_bots/request_test_lib.py
  47. +1 −1 zulip_bots/zulip_bots/test_lib.py
  48. +2 −2 zulip_botserver/tests/__init__.py
  49. +10 −6 zulip_botserver/tests/test_server.py
127 changes: 127 additions & 0 deletions .github/workflows/zulip-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This file is largely copied from the Zulip server's continuous
# integration. The intent is to run the Zulip server's API
# documentation test suite using the current version of this project,
# to verify that the API client is generally compatible with the old
# server release.
name: Zulip server CI

on: [push, pull_request]

defaults:
run:
shell: bash

jobs:
tests:
strategy:
fail-fast: false
matrix:
include:
# Base images are built using `tools/ci/Dockerfile.prod.template`.
# The comments at the top explain how to build and upload these images.
# Bionic ships with Python 3.6.
- docker_image: zulip/ci:bionic
name: Ubuntu 18.04 Bionic (Python 3.6, backend)
os: bionic
is_bionic: true
include_frontend_tests: false
# Configure this test to run with the Zulip 3.2 release.
legacy_client_interface: 3
server_version: refs/tags/3.2
# Focal ships with Python 3.8.2.
- docker_image: zulip/ci:focal
name: Ubuntu 20.04 Focal (Python 3.8, backend)
os: focal
is_focal: true
include_frontend_tests: false
legacy_client_interface: 4
server_version: refs/tags/4.0
# Bullseye ships with Python 3.9.2.
- docker_image: zulip/ci:bullseye
name: Debian 11 Bullseye (Python 3.9, backend)
os: bullseye
is_bullseye: true
include_frontend_tests: false
legacy_client_interface: 4
server_version: refs/tags/4.0

runs-on: ubuntu-latest
name: ${{ matrix.name }} (Zulip ${{matrix.server_version}})
container: ${{ matrix.docker_image }}
env:
# GitHub Actions sets HOME to /github/home which causes
# problem later in provison and frontend test that runs
# tools/setup/postgresql-init-dev-db because of the .pgpass
# location. PostgreSQL (psql) expects .pgpass to be at
# /home/github/.pgpass and setting home to `/home/github/`
# ensures it written there because we write it to ~/.pgpass.
HOME: /home/github/

steps:
- name: Add required permissions
run: |
# The checkout actions doesn't clone to ~/zulip or allow
# us to use the path option to clone outside the current
# /__w/zulip/zulip directory. Since this directory is owned
# by root we need to change it's ownership to allow the
# github user to clone the code here.
# Note: /__w/ is a docker volume mounted to $GITHUB_WORKSPACE
# which is /home/runner/work/.
sudo chown -R github .
# This is the GitHub Actions specific cache directory the
# the current github user must be able to access for the
# cache action to work. It is owned by root currently.
sudo chmod -R 0777 /__w/_temp/
- name: 'Checkout python-zulip-api'
uses: actions/checkout@v2
with:
path: api

- name: 'Checkout Zulip server ${{ matrix.server_version }}'
uses: actions/checkout@v2
with:
repository: zulip/zulip
ref: ${{ matrix.server_version }}
path: server

- name: Do Bionic hack
if: ${{ matrix.is_bionic }}
run: |
# Temporary hack till `sudo service redis-server start` gets fixes in Bionic. See
# https://chat.zulip.org/#narrow/stream/3-backend/topic/Ubuntu.20bionic.20CircleCI
sudo sed -i '/^bind/s/bind.*/bind 0.0.0.0/' /etc/redis/redis.conf
- name: Install dependencies
run: |
cd server
# This is the main setup job for the test suite
./tools/ci/setup-backend --skip-dev-db-build
# Cleaning caches is mostly unnecessary in GitHub Actions, because
# most builds don't get to write to the cache.
# scripts/lib/clean_unused_caches.py --verbose --threshold 0
- name: Replace dependency with the latest python-zulip-api
run: |
cd server
source tools/ci/activate-venv
pip install ../api/zulip
pip install ../api/zulip_bots
- name: Run documentation and api tests
run: |
cd server
source tools/ci/activate-venv
./tools/test-api
env:
LEGACY_CLIENT_INTERFACE_FROM_SERVER_DOCS_VERSION: ${{ matrix.legacy_client_interface }}

- name: Run backend tests
run: |
cd server
source tools/ci/activate-venv
./tools/test-backend zerver.tests.test_bots zerver.tests.test_embedded_bot_system
env:
LEGACY_CLIENT_INTERFACE_FROM_SERVER_DOCS_VERSION: ${{ matrix.legacy_client_interface }}
11 changes: 6 additions & 5 deletions .github/workflows/zulip-tests.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ name: build
on:
push:
branches:
- master
- main
pull_request:

jobs:
@@ -52,13 +52,14 @@ jobs:
name: Running Test-Suite on Linux
run: |
source zulip-api-py3-venv/bin/activate
tools/test-main
pytest --cov --cov-config=tools/.coveragerc --cov-report=xml
- if: runner.os == 'Windows'
name: Running Test-Suite on Windows
run: |
zulip-api-py3-venv\Scripts\Activate.ps1
tools\test-main.ps1
pytest --cov --cov-config=tools\.coveragerc --cov-report=xml
- name: Codecov
uses: codecov/codecov-action@v1.2.1
- uses: codecov/codecov-action@v2
with:
files: coverage.xml
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Zulip API

[![Build status](https://github.com/zulip/python-zulip-api/workflows/build/badge.svg?branch=master)](
https://github.com/zulip/python-zulip-api/actions?query=branch%3Amaster+workflow%3Abuild)
[![Coverage status](https://img.shields.io/codecov/c/github/zulip/python-zulip-api/master.svg)](
[![Build status](https://github.com/zulip/python-zulip-api/workflows/build/badge.svg)](
https://github.com/zulip/python-zulip-api/actions?query=branch%3Amain+workflow%3Abuild)
[![Coverage status](https://img.shields.io/codecov/c/github/zulip/python-zulip-api)](
https://codecov.io/gh/zulip/python-zulip-api)

This repository contains the source code for Zulip's PyPI packages:
@@ -59,13 +59,14 @@ and [commit guidelines](https://zulip.readthedocs.io/en/latest/contributing/vers

### Running tests

To run the tests for
You can run all the tests with:

* *zulip*: run `./tools/test-zulip`
`pytest`

* *zulip_bots*: run `./tools/test-lib && ./tools/test-bots`

* *zulip_botserver*: run `./tools/test-botserver`
or test individual packages with `pytest zulip`, `pytest zulip_bots`,
or `pytest zulip_botserver` (see the [pytest
documentation](https://docs.pytest.org/en/latest/how-to/usage.html)
for more options).

To run the linter, type:

7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
crayons
twine
coverage>=4.4.1
black
isort
flake8
mock
pytest
pytest-cov
-e ./zulip
-e ./zulip_bots
-e ./zulip_botserver
-e git+https://github.com/zulip/zulint@14e3974001bf8442a6a3486125865660f1f2eb68#egg=zulint==1.0.0
mypy==0.812
mypy==0.910
types-python-dateutil
types-pytz
types-requests
gitlint>=0.13.0
6 changes: 0 additions & 6 deletions tools/.coveragerc
Original file line number Diff line number Diff line change
@@ -14,9 +14,3 @@ exclude_lines =

[run]
source = zulip, zulip_bots, zulip_botserver
omit =
# Parts of the test runner infrastructure
tools/test-main
tools/test-bots
tools/test-botserver
tools/test-zulip
12 changes: 6 additions & 6 deletions tools/clean-branches
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
set -e

# usage: clean-branches
# Deletes any local branches which are ancestors of origin/master,
# Deletes any local branches which are ancestors of origin/main,
# and also any branches in origin which are ancestors of
# origin/master and are named like $USER-*.
# origin/main and are named like $USER-*.

# usage: clean-branches --reviews
# Deletes all the above mentioned branches as well as branches
@@ -18,13 +18,13 @@ fi
push_args=()

function is_merged {
! git rev-list -n 1 origin/master.."$1" | grep -q .
! git rev-list -n 1 origin/main.."$1" | grep -q .
}

function clean_ref {
ref="$1"
case "$ref" in
*/master | */HEAD)
*/main | */HEAD)
return
;;

@@ -56,8 +56,8 @@ function clean_ref {
esac
}

if [ "$(git symbolic-ref HEAD)" != 'refs/heads/master' ]; then
echo "Check out master before you run this script." >&2
if [ "$(git symbolic-ref HEAD)" != 'refs/heads/main' ]; then
echo "Check out main before you run this script." >&2
exit 1
fi

12 changes: 6 additions & 6 deletions tools/deploy-branch
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ branch_ref=$(git rev-list --max-count=1 "$branch")
[ $? -ne 0 ] && error_out "Unknown branch: $branch"

if [ "$old_ref" == "$branch_ref" ]; then
new_ref=master
new_ref=main
else
ref_name=$(git describe --all --exact "$old_ref")
if [ $? -eq 0 ]; then
@@ -31,12 +31,12 @@ fi

git fetch -p

git rebase origin/master "$branch"
[ $? -ne 0 ] && error_out "Rebase onto origin/master failed"
git rebase origin/main "$branch"
[ $? -ne 0 ] && error_out "Rebase onto origin/main failed"

git push . HEAD:master
git push origin master
[ $? -ne 0 ] && error_out "Push of master to origin/master failed"
git push . HEAD:main
git push origin main
[ $? -ne 0 ] && error_out "Push of main to origin/main failed"

git checkout "$new_ref"
git branch -D "$branch"
2 changes: 1 addition & 1 deletion tools/fetch-rebase-pull-request
Original file line number Diff line number Diff line change
@@ -12,6 +12,6 @@ fi
request_id="$1"
remote=${2:-"upstream"}
git fetch "$remote" "pull/$request_id/head"
git checkout -B "review-${request_id}" $remote/master
git checkout -B "review-${request_id}" $remote/main
git reset --hard FETCH_HEAD
git pull --rebase
6 changes: 3 additions & 3 deletions tools/lint-commits
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
# Edited at Line 14 Col 97 (zulip -> python-zulip-api)
# Please don't edit here; instead update the zulip/zulip copy and then resync this file.

# Lint all commit messages that are newer than upstream/master if running
# Lint all commit messages that are newer than upstream/main if running
# locally or the commits in the push or PR Gh-Actions.

# The rules can be found in /.gitlint
@@ -16,9 +16,9 @@ $(git remote -v)
" =~ '
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)"$repository"(\.git|/)?\ \(fetch\)'
' ]]; then
range="${BASH_REMATCH[1]}/master..HEAD"
range="${BASH_REMATCH[1]}/main..HEAD"
else
range="upstream/master..HEAD"
range="upstream/main..HEAD"
fi

commits=$(git log "$range" | wc -l)
16 changes: 8 additions & 8 deletions tools/review
Original file line number Diff line number Diff line change
@@ -32,21 +32,21 @@ def check_git_pristine() -> None:
exit("Git is not pristine:\n" + output)


def ensure_on_clean_master() -> None:
def ensure_on_clean_main() -> None:
branch = get_git_branch()
if branch != "master":
if branch != "main":
exit(f"You are still on a feature branch: {branch}")
check_git_pristine()
run("git fetch upstream master")
run("git rebase upstream/master")
run("git fetch upstream main")
run("git rebase upstream/main")


def create_pull_branch(pull_id: int) -> None:
run("git fetch upstream pull/%d/head" % (pull_id,))
run(f"git checkout -B review-{pull_id} FETCH_HEAD")
run("git rebase upstream/master")
run("git log upstream/master.. --oneline")
run("git diff upstream/master.. --name-status")
run("git rebase upstream/main")
run("git log upstream/main.. --oneline")
run("git diff upstream/main.. --name-status")

print()
print("PR: %d" % (pull_id,))
@@ -59,7 +59,7 @@ def review_pr() -> None:
except Exception:
exit("please provide an integer pull request id")

ensure_on_clean_master()
ensure_on_clean_main()
create_pull_branch(pull_id)


Loading