When I started my internship at Mozilla, one of the biggest challenges I faced was setting up my environment and getting my tests to pass. Treeherder setup, in particular, required multiple steps, and while the documentation was helpful, I had to piece together some additional details to get everything running smoothly. Eventually, I figured it out and created a system that worked for me. I'm documenting it here to help new interns or programmers navigate and overcome these setup hurdles.
PerfCompare Setup
PerfCompare is pretty straightforward to set up since the setup process is well outlined in the repository README. Here’s what worked for me:
Fork the repository: Mozilla PerfCompare
Clone your forked repo:
git clone https://github.com/YOUR_GITHUB_USERNAME/perfcompare.git
Install dependencies and run the app:
npm install npm run dev
Create a new branch:
git checkout -b new-branch-name
Make changes and fix linting issues:
npm run fix-all # Runs linting, test coverage, updates snapshots, and fixes lint errors
Stage and commit your changes:
git add . git commit -m "Describe your changes"
Rebase with the upstream branch:
git fetch upstream git rebase upstream/main
- If there are conflicts, resolve them and commit.
Push changes to your branch:
git push --force origin new-branch-name
Create a pull request on GitHub:
Be descriptive.
Attach relevant screenshots.
Add deployment and Bugzilla links where necessary.
PerfCompare Documentation: User Guide | How to use PerfCompare
Treeherder Setup
Treeherder was trickier to set up, especially on Windows. Here’s what worked for me:
Fork the repository: Mozilla Treeherder
Clone your forked repo:
git clone https://github.com/YOUR_GITHUB_USERNAME/treeherder.git
Ensure Docker and Docker Compose are installed:
On Windows, make sure WSL is properly configured.
Install Docker Desktop.
Sometimes,
docker-compose up
fails unless Docker Desktop is open. Keep this in mind when starting services.
Set up the test database:
Move the provided test database file (decompressed SQL file) to the root folder.
Run:
psql -h localhost -U postgres -W < treeherder.sql
Start services:
docker-compose up --build
After creating services, you don’t need to use the
--build
flag every time. Just run:docker-compose up
Access the database:
psql -h localhost -U postgres -d treeherder
- Login with password:
mozilla1234
- Login with password:
Access the backend service:
docker-compose exec backend bash
Run Python scripts:
docker-compose exec backend python manage.py shell
Set up pre-commit hooks (optional but helpful):
pre-commit install pre-commit run --all-files
Running Tests
Before running tests:
Ensure you're inside the backend service:
docker-compose exec backend bash
Run all tests:
pytest tests
- This takes time but ensures everything is working.
Run specific test files:
pytest tests/webapp/api/test_push_api.py
Run a specific test within a test file:
pytest tests/webapp/api/test_push_api.py::test_push_search
Handling Migrations
Create a new migration:
python manage.py makemigrations
Apply migrations:
python manage.py migrate
Rollback to a previous migration:
python manage.py migrate yourappname previous_migration_name
Pushing Changes
Stage changes:
git add .
Commit changes:
git commit -m "Describe your changes"
Rebase with the upstream branch:
git fetch upstream git rebase upstream/master
- If there are conflicts, resolve them and commit.
Push changes:
git push --force origin new-branch-name
Treeherder Documentation: Installation Guide | User Guide
These are some of the commands that helped me implement Full-text Search in PerfCompare. I hope this helps future interns or contributors overcome the setup hurdles!