Skip to content

Commit e6e909e

Browse files
authored
Docs to onboard contributor (#440)
1 parent a91e597 commit e6e909e

File tree

10 files changed

+136
-10
lines changed

10 files changed

+136
-10
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[settings]
22
known_first_party = code_coverage_backend,code_coverage_bot,code_coverage_events,code_coverage_tools,conftest,firefox_code_coverage
3-
known_third_party = connexion,datadog,dateutil,fakeredis,flask,flask_cors,flask_talisman,google,hglib,jsone,jsonschema,libmozdata,libmozevent,logbook,magic,pytest,pytz,raven,redis,requests,responses,setuptools,structlog,taskcluster,tenacity,werkzeug,zstandard
3+
known_third_party = connexion,datadog,dateutil,fakeredis,flask,flask_cors,flask_talisman,google,hglib,jsone,jsonschema,libmozdata,libmozevent,logbook,magic,pytest,pytz,raven,redis,requests,responses,setuptools,structlog,taskcluster,tenacity,werkzeug,yaml,zstandard
44
force_single_line = True
55
default_section=FIRSTPARTY
66
line_length=159

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ This project has 4 parts:
66
* `backend` is a Python API built with Flask, that serves the aggregated code coverage data, in an efficient way,
77
* `frontend` is a vanilla Javascript SPA displaying code coverage data in your browser,
88
* `addon` is a Web Extension for Firefox, extending several Mozilla websites with code coverage data.
9+
10+
## Help
11+
12+
You can reach us on our Matrix instance: [#codecoverage:mozilla.org](https://chat.mozilla.org/#/room/#codecoverage:mozilla.org)

backend/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,27 @@ docker run -v /tmp/ccov-redis:/data -p 6379:6379 redis
3737

3838
The development webserver will run on **http://localhost:8000**
3939

40-
Using default secret `project-relman/code-coverage/dev`:
40+
You need to setup a local YAML configuration file, with the following content:
41+
42+
```yaml
43+
---
44+
common:
45+
APP_CHANNEL: dev
46+
GOOGLE_CLOUD_STORAGE: null
47+
```
48+
49+
Using your local configuration:
4150
4251
```shell
43-
./run.sh
52+
LOCAL_CONFIGURATION=/path/to/code-coverage-conf.yml ./run.sh
4453
```
4554

46-
You can specify any other secret as:
55+
You can specify a firefox-ci Taskcluster secret (e.g. project-relman/code-coverage/dev) instead using:
4756

4857
```shell
4958
TASKCLUSTER_SECRET=path/to/secret ./run.sh
5059
```
60+
61+
## Help
62+
63+
You can reach us on our Matrix instance: [#codecoverage:mozilla.org](https://chat.mozilla.org/#/room/#codecoverage:mozilla.org)

backend/code_coverage_backend/backend/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os.path
77

88
import structlog
9+
import yaml
910

1011
import code_coverage_backend.datadog
1112
import code_coverage_backend.gcp
@@ -17,12 +18,20 @@
1718

1819
def create_app():
1920
# Load secrets from Taskcluster
21+
local_secrets_path = os.environ.get("LOCAL_CONFIGURATION")
22+
if local_secrets_path is not None:
23+
assert os.path.exists(
24+
local_secrets_path
25+
), f"Invalid local secrets path {local_secrets_path}"
2026
taskcluster.auth()
2127
taskcluster.load_secrets(
2228
os.environ.get("TASKCLUSTER_SECRET"),
2329
prefixes=["common", "backend", "code-coverage-backend"],
2430
required=["GOOGLE_CLOUD_STORAGE", "APP_CHANNEL"],
2531
existing={"REDIS_URL": os.environ.get("REDIS_URL", "redis://localhost:6379")},
32+
local_secrets=yaml.safe_load(open(local_secrets_path))
33+
if local_secrets_path
34+
else None,
2635
)
2736

2837
# Configure logger

backend/code_coverage_backend/datadog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_stats():
2525

2626
app_channel = taskcluster.secrets["APP_CHANNEL"]
2727

28-
if taskcluster.secrets["DATADOG_API_KEY"]:
28+
if taskcluster.secrets.get("DATADOG_API_KEY"):
2929
datadog.initialize(
3030
api_key=taskcluster.secrets["DATADOG_API_KEY"],
3131
host_name=f"coverage.{app_channel}.moz.tools",

bot/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Code Coverage Bot
2+
3+
This project runs as [Taskcluster hooks](https://firefox-ci-tc.services.mozilla.com/hooks) on the firefox-ci instance, to extract and store the code coverage information from mozilla-central and try builds.
4+
5+
It's built using Python 3.8 and few dependencies.
6+
7+
## Developer setup
8+
9+
Requirements:
10+
11+
- Python 3.8
12+
- Mercurial 5.3
13+
- (optional) [virtualenv](https://virtualenv.pypa.io/en/stable/)
14+
- (optional) [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)
15+
16+
Setup on your computer:
17+
18+
```console
19+
# If you have virtualenvwrapper:
20+
mkvirtualenv -p /usr/bin/python3.8 code-coverage-bot
21+
22+
# Mandatory steps
23+
pip install -r requirements.txt -r requirements-dev.txt
24+
pip install -e .
25+
pre-commit install
26+
```
27+
28+
Check linting (it should be automatically done before any commit):
29+
30+
```console
31+
pre-commint run -a
32+
```
33+
34+
Check unit tests:
35+
36+
```console
37+
pytest -v
38+
```
39+
40+
Write your local configuration as YAML:
41+
42+
```yaml
43+
---
44+
common:
45+
APP_CHANNEL: dev
46+
bot:
47+
BACKEND_HOST: 'http://localhost:8000'
48+
EMAIL_ADDRESSES: []
49+
PHABRICATOR_TOKEN: api-xxx
50+
PHABRICATOR_ENABLED: false
51+
PHABRICATOR_URL: 'https://phabricator-dev.allizom.org/api/'
52+
GOOGLE_CLOUD_STORAGE: null
53+
```
54+
55+
Run the bot (in cron mode):
56+
57+
```console
58+
mkdir -p build/{cache,work} # or elsewhere on your system
59+
code-coverage-cron --cache-root=build/cache --working-dir=build/work --local-configuration=path/to/code-coverage.yml
60+
```
61+
62+
The repo mode (with `code-coverage-repo`) is harder to use, as it requires a Google Cloud Storage and a Phabricator account.
63+
64+
## Help
65+
66+
You can reach us on our Matrix instance: [#codecoverage:mozilla.org](https://chat.mozilla.org/#/room/#codecoverage:mozilla.org)

bot/code_coverage_bot/cli.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import argparse
77
import os
88

9+
import yaml
10+
911
from code_coverage_bot.secrets import secrets
1012
from code_coverage_bot.taskcluster import taskcluster_config
1113
from code_coverage_tools.log import init_logger
@@ -38,6 +40,11 @@ def setup_cli(ask_repository=True, ask_revision=True):
3840
help="Taskcluster Secret path",
3941
default=os.environ.get("TASKCLUSTER_SECRET"),
4042
)
43+
parser.add_argument(
44+
"--local-configuration",
45+
help="Path to a local YAML configuration file",
46+
type=open,
47+
)
4148
parser.add_argument("--taskcluster-client-id", help="Taskcluster Client ID")
4249
parser.add_argument("--taskcluster-access-token", help="Taskcluster Access token")
4350
args = parser.parse_args()
@@ -46,7 +53,12 @@ def setup_cli(ask_repository=True, ask_revision=True):
4653
taskcluster_config.auth(args.taskcluster_client_id, args.taskcluster_access_token)
4754

4855
# Then load secrets
49-
secrets.load(args.taskcluster_secret)
56+
secrets.load(
57+
args.taskcluster_secret,
58+
local_secrets=yaml.safe_load(args.local_configuration)
59+
if args.local_configuration
60+
else None,
61+
)
5062

5163
init_logger(
5264
"bot",

bot/code_coverage_bot/secrets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class Secrets(dict):
1515
PHABRICATOR_TOKEN = "PHABRICATOR_TOKEN"
1616
GOOGLE_CLOUD_STORAGE = "GOOGLE_CLOUD_STORAGE"
1717

18-
def load(self, taskcluster_secret):
18+
def load(self, taskcluster_secret=None, local_secrets=None):
1919
taskcluster_config.load_secrets(
2020
taskcluster_secret,
21-
prefixes=["common", "code-coverage-bot"],
21+
prefixes=["common", "bot"],
2222
required=[
2323
Secrets.APP_CHANNEL,
2424
Secrets.BACKEND_HOST,
@@ -27,6 +27,7 @@ def load(self, taskcluster_secret):
2727
Secrets.PHABRICATOR_URL,
2828
Secrets.PHABRICATOR_TOKEN,
2929
],
30+
local_secrets=local_secrets,
3031
)
3132
self.update(taskcluster_config.secrets)
3233

frontend/README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Mozilla Code Coverage frontend
22
This is a simple JavaScript application displaying information from the Mozilla code coverage backend (hosted as https://coverage.moz.tools)
33

4-
You can use it right now from [mozilla.github.io/code-coverage-reports](https://mozilla.github.io/code-coverage-reports/)
4+
You can use it right now from [coverage.moz.tools](https://coverage.moz.tools/)
55

66
## File viewer
77

@@ -11,4 +11,25 @@ You can browse the aggregated code coverage data for mozilla-central, per direct
1111

1212
## Zero coverage reports
1313

14-
We've also [developed a page](https://mozilla.github.io/code-coverage-reports/zero_coverage_report.html) to easily browse the directories & files with no coverage: these files are interesting because they can sometimes be removed altogether from mozilla-central...
14+
We've also [developed a page](https://coverage.moz.tools/#view=zero) to easily browse the directories & files with no coverage: these files are interesting because they can sometimes be removed altogether from mozilla-central...
15+
16+
## Developer setup
17+
18+
It's a pretty simple Single Page application setup using webpack:
19+
20+
```console
21+
npm install
22+
npm run start
23+
```
24+
25+
The frontend should now be available on http://localhost:9000/ and will use a backend running on http://localhost:8000/
26+
27+
You can specify another remote backend like so:
28+
29+
```
30+
BACKEND_URL=https://api.coverage.moz.tools npm run start
31+
```
32+
33+
## Help
34+
35+
You can reach us on our Matrix instance: [#codecoverage:mozilla.org](https://chat.mozilla.org/#/room/#codecoverage:mozilla.org)

frontend/screenshot.png

27.9 KB
Loading

0 commit comments

Comments
 (0)