2020-08-11 01:47:54 +02:00
|
|
|
Using the development environment
|
2016-07-15 20:43:09 +02:00
|
|
|
=================================
|
|
|
|
|
2020-01-14 20:13:59 +01:00
|
|
|
This page describes the basic edit/refresh workflows for working with
|
2021-08-20 21:53:28 +02:00
|
|
|
the Zulip development environment. Generally, the development
|
2020-01-17 00:56:39 +01:00
|
|
|
environment will automatically update as soon as you save changes
|
2021-08-20 21:53:28 +02:00
|
|
|
using your editor. Details for work on the [server](#server),
|
2021-05-14 00:16:30 +02:00
|
|
|
[web app](#web), and [mobile apps](#mobile) are below.
|
2020-01-14 20:13:59 +01:00
|
|
|
|
2020-01-17 00:56:39 +01:00
|
|
|
If you're working on authentication methods or need to use the [Zulip
|
|
|
|
REST API][rest-api], which requires an API key, see [authentication in
|
|
|
|
the development environment][authentication-dev-server].
|
2016-07-15 20:43:09 +02:00
|
|
|
|
2020-01-17 09:00:09 +01:00
|
|
|
## Common
|
2016-07-15 20:43:09 +02:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- Zulip's `main` branch moves quickly, and you should rebase
|
2021-09-08 00:23:24 +02:00
|
|
|
constantly with e.g.
|
|
|
|
`git fetch upstream; git rebase upstream/main` to avoid developing
|
|
|
|
on an old version of the Zulip codebase (leading to unnecessary
|
|
|
|
merge conflicts).
|
2021-08-20 21:45:39 +02:00
|
|
|
- Remember to run `tools/provision` to update your development
|
2020-01-17 09:00:09 +01:00
|
|
|
environment after switching branches; it will run in under a second
|
|
|
|
if no changes are required.
|
2021-08-20 21:45:39 +02:00
|
|
|
- After making changes, you'll often want to run the
|
2020-01-17 00:56:39 +01:00
|
|
|
[linters](../testing/linters.md) and relevant [test
|
2021-08-20 21:53:28 +02:00
|
|
|
suites](../testing/testing.md). Consider using our [Git pre-commit
|
2020-01-17 09:00:09 +01:00
|
|
|
hook](../git/zulip-tools.html#set-up-git-repo-script) to
|
|
|
|
automatically lint whenever you make a commit.
|
2021-08-20 21:45:39 +02:00
|
|
|
- All of our test suites are designed to support quickly testing just
|
2020-01-17 09:00:09 +01:00
|
|
|
a single file or test case, which you should take advantage of to
|
|
|
|
save time.
|
2021-08-20 21:45:39 +02:00
|
|
|
- Many useful development tools, including tools for rebuilding the
|
2020-01-17 09:00:09 +01:00
|
|
|
database with different test data, are documented in-app at
|
|
|
|
`https://localhost:9991/devtools`.
|
2021-08-20 21:45:39 +02:00
|
|
|
- If you want to restore your development environment's database to a
|
2020-04-21 22:03:12 +02:00
|
|
|
pristine state, you can use `./tools/rebuild-dev-database`.
|
2016-07-15 20:43:09 +02:00
|
|
|
|
2020-01-17 00:56:39 +01:00
|
|
|
## Server
|
2020-01-14 20:13:59 +01:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- For changes that don't affect the database model, the Zulip
|
2020-01-17 00:56:39 +01:00
|
|
|
development environment will automatically detect changes and
|
|
|
|
restart:
|
2021-08-20 21:45:39 +02:00
|
|
|
- The main Django/Tornado server processes are run on top of
|
2020-01-17 00:56:39 +01:00
|
|
|
Django's [manage.py runserver][django-runserver], which will
|
|
|
|
automatically restart them when you save changes to Python code
|
2021-08-20 21:53:28 +02:00
|
|
|
they use. You can watch this happen in the `run-dev.py` console
|
2020-01-17 00:56:39 +01:00
|
|
|
to make sure the backend has reloaded.
|
2021-08-20 21:45:39 +02:00
|
|
|
- The Python queue workers will also automatically restart when you
|
2020-01-17 09:00:09 +01:00
|
|
|
save changes, as long as they haven't crashed (which can happen if
|
|
|
|
they reloaded into a version with a syntax error).
|
2021-08-20 21:45:39 +02:00
|
|
|
- If you change the database schema (`zerver/models.py`), you'll need
|
2020-01-17 00:56:39 +01:00
|
|
|
to use the [Django migrations
|
2020-01-17 09:00:09 +01:00
|
|
|
process](../subsystems/schema-migrations.md); see also the [new
|
|
|
|
feature tutorial][new-feature-tutorial] for an example.
|
2021-08-20 21:45:39 +02:00
|
|
|
- While testing server changes, it's helpful to watch the `run-dev.py`
|
2020-01-17 00:56:39 +01:00
|
|
|
console output, which will show tracebacks for any 500 errors your
|
2020-01-17 09:00:09 +01:00
|
|
|
Zulip development server encounters (which are probably caused by
|
|
|
|
bugs in your code).
|
2021-08-20 21:45:39 +02:00
|
|
|
- To manually query Zulip's database interactively, use
|
2021-09-08 00:23:24 +02:00
|
|
|
`./manage.py shell` or `manage.py dbshell`.
|
2021-08-20 21:45:39 +02:00
|
|
|
- The database(s) used for the automated tests are independent from
|
2020-01-17 00:56:39 +01:00
|
|
|
the one you use for manual testing in the UI, so changes you make to
|
|
|
|
the database manually will never affect the automated tests.
|
2020-01-14 20:13:59 +01:00
|
|
|
|
2020-02-04 01:55:28 +01:00
|
|
|
## Web
|
2020-01-14 20:13:59 +01:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- Once the development server (`run-dev.py`) is running, you can visit
|
2020-01-17 00:56:39 +01:00
|
|
|
<http://localhost:9991/> in your browser.
|
2021-08-20 21:45:39 +02:00
|
|
|
- By default, the development server homepage just shows a list of the
|
2020-08-11 02:20:10 +02:00
|
|
|
users that exist on the server and you can log in as any of them by
|
2020-01-17 00:56:39 +01:00
|
|
|
just clicking on a user.
|
2021-08-20 21:45:39 +02:00
|
|
|
- This setup saves time for the common case where you want to test
|
2020-01-17 00:56:39 +01:00
|
|
|
something other than the login process.
|
2021-08-20 21:45:39 +02:00
|
|
|
- You can test the login or registration process by clicking the
|
2020-01-17 00:56:39 +01:00
|
|
|
links for the normal login page.
|
2021-08-20 21:53:28 +02:00
|
|
|
- Most changes will take effect automatically. Details:
|
2021-08-20 21:45:39 +02:00
|
|
|
- If you change CSS files, your changes will appear immediately via
|
2020-01-17 09:00:09 +01:00
|
|
|
webpack hot module replacement.
|
2021-08-20 21:45:39 +02:00
|
|
|
- If you change JavaScript code (`static/js`) or Handlebars
|
2020-01-17 09:00:09 +01:00
|
|
|
templates (`static/templates`), the browser window will be
|
|
|
|
reloaded automatically.
|
2021-08-20 21:45:39 +02:00
|
|
|
- For Jinja2 backend templates (`templates/*`), you'll need to reload
|
2020-01-17 09:00:09 +01:00
|
|
|
the browser window to see your changes.
|
2021-08-20 21:45:39 +02:00
|
|
|
- Any JavaScript exceptions encountered while using the web app in a
|
2020-01-17 00:56:39 +01:00
|
|
|
development environment will be displayed as a large notice, so you
|
|
|
|
don't need to watch the JavaScript console for exceptions.
|
2021-08-20 21:45:39 +02:00
|
|
|
- Both Chrome and Firefox have great debuggers, inspectors, and
|
2020-01-17 09:00:09 +01:00
|
|
|
profilers in their built-in developer tools.
|
2021-08-20 21:45:39 +02:00
|
|
|
- `debug.js` has some occasionally useful JavaScript profiling code.
|
2020-01-14 20:13:59 +01:00
|
|
|
|
2020-02-04 01:55:28 +01:00
|
|
|
## Mobile
|
2020-01-14 20:13:59 +01:00
|
|
|
|
|
|
|
See the mobile project's documentation on [using a development server
|
|
|
|
for mobile development][mobile-dev-server].
|
2016-07-15 20:43:09 +02:00
|
|
|
|
2020-06-08 23:04:39 +02:00
|
|
|
[rest-api]: https://zulip.com/api/rest
|
2020-01-15 20:32:49 +01:00
|
|
|
[authentication-dev-server]: ./authentication.md
|
2016-07-15 20:43:09 +02:00
|
|
|
[django-runserver]: https://docs.djangoproject.com/en/1.8/ref/django-admin/#runserver-port-or-address-port
|
2019-09-30 19:37:56 +02:00
|
|
|
[new-feature-tutorial]: ../tutorials/new-feature-tutorial.md
|
|
|
|
[testing-docs]: ../testing/testing.md
|
2020-01-14 20:13:59 +01:00
|
|
|
[mobile-dev-server]: https://github.com/zulip/zulip-mobile/blob/master/docs/howto/dev-server.md#using-a-dev-version-of-the-server
|