Commit Graph

39160 Commits

Author SHA1 Message Date
Steve Howell 294fd59983 github webhook: Ignore more pull_request actions.
See https://github.com/zulip/zulip/issues/16258 for
possible follow up here.

We now ignore the following two new pull_request
actions (as well as the three existing ones
from before):

    approved
    converted_to_draft

As the issue above indicates, we may want to actually
support "approved" if we can find somebody to work
on the webhook.  (And then the issue goes a little
broader than what changed here.)
2020-09-03 10:44:39 -07:00
Steve Howell 5dea85a186 github tests: Extract test_ignored_pull_request_actions.
We consolidate the tests and remove the fixtures, which
just have a lot of noisy fields that we ignore.  Also,
pull_request__request_review_removed was named improperly.
2020-09-03 10:44:39 -07:00
Steve Howell 4c2787c35f github tests: Add test_ignored_events. 2020-09-03 10:44:39 -07:00
Steve Howell 040bf82122 github webhook: Remove unused exception class. 2020-09-03 10:44:39 -07:00
Steve Howell 3634fe903b decorator test: Dedent some assertions.
These assertions didn't need to be nested
in the with blocks.
2020-09-03 10:44:39 -07:00
Steve Howell e91e21c9e7 webhook logger: Add summary field.
Before this the only way we took advantage
of the summary from UnexpectedWebhookEventType
was by looking at exc_info().

Now we just explicitly add it to the log
message, which also sets us up to call
log_exception_to_webhook_logger directly
with some sort of "summary" info
when we don't actually want a real
exception (for example, we might want to
report anomalous webhook data but still
continue the transaction).

A minor change in passing is that I move
the payload parameter lexically.
2020-09-03 10:44:39 -07:00
Anders Kaseorg 3b257d10df tools: Delete tagmessages script.
It was broken by commit aaedec1fdb which
moved it to tools/i18n without adjusting its relative path references,
and it contains a sketchy injectable os.system call that I’d like to
remove.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-03 10:35:51 -07:00
Anders Kaseorg 5a1104f1b8 update-zuliprc-api-field: Add missing shell quoting.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-03 10:34:27 -07:00
Anders Kaseorg d751e0cece puppet: Don’t install netcat.
It’s been unused since commit 0af22dad18
(#13239).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-03 10:33:47 -07:00
Steve Howell 81b6583d28 node tests: Show coverage link when we regress coverage.
In 6653e19e3a we added
the convenient line to tell folks about the coverage
report.  But if we failed coverage checks, we didn't
show the link.

Arguably we should just always show this, even if
tests fail, but that can also be potentially confusing.
2020-09-03 07:57:58 -04:00
Steve Howell dc1795a3da node tests: Find files in Python.
The code to run single files was added
in c15695e514,
and it's just kinda strange code.

We already do a lot of file logic in Python
to check for line-coverage, so it's easier
to just have all the logic in Python.

This adds a new feature--you can now specify
the actual file:

    ./tools/test-js-with-node frontend_tests/node_tests/people.js

(This is helpful if you just want to use
shell autocomplete.)

Another minor change is that if you specify
individual files, we won't sort them.  This is
important when you're trying to hunt down test
leaks.

Finally, we have a nicer message if we can't find
the file.
2020-09-03 07:57:58 -04:00
Steve Howell e9bbfbc624 node tests: Clean up nyc arguments.
nyc was added in 29f04511c0

All the stuff after "&&" was actually passed to
node, because we didn't use shell=True, so the
"nyc report" command didn't run, and the ugly
finder.js code just skipped over all the final tokens.
2020-09-03 07:57:58 -04:00
Anders Kaseorg b84260014a populate_analytics_db: Replace intermediate list with generator.
Followup to commit ab120a03bc (#16265).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 19:34:48 -07:00
Anders Kaseorg d9860d40a6 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 19:34:37 -07:00
Aman Agrawal 66a1037f06 test: Use variable instead of hard coded value. 2020-09-02 17:58:19 -07:00
Anders Kaseorg 0682d5c0f3 provision: Convert "".format to Python 3.6 f-strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 17:27:14 -07:00
Anders Kaseorg 424b441bb1 provision: Check for old Ubuntu or Python before starting Python.
This unblocks us from being able to use Python 3.6 syntax in
provision.py and its dependencies.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 17:27:14 -07:00
Anders Kaseorg c1618c16c1 eslint: Enable import/no-cycle.
Also remove import/no-unresolved, which is already implied by
plugin:import/errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 13:14:39 -07:00
Anders Kaseorg c5a904fb05 django_api, test_classes: Use Python 3 form of super().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:31:46 -07:00
Anders Kaseorg 691f8f8e47 test_hash_reqs: Use mock from unittest.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:26:12 -07:00
Anders Kaseorg 02725d32dd python: Rewrite list() as [].
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a276eefcfe python: Rewrite dict() as {}.
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a610bd19a1 python: Simplify away various unnecessary lists and list comprehensions.
Loosely inspired by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 9048f79e53 test_stripe: Simplify with iterable unpacking.
Issue suggested by the flake8-comprehensions plugin, although the
solution is simpler.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 0e5e6d0890 email_notifications: Convert list() of generator to comprehensions.
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg ab120a03bc python: Replace unnecessary intermediate lists with generators.
Mostly suggested by the flake8-comprehension plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 1ded51aa9d python: Replace list literal concatenation with * unpacking.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a5dbab8fb0 python: Remove redundant dest for argparse arguments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:04:10 -07:00
Anders Kaseorg 4d583e3d41 test_openapi: Drop Python 3.5 code in get_standardized_argument_type.
Also flip the Python 3.6 and 3.7+ cases to consider the modern version
as the “normal” case.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:02:55 -07:00
Anders Kaseorg edaed497ed lint: Remove unused ignorelongline and lint:ignore comments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:00:44 -07:00
Anders Kaseorg 72d2e5df15 isort: Enable black profile.
Our isort configuration was almost Black-compatible, but we were
missing ensure_newline_before_comments.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:00:07 -07:00
Aman Agrawal 22665414fe landing-page: Fix carousel indicators alignment.
Reset to bootstrap v2.3.2 moved the indicators to top right, we
change it back to its previous location in this commit.
2020-09-02 10:59:22 -07:00
Steve Howell 8a210923e1 node tests: Prevent theoretical leak from Intl.
Because `util` is so late in the alphabet, this
leak never surfaced in practice, but I tried running
the node tests in reverse, and this leak came
up if you ran `util` before `stream_list`.  I guess
it's nice that `stream_list` actually exercises
the difference between a dumb sort and an
Intl-aware sort.

It's possible that we should just assume that
Intl.Collator is always available at this point,
which would eliminate the need for this test.
2020-09-02 13:45:03 -04:00
Steve Howell fb96407607 node tests: Avoid unnecessary people mocks.
The first mock here probably hasn't been
needed for a long time, and the second one
is easily addressed by making hamlet be
the current user.
2020-09-02 10:48:51 -04:00
Priyank Patel 551a19c90d js: Convert people module to ES6. 2020-09-01 19:55:58 -07:00
Priyank Patel aca77e9245 js: Convert pm_conversations module to ES6.
This was converted automatically using a jscodeshift script followed
by running eslint and prettier to convert let -> const (whenever
applicable) and removing "use strict;".
2020-09-01 19:55:58 -07:00
Priyank Patel a691f0c527 eslint: Disable no-use-before-define for functions.
There are lots of function that will be used before they are defined
when we migrate to ES6 from CommonJS, so disable this rule. Functions
are hoisted and processed by webpack so this is fine.
2020-09-01 19:55:58 -07:00
Priyank Patel b7998d3160 js: Purge people module from window. 2020-09-01 19:55:58 -07:00
Priyank Patel d774bba1b9 js: Purge pm_conversations module from window.
All the changes are done using a script followed by updates to Node
tests and running eslint and prettier to fix formatting issues.
2020-09-01 19:55:58 -07:00
Priyank Patel 305a1ac57d node_tests: Don't remove require cache of module in zrequire.
There is good reason to do this (explanation is bit long!). With the
TypeScript migration, and the require and ES6 migrations that come
with it, we use require instead of set_global which loads the entire
module. Suppose we have a util module, which is used by some other
module, say message_store, and util is being required in message_store
since it is removed from window. Then, if a test zrequires
message_store first, and then zrequires the util module qand mocks one
of its methods, it will not be mocked for the message_store
module. The reason is:
 1. zrequire('message_store') leads to require('util').
 2. zrequire('util') removes the util module from cache and it is
    reloaded. Now the util module in message_store and the one in
    the test will be different and any updates to it in tests won't
    be reflected in the actual code.

Which can lead to confusion for folks writing tests. I'll mention this
can be avoided doing zrequire('util') first but...that is not ideal.

And, since there was one outlier test that relied on this behavior,
we add the namespace.reset_module function.
2020-09-01 19:55:58 -07:00
Priyank Patel 5c53c44ee5 dependencies: Upgrade babel-plugin-rewire-ts to v1.4.0.
This version keeps the internal and external state of the ES6 module
in sync so its state is similar to a CommonJS module.  Since we don't
need to ask rewire for the internal state of the module, the tests
will be same as they were before the TS/ES6/remove from window
migrations.
2020-09-01 19:55:58 -07:00
S-Abhishek 55a23754c3 api: Fix trailing '/' at end of jitsi server url.
Some users setup zulip with trailing / at end, like 'https://meet.jit.si/
leading to extra / on clients while generating video chat link.

This commit removes trailing '/' if it exists to make it consistent. Manual
testing was done by generating jitsi url.

Fixes #16225
2020-09-01 17:29:31 -07:00
Tim Abbott 63101db3ce template context: Remove jitsi_server_url.
This field was not used in any of our templates; the actual encoding
of this value for clients is in zerver/lib/events.py.
2020-09-01 17:29:31 -07:00
Anders Kaseorg c74b1b22c1 eslint: Forbid unnecessary path segments in imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 6398bcbd2f eslint: Forbid .js and .ts extensions on imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 279e4b819e js: Elide .js and .ts extensions from imports and requires.
This will be required for TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg b9184eee65 eslint: Use eslint-import-resolver-webpack.
This uses our Webpack configuration to more accurately predict how our
imports will actually behave; for example, it automatically resolves
the .ts extension.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 2bfb590391 package.json: Move testing dependencies to devDependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 10bd7a47c4 webpack: Move webpack.config.ts to top level.
We lost the war against top level configuration files many moons ago.
This is what developers and tools expect.  And it seems to be required
for eslint-import-resolver-webpack (there’s ostensibly a {"config":
"tools/webpack.config.ts"} option, but it doesn’t work correctly:
https://github.com/benmosher/eslint-plugin-import/issues/1861).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Steve Howell 8dc24e2a20 webhooks: Clean up args to log_exception_to_webhook_logger.
We eliminate optional parameters and replace `request_body`
with `payload`.

There is much less confusion if we just pass in `payload`,
and then we optionally re-format it if it's json.

For unclear reasons the original code was trying to
do `request_body = str(payload)` when `request_body`
was no longer being used.
2020-09-01 15:10:16 -07:00