2019-03-08 19:03:59 +03:00
# Mozilla Experimenter
2019-03-29 18:06:09 +03:00
2017-04-28 00:24:36 +03:00
[![CircleCI ](https://circleci.com/gh/mozilla/experimenter.svg?style=svg )](https://circleci.com/gh/mozilla/experimenter)
2017-08-09 20:19:36 +03:00
< p align = "center" >
< img src = "https://cdn1.iconfinder.com/data/icons/simple-arrow/512/arrow_20-128.png" > < br / >
< b > 1. Design 2. Launch 3. Analyze< / b >
< br > < br >
< / p >
2019-03-08 19:03:59 +03:00
Experimenter is a platform for managing experiments in [Mozilla Firefox ](https://www.mozilla.org/en-US/firefox/?utm_medium=referral&utm_source=firefox-com ).
2017-08-09 20:19:36 +03:00
2018-05-23 22:43:50 +03:00
## Deployments
### Staging
2020-07-14 07:07:15 +03:00
< https: / / stage . experimenter . nonprod . dataops . mozgcp . net / >
2018-05-23 22:43:50 +03:00
### Production
2020-07-14 07:07:15 +03:00
< https: / / experimenter . services . mozilla . com / >
2018-05-23 22:43:50 +03:00
2017-04-11 22:45:02 +03:00
## Installation
2020-09-28 20:42:10 +03:00
### General Setup
2017-04-11 22:45:02 +03:00
2020-02-13 21:34:30 +03:00
1. Install [docker ](https://www.docker.com/ ) on your machine
2017-04-11 22:45:02 +03:00
2021-01-11 23:58:39 +03:00
- On linux, [setup docker to run as non-root ](https://docs.docker.com/engine/security/rootless/ )
2020-10-06 21:08:42 +03:00
2020-02-13 21:34:30 +03:00
1. Clone the repo
2017-04-11 22:45:02 +03:00
git clone < your fork >
2020-02-13 21:34:30 +03:00
1. Copy the sample env file
2017-04-11 22:45:02 +03:00
cp .env.sample .env
2020-02-13 21:34:30 +03:00
1. Set DEBUG=True for local development
2018-02-12 19:15:13 +03:00
vi .env
2020-02-13 21:34:30 +03:00
1. Create a new secret key and put it in .env
2017-04-11 22:45:02 +03:00
make secretkey
2020-02-13 21:34:30 +03:00
1. Run tests
2017-04-11 22:45:02 +03:00
make test
2020-03-17 20:35:06 +03:00
1. Setup the database
2017-05-04 23:32:01 +03:00
2020-03-17 20:35:06 +03:00
make refresh
2019-03-15 22:50:48 +03:00
2020-09-28 20:42:10 +03:00
#### Fully Dockerized Setup (continuation from General Setup 1-7)
2020-02-13 21:34:30 +03:00
1. Run a dev instance
2017-05-04 23:32:01 +03:00
make up
2017-10-16 23:33:19 +03:00
2020-02-13 21:34:30 +03:00
1. Navigate to it and add an SSL exception to your browser
2017-10-16 23:33:19 +03:00
https://localhost/
2020-09-28 20:42:10 +03:00
#### Semi Dockerized Setup (continuation from General Setup 1-7)
One might choose the semi dockerized approach for:
1. faster startup/teardown time (not having to rebuild/start/stop containers)
2020-10-06 21:08:42 +03:00
1. better ide integration
Notes:
2021-01-11 23:58:39 +03:00
- Node ^14.0.0 is required
2020-09-28 20:42:10 +03:00
2021-01-11 23:58:39 +03:00
- [osx catalina, reinstall command line tools ](https://medium.com/flawless-app-stories/gyp-no-xcode-or-clt-version-detected-macos-catalina-anansewaa-38b536389e8d )
2020-09-28 20:42:10 +03:00
2021-01-11 23:58:39 +03:00
- [poetry ](https://python-poetry.org/docs/#installation )
2020-09-28 20:42:10 +03:00
### Semi Dockerized Setup
1. Pre reqs (macOs instructions)
brew install postgresql llvm openssl yarn
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
2. Install dependencies
source .env
poetry install (cd into app)
yarn install
3. env values
.env (set at root):
DEBUG=True
DB_HOST=localhost
HOSTNAME=localhost
4. Start postgresql, redis, autograph, kinto
make up_db
5. Django app
# in app
poetry shell
yarn workspace @experimenter/nimbus -ui build
yarn workspace @experimenter/core build
./manage.py runserver 0.0.0.0:7001
2017-04-11 22:45:02 +03:00
2020-09-24 18:00:48 +03:00
Pro-tip: we have had at least one large code refactor. You can ignore specific large commits when blaming by setting the Git config's `ignoreRevsFile` to `.git-blame-ignore-revs` :
```
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
2020-11-12 23:13:17 +03:00
### Google Credentials
On certain pages an API endpoint is called to receive experiment analysis data from Jetstream to display visualization tables. To see experiment visualization data, you must provide GCP credentials.
1. Generate a GCP private key file.
2021-01-11 23:58:39 +03:00
- Ask in #experimenter for the GCP link to create a new key file.
- Add Key > Create New Key > JSON > save this file.
- Do not lose or share this file. It's unique to you and you'll only get it once.
2020-11-12 23:13:17 +03:00
2. Rename the file to `google-credentials.json` and place it anywhere inside the `/app` directory.
3. Update your `.env` so that `GOOGLE_APPLICATION_CREDENTIALS` points to this file. If your file is inside the `/app` directory it would look like this:
2021-01-11 23:58:39 +03:00
```
GOOGLE_APPLICATION_CREDENTIALS=/app/google-credentials.json
```
2020-11-12 23:13:17 +03:00
2017-04-11 22:45:02 +03:00
## Usage
2019-03-08 19:03:59 +03:00
Experimenter uses [docker ](https://www.docker.com/ ) for all development, testing, and deployment.
2017-04-11 22:45:02 +03:00
The following helpful commands have been provided via a Makefile:
### build
2020-02-13 21:34:30 +03:00
2020-07-03 00:12:25 +03:00
Build the application container by executing the [build script ](https://github.com/mozilla/experimenter/blob/main/scripts/build.sh )
2017-04-11 22:45:02 +03:00
### compose_build
2020-02-13 21:34:30 +03:00
2020-07-03 00:12:25 +03:00
Build the supporting services (nginx, postgresql) defined in the [compose file ](https://github.com/mozilla/experimenter/blob/main/docker-compose.yml )
2017-04-11 22:45:02 +03:00
### up
2020-02-13 21:34:30 +03:00
2017-04-11 22:45:02 +03:00
Start a dev server listening on port 80 using the [Django runserver ](https://docs.djangoproject.com/en/1.10/ref/django-admin/#runserver )
2020-09-12 00:12:46 +03:00
### up_db
2020-02-13 21:34:30 +03:00
2020-09-12 00:12:46 +03:00
Start postgresql, redis, autograph, kinto on their respective ports to allow running the Django runserver and yarn watchers locally (non containerized)
2017-04-11 22:45:02 +03:00
2020-09-12 00:12:46 +03:00
### up_django
2020-02-13 21:34:30 +03:00
2020-09-12 00:12:46 +03:00
Start Django runserver, Celery worker, postgresql, redis, autograph, kinto on their respective ports to allow running the yarn watchers locally (non containerized)
### up_detached
Start all containers in the background (not attached to shell)
2017-04-11 22:45:02 +03:00
### check
2020-02-13 21:34:30 +03:00
2020-09-12 00:12:46 +03:00
Run all test and lint suites, this is run in CI on all PRs and deploys
2017-04-11 22:45:02 +03:00
2020-11-17 03:55:59 +03:00
### py_test
Run python tests
2017-04-11 22:45:02 +03:00
### migrate
2020-02-13 21:34:30 +03:00
2017-04-11 22:45:02 +03:00
Apply all django migrations
2019-04-05 22:50:21 +03:00
### load_locales_countries
2020-02-13 21:34:30 +03:00
2019-04-05 22:50:21 +03:00
Populates locales and countries
### load_dummy_experiments
2020-02-13 21:34:30 +03:00
2019-04-05 22:50:21 +03:00
Populates db with dummy experiments
2017-04-11 22:45:02 +03:00
### bash
2020-02-13 21:34:30 +03:00
2020-09-12 00:12:46 +03:00
Start a bash shell inside the container (this lets you interact with the containerized filesystem and run Django management commands)
2017-04-11 22:45:02 +03:00
2017-10-16 23:33:19 +03:00
### ssl
2020-02-13 21:34:30 +03:00
2017-10-18 00:58:04 +03:00
Create dummy SSL certs to use the dev server over a locally secure
connection. This helps test client behaviour with a secure
connection. This task is run automatically when needed.
2017-10-16 23:33:19 +03:00
2018-02-12 19:15:13 +03:00
### kill
2020-02-13 21:34:30 +03:00
2019-03-08 19:03:59 +03:00
Stop and delete all docker containers.
2020-02-13 21:34:30 +03:00
WARNING: this will remove your database and all data. Use this to reset your dev environment.
2018-02-12 19:15:13 +03:00
2019-04-05 22:50:21 +03:00
### refresh
2020-02-13 21:34:30 +03:00
2020-03-17 20:35:06 +03:00
Run kill, migrate, load_locales_countries load_dummy_experiments
2019-04-05 22:50:21 +03:00
2020-03-17 20:35:06 +03:00
### integration_test
2020-07-14 07:07:15 +03:00
Run the integration test suite inside a containerized instance of Firefox. You must also be already running a `make up` dev instance in another shell to run the integration tests.
2020-03-17 20:35:06 +03:00
### integration_vnc_up
2020-07-14 07:07:15 +03:00
Start a linux VM container with VNC available over `vnc://localhost:5900` with password `secret` . Right click on the desktop and select `Applications > Shell > Bash` and enter `tox -c tests/integration/` to run the integration tests and watch them run in a Firefox instance you can watch and interact with.
2019-10-15 18:34:04 +03:00
2020-09-24 18:00:48 +03:00
## Frontend
2021-01-11 23:58:39 +03:00
Experimenter has two front-end UIs:
2020-09-24 18:00:48 +03:00
2021-01-11 23:58:39 +03:00
- [`core` ](./app/experimenter/legacy-ui/core ) is the legacy UI used for Experimenter intake which will remain until `nimbus-ui` supersedes it
- [`nimbus-ui` ](./app/experimenter/nimbus-ui ) is the Nimbus Console UI for Experimenter that is actively being developed
2020-09-24 18:00:48 +03:00
Learn more about the organization of these UIs [here ](./app/experimenter/legacy-ui/README.md ).
2021-01-11 23:58:39 +03:00
**Also see the [nimbus-ui README ](https://github.com/mozilla/experimenter/tree/main/app/experimenter/nimbus-ui ) for relevent Nimbus documentation.**
2017-05-04 23:32:01 +03:00
## API
2020-07-03 00:12:25 +03:00
API documentation can be found [here ](https://htmlpreview.github.io/?https://github.com/mozilla/experimenter/blob/main/app/experimenter/docs/swagger-ui.html )
2017-09-07 20:39:26 +03:00
2017-04-11 22:45:02 +03:00
## Contributing
2020-07-03 00:12:25 +03:00
Please see our [Contributing Guidelines ](https://github.com/mozilla/experimenter/blob/main/contributing.md )
2017-04-11 22:45:02 +03:00
## License
Experimenter uses the [Mozilla Public License ](https://www.mozilla.org/en-US/MPL/ )