All bugs are tracked in https://bugzilla.mozilla.org/.
Write up a new bug:
Everything runs in a Docker container. Thus Pontoon requires fewer things to get started and you’re guaranteed to have the same setup as everyone else and it solves some other problems, too.
Python code conventions¶
Python code should follow PEP-8.
Max line length is 100 characters.
To run the linter, do:
$ pylama pontoon
If you hit issues, use
# noqa to make the linter ignore that error. Note that in most cases,
it is better to fix the issues than ignoring them.
First line is a summary of the commit. It should start with one of the following:
Fix bug XXXXXXX
The first, when it lands, will cause the bug to be closed. The second one does not.
After that, the commit should explain why the changes are being made and any notes that future readers should know for context or be aware of.
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
Pull request summary should indicate the bug the pull request addresses.
Pull request descriptions should cover at least some of the following:
- what is the issue the pull request is addressing?
- why does this pull request fix the issue?
- how should a reviewer review the pull request?
- what did you do to test the changes?
- any steps-to-reproduce for the reviewer to use to test the changes
Pull requests should be reviewed before merging.
Style nits should be covered by linting as much as possible.
Code reviews should review the changes in the context of the rest of the system.
Dependencies for production Pontoon are in
requirements.txt. Development dependencies are in
requirements-dev.txt. They need to be pinned and hashed.
For example, to add
foobar version 5:
$ hashin -r requirements.txt foobar==5
Then rebuild your docker environment:
$ make dockerbuild
If there are problems, it’ll tell you.
Documentation for Pontoon is built with Sphinx and is available on ReadTheDocs.
Building docs is not covered with docker yet, so you will have to do it on your host. To make a virtualenv to build docs, do this:
$ cd docs/ $ virtualenv venv $ source venv/bin/activate $ pip install --require-hashes -r requirements.txt
Then, to build the docs, run this:
$ make html
The HTML documentation will be in docs/_build/html/. Try to open docs/_build/html/index.html for example.
To run the tests, do:
$ make dockertest
To run specific tests or specify arguments, you’ll want to start a shell in the test container:
$ make dockershell
Then you can run tests as you like.
Running all the unittests (make sure you run
./manage.py collectstatic first):
app@...:/app$ ./manage.py test
Running a directory of tests:
app@...:/app$ ./manage.py test pontoon/base/
Running a file of tests:
app@...:/app$ ./manage.py test pontoon/base/tests/test_views.py
Put your tests in the
tests/ directory of the appropriate app in
Mock is a python library for mocks objects. This allows us to write isolated tests by simulating services beside using the real ones. Best examples is existing tests which admittedly do mocking different depending on the context.
Tip! Try to mock in limited context so that individual tests don’t affect other tests. Use context managers instead of monkey patching imported modules.
Updating Your Local Instance¶
When changes are merged to the main Pontoon repository, you’ll want to update your local development instance to reflect the latest version of the site. You can use Git as normal to pull the latest changes, but if the changes add any new dependencies or alter the database, you’ll want to install any new libraries and run any new migrations.
If you’re unsure what needs to be run, it’s safe to just perform all of these steps, as they don’t affect your setup if nothing has changed:
# Pull latest code (assuming you've already checked out master). git pull origin master # Install new dependencies or update existing ones. pip install -U --force --require-hashes -r requirements.txt # Run database migrations. python manage.py migrate
Integration with fluent¶
Pontoon is able to synchronize translations produced by libraries provided by Project Fluent and provides advanced editor for translators.
It’s important to remember to update both packages:
- python-fluent (responsible for e.g. server-side sync process)
- fluent-syntax (required by the fluent editor)
How to build the fresh version of fluent-syntax.js¶
npm install fluent-syntax cp node_modules/fluent-syntax/compat.js pontoon/base/static/js/lib/fluent-syntax.js