Commit Graph

956 Commits

Author SHA1 Message Date
Umair Khan 82b5d9304b [third] Integrate i18next with Handlebars 2016-05-19 22:58:25 -07:00
Tim Abbott cadbe64265 Fix venv files being included in coverage reports in CI.
e4707af2e2 didn't correctly deal with
the different path for the venv cache in Travis CI.
2016-05-19 10:25:56 -07:00
Tim Abbott e4707af2e2 test-backend: Fix venv files being included in coverage reports. 2016-05-19 09:36:53 -07:00
Umair Khan e56d3196ef Update provisioning/release scripts to build `.mo` files.
We need to update provision.py to compile the messages files, since
they are needed for the new i18n tests.  And of course we need to
include the .mo files in release tarballs; there's a bit of complexity
there around how the tarball archives are created.
2016-05-18 19:30:00 -07:00
Umair Khan e6d33e8834 jslint: Fix typo. 2016-05-18 18:58:06 -07:00
Eklavya Sharma 016a2faa23 Make zproject/local_settings.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma 54759be785 Make zproject/local_settings_template.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma 70a94a5b23 Expand zproject/ in mypy exclude list. 2016-05-18 17:10:18 +05:30
Eklavya Sharma 6606c30355 Remove zilencer/models.py from mypy exclude list.
zilencer/models.py no longer gives an error on type checking with
mypy.
2016-05-18 17:10:18 +05:30
Eklavya Sharma 7c77522ce4 Make zerver/middleware.py pass mypy check.
This was done by reporting python/mypy#1540 and upgrading to the
latest version of mypy which has the fix for this.
2016-05-18 17:10:18 +05:30
Eklavya Sharma 98afe000ee Make zerver/lib/statistics.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma 0dcd8b387d Make zerver/lib/bugdown/fenced_code.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma 3441f0848c Annotate pg_backup_and_purge.py. 2016-05-18 17:10:17 +05:30
Eklavya Sharma 66bb6394e5 Make api/zulip/__init__.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma 46757f07bf Make zerver/lib/actions.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma 16067b7013 Make zerver/views/webhooks/jira.py pass mypy check. 2016-05-18 17:10:17 +05:30
Tim Abbott 12b32d3889 check-py3: Display git status --porcelain output. 2016-05-12 16:30:58 -07:00
Tim Abbott 6c744564a7 travis: Add debugging code for rabbitmq nagios failures. 2016-05-09 09:55:18 -07:00
Umair Khan 5359e6b0d4 Convert Zulip to use Jinja2 templates.
This results in a substantial performance improvement for all of
Zulip's backend templates.

Changes in templates:
- Change `block.super` to `super()`.
- Remove `load` tag because Jinja2 doesn't support it.
- Use `minified_js()|safe` instead of `{% minified_js %}`.
- Use `compressed_css()|safe` instead of `{% compressed_css %}`.
- `forloop.first` -> `loop.first`.
- Use `{{ csrf_input }}` instead of `{% csrf_token %}`.
- Use `{# ... #}` instead of `{% comment %}`.
- Use `url()` instead of `{% url %}`.
- Use `_()` instead of `{% trans %}` because in Jinja `trans` is a block tag.
- Use `{% trans %}` instead of `{% blocktrans %}`.
- Use `{% raw %}` instead of `{% verbatim %}`.

Changes in tools:
- Check for `trans` block in `check-templates` instead of `blocktrans`

Changes in backend:
- Create custom `render_to_response` function which takes `request` objects
  instead of `RequestContext` object. There are two reasons to do this:
    1. `RequestContext` is not compatible with Jinja2
    2. `RequestContext` in `render_to_response` is deprecated.
- Add Jinja2 related support files in zproject/jinja2 directory. It
  includes a custom backend and a template renderer, compressors for js
  and css and Jinja2 environment handler.
- Enable `slugify` and `pluralize` filters in Jinja2 environment.

Fixes #620.
2016-05-09 09:55:18 -07:00
Tim Abbott 804dad42e6 travis: Run various Nagios checks in production tests. 2016-05-08 17:35:50 -07:00
Tim Abbott 744e8ad0e3 travis: Set prod EXTERNAL_HOST to resolve correctly.
This is needed to use check_send_receive_time in the tests.
2016-05-08 17:35:50 -07:00
Tim Abbott e4c098fba4 travis: Verify all supervisord jobs are running in production test.
This requires a bit of complexity since supervisord automatically
restarts failing jobs.
2016-05-08 17:35:50 -07:00
Tim Abbott 40de75d9e6 travis: Verify the server doesn't 500 in production test. 2016-05-08 17:35:50 -07:00
Vladislav Manchev 52e96915e2 check-templates: Allow HTML tag brackets inside tag attributes. 2016-05-08 16:33:03 -07:00
Tim Abbott 6e1872987d Move bin/get-django-setting to scripts/. 2016-05-07 19:37:06 -07:00
Tim Abbott c1a680e2a9 rate_limiter: Fix misplaced type annotation and cleanup code.
You don't put type annotations on return values.
2016-05-06 13:38:12 -07:00
Tim Abbott 3a0e7c217f mypy: Move verbose error output to travis CI wrapper.
This makes it easier to pipe the output of tools/run-mypy to tools
like grep.
2016-05-06 13:38:12 -07:00
Tim Abbott b21454d05e mypy: Use the new --fast-parser option.
This makes mypy about 15% faster running on the Zulip codebase (from
7s=>6s on my laptop), which seems worth it for losing a couple files.

This option requires a new dependency, which we add to the
mypy-specific requirements.txt file.
2016-05-06 13:38:12 -07:00
Tim Abbott 1807e855e7 Upgrade mypy to the new 0.4.0 release.
Also update the mypy command line to not use deprecated argument names.

This introduces a few errors, so we exclude the relevant files to keep
the mypy output clean.
2016-05-06 13:38:12 -07:00
Tim Abbott 542af0d6b6 lint: Add option to print verbose timing output. 2016-05-04 14:22:52 -07:00
Tim Abbott e2aeee0c35 lint: Add check for unnecessary whitespace between % and (. 2016-05-04 14:22:52 -07:00
Tim Abbott 72ee9f5137 lint: Check for unnecssary whitespace after ','s. 2016-05-04 14:17:27 -07:00
Tim Abbott dd40f51fee Add code to clean the venv cache of old venvs. 2016-05-03 15:04:03 -07:00
Tim Abbott 9970341ede Fix caching of install-phantomjs library in Travis CI. 2016-05-03 14:48:21 -07:00
Tim Abbott 391a225595 lint: Check for missing space after comments. 2016-05-02 22:10:47 -07:00
Tim Abbott 762a3188ee Fix missing whitespace after # in comments. 2016-05-02 22:10:47 -07:00
Tim Abbott 52c1e8ac7d Run a local camo server in voyager production environments.
Camo is a caching image proxy, used in Zulip to avoid mixed-content
warnings by proxying HTTP image content over HTTPS.  We've been using
it in zulip.com production for years; this change makes it available
in standalone Zulip deployments.
2016-05-02 17:21:31 -07:00
Tim Abbott 48a578d003 travis: hold expensive to upgrade packages in Travis CI.
This should save a few minutes of time running the production test
suite.  This is part of solving #722.
2016-05-02 16:59:21 -07:00
Tim Abbott 79327a61ae travis: Do an apt-get update before the apt upgrade.
This should save several minutes off the Travis CI `production`
suite's runtime, since previously we were doing the full apt upgrade
process twice, resulting in things like multiple expensive rebuilds of
the initramfs.
2016-05-02 16:35:46 -07:00
Eklavya Sharma 27f12b2de3 Annotate tools/lister.py. 2016-05-01 23:04:09 +05:30
Eklavya Sharma 247cdf578b Add dependencies to setup-py3k.
Add 'six' to setup-py3k, because it is being used in tools/lister.py.
Add 'typing' to setup-py3k, so that tools/lister.py can be type
annotated in the future.
2016-05-01 10:47:04 +05:30
Eklavya Sharma 2d3f9c8fb9 tools/lister.py: Use default arguments in add_argument.
Use the `default` parameter of ArgumentParser.add_argument
instead of manually setting default using the `x = x or []` pattern.
2016-05-01 07:01:52 +05:30
Tim Abbott 755695d3c0 bugdown: Add type: ignore for fenced_code import.
This is a workaround to allow us to type-check files that depend on
this.  Ideally in the future we'll fix the type errors in
fenced_code.py.
2016-04-28 12:50:47 -07:00
Tim Abbott d61c8f91cf run-mypy: Link to docs on ReadTheDocs. 2016-04-28 12:35:54 -07:00
Eklavya Sharma 4310e6d224 Add tools/install-mypy.
This provides a way for users not using provision.py to install mypy.

[with substantial tweaks by tabbott]
2016-04-28 12:29:12 -07:00
Eklavya Sharma 1041115b38 Add code to install mypy from provision.py. 2016-04-28 12:28:24 -07:00
Eklavya Sharma 3601b9eda9 tools/run-mypy: Use mypy from zulip-py3-venv if present. 2016-04-28 12:28:24 -07:00
Eklavya Sharma c80f699321 Add tools/run-mypy to Travis checks.
Fixes #635.
2016-04-28 10:03:35 -07:00
Eklavya Sharma 1af4334887 Add tools/run-mypy.
Since a lot of files don't pass the mypy check, a long list of
files to be excluded from mypy check has been specified.
2016-04-28 10:03:35 -07:00
Eklavya Sharma c220c61dbd tools/check-py3: Speed up and add --find-fixers.
Now tools/check-py3 will by default run all fixers together.  This is
quicker but doesn't indicate which fixers caused the failure.  The
newly added option --find-fixers falls back to the old way of checking
each fixer separately if the quick check fails.

Fixes #710.
2016-04-28 10:01:17 -07:00
Tim Abbott 302da832fa lint: Enforce whitespace between : and value in dicts. 2016-04-27 22:23:40 -07:00
Eklavya Sharma b4555e58c8 tools/check-py3: Update references in output.
Replace occurrences of 'py3k' by 'check-py3' in echo output.
2016-04-27 10:34:52 -07:00
Vishnu Ks fe4a03fd01 Move narrowed_msg_list to message_list.js. 2016-04-26 10:25:11 -07:00
Eklavya Sharma cbba7202e6 Add future and modernize to requirements.txt
Also improve tools/travis/setup-py3k in these ways:
* remove sudo
* add --no-deps to pip install
* specify versions in pip install
2016-04-25 09:50:32 -07:00
Eklavya Sharma 1ce2d26679 Prevent check-py3 from failing on no files.
Now tools/travis/check-py3 does not fail unexpectedly when there are
no python files in the current directory.
2016-04-25 09:50:32 -07:00
Eklavya Sharma b4009c28d0 Move py3k and add a travis wrapper for it.
Move tools/travis/py3k to tools/check-py3.
Add tools/travis/py3k which calls tools/check-py3.
2016-04-25 09:50:32 -07:00
Vishnu Ks 35b0af2852 Move all_msg_list to message_list.js. 2016-04-21 17:46:21 -07:00
Tim Abbott 8a278cbe3a Switch to using a Zulip version of @login_required.
Currently the code is the unmodified Django upstream implementation;
this commit is preparation for modifying it.
2016-04-21 14:59:39 -07:00
Vishnu Ks ee39f5009f Make message_list.js work like the other modules. 2016-04-20 15:29:30 -07:00
Tim Abbott 9c56027627 lint: Add CSS lint rule for whitespace after {. 2016-04-20 11:50:01 -07:00
Tim Abbott a46b5d7bbe Add lint check for missing whitespace after =. 2016-04-20 11:37:03 -07:00
Tim Abbott a72385246e Fix missing whitespace after '=' in python/js code. 2016-04-20 11:36:14 -07:00
Vishnu Ks 3179434f93 Move keep_pointer_in_view to pointer.js. 2016-04-19 15:23:45 -07:00
Vishnu Ks b655e090a6 check_all: Move viewport to modules list.
It was previously incorrectly listed as a global variable.
2016-04-19 15:23:24 -07:00
Tim Abbott a2b59b8b51 lint: Check whitespace rules for txt files. 2016-04-14 14:36:29 -07:00
Tim Abbott 39950b8f4f lint: Check whitespace rules in markdown files too. 2016-04-14 14:30:29 -07:00
Tim Abbott 1a162ecb97 Fix tab-based whitespace in stress-test README file. 2016-04-14 14:30:29 -07:00
Tim Abbott 2b76f6223e Make 'no newline at end of file' lint error more actionable.
There's a handy sed command to fix this, so we might as well document
it.
2016-04-14 10:55:06 -07:00
Tim Abbott e71d8bb4b6 lint-all: Require newlines at end of JSON files. 2016-04-14 10:49:12 -07:00
Tim Abbott d0f2c46f25 generate_test_credentials: Use the email variable properly.
This makes it a bit easier to change the email in the test
credentials.
2016-04-13 13:19:02 -07:00
Tim Abbott 98d5f64f36 webpack: Use the correct port in Casper tests.
Previously we used 9994 unconditionally, whereas we should be using
9984 or 9994 depending whether it's being run manually or via the
Casper tests.
2016-04-13 13:18:38 -07:00
Vishnu Ks 35f70e9dac Move 5 legacy global variables to pointer.js.
Move recenter_pointer_on_display, suppress_scroll_pointer_update,
fast_forward_pointer, furthest_read, and server_furthest_read to
a new pointer module in pointer.js.
2016-04-12 10:56:54 -07:00
Tim Abbott be96cf809d Move Zulip backend tests to zerver.tests. 2016-04-11 22:16:09 -07:00
Ashish a12006d86f Replace /json/update_active_status with REST style route. 2016-04-11 21:38:23 -07:00
Ashish cb8da46bbf Replace /json/get_old_messages with REST style route. 2016-04-11 21:38:23 -07:00
Tim Abbott 52fc1c71bc provision: Rewrite using subprocess module instead of sh.
The `with sh.sudo` pattern that we were using in python-sh was
deprecated, and emperically hangs on Ubuntu xenial.  Since in general
the use of python-sh/python-pbs caused trouble (requiring extra
dependencies, confusing syntax), this just removes it.

We replace it with a new zulip_tools.py library function that echoes
the command line and streams the output.

We do the same to install-phantomjs so we can remove that dependency.
2016-04-10 17:33:19 -07:00
Vishnu Ks 2ac5271091 Move global variable have_scrolled_away_from_top to ui.js. 2016-04-10 10:55:16 -07:00
Tim Abbott 9584ae1ab8 Add CSS linter for missing space after : in rules. 2016-04-08 21:04:43 -07:00
Aristeidis Fkiaras 0058ccbdb0 Move global unread_messages_read_in_narrow to unread.js. 2016-04-08 12:11:47 -07:00
Tim Abbott 209e6ef7a1 Run trailing whitespace linter on bash files. 2016-04-08 11:52:11 -07:00
Tim Abbott caba24b2af Fix existing trailing whitespace in bash scripts. 2016-04-08 11:52:11 -07:00
Tim Abbott 4fa63c29ca Run whitespace linters on html files. 2016-04-08 11:52:11 -07:00
Tim Abbott d670e902a9 Run whitespace linters on handlebars templates. 2016-04-08 11:52:11 -07:00
Tim Abbott c6d01ab76b Run whitespace linters on CSS files. 2016-04-08 11:47:10 -07:00
Tim Abbott 1b84617771 Don't skip running python custom linters inside comments.
This fixes an issue where we weren't checking for trailing whitespace
in comments.
2016-04-08 11:47:10 -07:00
Tim Abbott 14b5e265c2 Remove unuseful suspicious code lint check. 2016-04-08 11:47:10 -07:00
Tim Abbott efd14e7ad9 Revert "Exclude 'from typing import *' from linter."
This reverts commit d936bf61f9.

We no longer need this since we've migrated to specifying the
dependencies in the typing module that we're actually using.
2016-04-07 14:12:18 -07:00
Tim Abbott e413d4e153 Move webpack configuration to tools/. 2016-04-06 08:09:55 -07:00
Eklavya Sharma 05ab57e373 In py3k, exit with 1 if repository is not clean. 2016-04-05 13:22:51 -07:00
Eklavya Sharma 569d1240d0 Exit with 1 in py3k when fixers find an issue.
tools/travis/py3k used to always exit with exit code 0.
It should exit with 1 when fixers detect a compatibility issue.

py3k used [ -z "$failed" ] to check if there was a failure.
This is wrong, since if no failure has occured, failed=0,
and -z checks if a string is of zero length. This commit also
fixes this bug.
2016-04-05 13:22:51 -07:00
Eklavya Sharma dd501830a6 Change position where git reset is called in py3k.
In py3k, "git reset --hard" was called only if
libmodernize.fixes.fix_dict_six changed files and some of those
changes are not considered false positives by py3k.
But if all of those changes are not considered false positives
by py3k, then "git reset --hard" is not called and the repository
is no longer clean.

This commit fixes this bug.
2016-04-05 13:22:51 -07:00
Eklavya Sharma 5e71777975 Add --no-pager option to git diff in py3k.
This is needed because py3k hangs when a pager opens up.
2016-04-05 13:22:51 -07:00
Eklavya Sharma adff674b0e tools/travis/py3k now checks all python files.
tools/travis/py3k used to only check files whose names ended with .py.
Now it also checks python scripts which don't have an extension.
It uses tools/lister.py to get a list of all python files.
2016-04-05 13:22:51 -07:00
Eklavya Sharma ab02ab31e3 Change len(obj.keys()) to len(obj) in tools/get-handlebar-vars.
This prevents libmodernize.fixes.fix_dict_six from reporting
this on running tools/travis/py3k.
2016-04-05 13:22:51 -07:00
Eklavya Sharma 8a81f8c125 Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import. 2016-04-05 13:22:51 -07:00
Eklavya Sharma f4aa609aea Apply Python 3 futurize transform libmodernize.fixes.fix_file. 2016-04-05 13:22:51 -07:00
Eklavya Sharma be0a4f349d Apply Python 3 futurize transform libmodernize.fixes.fix_filter. 2016-04-05 13:22:51 -07:00
Tim Abbott 78e289f904 Exclude puppet-common tests from puppet linter. 2016-04-04 17:08:29 -07:00
Tim Abbott b99313545e Add PEP-484 type annotations to global dictionaties. 2016-04-03 15:40:06 -07:00
Tim Abbott 70c1b0a01d lister: Add file type detection for node and ruby. 2016-04-01 15:27:32 -07:00