Installation

Prerequisites

If you only want to hack on the frontend, see the UI Development section below. If you want to hack on the backend or work full-stack, see the Server and Full-stack Development section.

UI Development

To get started:

  • Install Node.js and Yarn (see package.json for known compatible versions, listed under engines).
  • Run yarn install to install all dependencies.

Running the standalone development server

The default development server runs the unminified UI and fetches data from the production site. You do not need to set up the Docker environment unless making backend changes.

  • Start the development server by running:

    yarn start
    

    Note

    Any action you take, such as classifying a job, will affect the live production front-end of Treeherder, so we recommend developing against stage (details below) unless there's something data-specific that must be addressed on production.

  • The server will perform an initial build and then watch for new changes. Once the server is running, you can navigate to: http://localhost:5000 to see the UI.

    To run the unminified UI with data from the staging site instead of the production site, type:

    yarn start:stage
    

Server and Full-stack Development

To get started:

  • Install Docker & docker-compose (both are installed if using Docker for Windows/Mac).
  • If you just wish to run the tests, you can stop now without performing the remaining steps.

Starting a local Treeherder instance

  • Open a shell, cd into the root of the Treeherder repository, and type:

    docker-compose up --build
    
  • Wait for the Docker images to be downloaded/built and container steps to complete.

Both Django's runserver and webpack-dev-server will automatically refresh every time there's a change in the code.

Note

There will be no data to display until the ingestion tasks are run.

Running the migrations

To run the Django migrations:

docker-compose run backend sh -c "./initialize_data.sh"

Using the minified UI

If you would like to use the minified production version of the UI with the development backend:

  • Run the build task:

    docker-compose run frontend sh -c "yarn && yarn build"
    
  • Start Treeherder's backend:

    docker-compose up --build
    

Requests to port 8000 skip webpack-dev-server, causing Django's runserver to serve the production UI from .build/ instead. In addition to being minified and using the non-debug versions of React, the assets are served with the same Content-Security-Policy header as production.

Running full stack with a custom DB setting

If you want to develop both the frontend and backend, but have the database pointing to an external DB host, you have a few choices. The environment variable of DATABASE_URL is what needs to be set. You can do this in a file in the root of /treeherder called .env:

DATABASE_URL=mysql://user:password@hostname/treeherder

Alternatively, you can export that value in your terminal prior to executing docker-compose up or just specify it on the command line as you execute:

DATABASE_URL=mysql://user:password@hostname/treeherder docker-compose up

Running the ingestion tasks

Ingestion tasks populate the database with version control push logs, queued/running/completed jobs & output from log parsing, as well as maintain a cache of intermittent failure bugs. To run these:

  • Start up a celery worker to process async tasks:

    docker-compose run backend celery -A treeherder worker -B --concurrency 5
    

    The "-B" option tells the celery worker to startup a beat service, so that periodic tasks can be executed. You only need one worker with the beat service enabled. Multiple beat services will result in periodic tasks being executed multiple times.

  • Then in a new terminal window, run docker-compose run backend bash, and follow the steps from the loading pulse data page.

Manual ingestion

NOTE; You have to include --root-url https://community-tc.services.mozilla.com in order to ingest from the Taskcluster Community instance, otherwise, it will default to the Firefox CI.

Ingesting pushes & tasks

docker-compose run backend ./manage.py ingest push -p autoland -r 63f8a47cfdf5

NOTE: In the future you will also be able to append --ingest-all-tasks to ingest all tasks.

Ingesting a range of pushes

It is also possible to ingest the last N pushes for a repository:

docker-compose run backend ./manage.py ingest_push mozilla-central --last-n-pushes 100

In this mode, only the push information will be ingested: tasks associated with the pushes will not. This mode is useful to seed pushes so they are visible on the web interface and so you can easily copy and paste changesets from the web interface into subsequent commands to ingest all tasks.

Ingesting Github PRs

NOTE: This will only ingest the commits if there's an active Github PRs project. It will only ingest the commits.

docker-compose run backend ./manage.py ingest pr --pr-url https://github.com/mozilla-mobile/android-components/pull/4821

Ingesting individual task

This will work if the push associated to the task exists in the database.

# Make sure to ingest 1bd9d4f431c4c9f93388bd04a6368cb07398f646 for autoland first
docker-compose run backend ./manage.py ingest task --task-id KQ5h1BVYTBy_XT21wFpLog

Learn more

Continue to Working with the Server section after looking at the Code Style doc.