Skip to content

Commit

Permalink
Backend cleanup (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
La0 committed Jul 18, 2019
1 parent f0a6558 commit d24e850
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 43 deletions.
51 changes: 51 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Mozilla Code Coverage Backend

This project is a Python 3 REST API, powered by [Flask](https://palletsprojects.com/p/flask/) that serves code coverage data aggregated by the bot project.

The production instance of this service is hosted on https://api.coverage.moz.tools

We currently have several endpoints implemented:

* `/v2/extensions` lists all the file extensions supported by the code coverage suite,
* `/v2/latest` lists the 10 latest code coverage reports ingested on the backend and available to query,
* `/v2/history` shows the code coverage progression for a specific path in a repository,
* `/v2/path` provides the code coverage information for a directory or file in a repository, at a given revision.


## Setup instructions for developpers

```shell
mkvirtualenv -p /usr/bin/python3 ccov-backend
cd backend/
pip install -r requirements.txt -r requirements-dev.txt
pip install -e .
```

You should now be able to run tests and linting:

```shell
pytest
flake8
```

## Run a redis instance through docker

```shell
docker run -v /tmp/ccov-redis:/data -p 6379:6379 redis
```

## Run the webserver

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

Using default secret `project-relman/code-coverage/dev`:

```shell
./run.sh
```

You can specify any other secret as:

```shell
TASKCLUSTER_SECRET=path/to/secret ./run.sh
```
25 changes: 0 additions & 25 deletions backend/code_coverage_backend/worker.py

This file was deleted.

5 changes: 1 addition & 4 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

responses
aresponses
fakeredis
flake8
flake8-isort
pytest==4.3.1
pytest
responses
6 changes: 0 additions & 6 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

aiohttp
async-lru
cachetools
connexion
datadog
-e ../tools #egg=code-coverage-tools
Expand All @@ -12,7 +8,5 @@ gunicorn
python-dateutil
pytoml
redis
rq
setuptools-scm # needed by py-1.5.4 buildInputs
swagger-ui-bundle
zstandard
29 changes: 23 additions & 6 deletions backend/requirements_frozen.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
aiohttp==3.5.4
async-lru==1.0.2
async-timeout==3.0.1
atomicwrites==1.3.0
attrs==19.1.0
cachetools==3.1.1
certifi==2019.6.16
cffi==1.12.3
chardet==3.0.4
Click==7.0
clickclick==1.2.2
-e git+git@github.com:mozilla/code-coverage.git@d7773e78fe674df4bc745ea47b5cc184ef520af7#egg=code_coverage_tools&subdirectory=tools
connexion==2.3.0
datadog==0.29.3
decorator==4.4.0
entrypoints==0.3
fakeredis==1.0.3
flake8==3.7.8
flake8-isort==2.7.0
Flask==1.1.1
Flask-Cors==3.0.8
flask-talisman==0.7.0
Expand All @@ -24,37 +27,51 @@ googleapis-common-protos==1.6.0
gunicorn==19.9.0
idna==2.8
idna-ssl==1.1.0
importlib-metadata==0.18
inflection==0.3.1
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.10.1
jsonschema==2.6.0
Logbook==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
mohawk==1.0.0
more-itertools==7.1.0
multidict==4.5.2
openapi-spec-validator==0.2.7
packaging==19.0
pkg-resources==0.0.0
pluggy==0.12.0
protobuf==3.9.0
py==1.8.0
pyasn1==0.4.5
pyasn1-modules==0.2.5
pycodestyle==2.5.0
pycparser==2.19
pyflakes==2.1.1
pyparsing==2.4.0
pytest==5.0.1
python-dateutil==2.8.0
pytoml==0.1.20
pytz==2019.1
PyYAML==5.1.1
redis==3.2.1
requests==2.22.0
rq==1.0
responses==0.10.6
rsa==4.0
setuptools-scm==3.3.3
six==1.12.0
slugid==2.0.0
sortedcontainers==2.1.0
structlog==19.1.0
swagger-ui-bundle==0.0.5
taskcluster==7.0.1
taskcluster==14.3.1
taskcluster-urls==11.0.0
testfixtures==6.10.0
typing-extensions==3.7.4
urllib3==1.25.3
Werkzeug==0.15.4
wcwidth==0.1.7
Werkzeug==0.15.5
yarl==1.3.0
zipp==0.5.2
zstandard==0.11.1
5 changes: 4 additions & 1 deletion backend/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
export TASKCLUSTER_SECRET="project/relman/code-coverage/dev"
if [[ ! $TASKCLUSTER_SECRET ]]; then
export TASKCLUSTER_SECRET="project/relman/code-coverage/dev"
echo 'Using dev secret'
fi
gunicorn --bind localhost:8000 --reload --reload-engine=poll --log-file=- code_coverage_backend.flask:app
2 changes: 1 addition & 1 deletion backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read_requirements(file_):
description='The code behind https://coverage.moz.tools',
author='Mozilla Release Management',
author_email='release-mgmt-analysis@mozilla.com',
url='https://coverage.moz.tools',
url='https://api.coverage.moz.tools',
tests_require=read_requirements('requirements-dev.txt'),
install_requires=read_requirements('requirements.txt'),
packages=find_packages(),
Expand Down

0 comments on commit d24e850

Please sign in to comment.