Skip to content

bot: Export main report as Taskcluster artifact, fixes #151 #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bot/code_coverage_bot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def setup_cli(ask_repository=True, ask_revision=True):
parser.add_argument(
"--cache-root", required=True, help="Cache root, used to pull changesets"
)
parser.add_argument(
"--working-dir",
required=True,
help="Working dir to download artifacts and build reports",
)
parser.add_argument(
"--task-name-filter",
default="*",
Expand Down
20 changes: 15 additions & 5 deletions bot/code_coverage_bot/hooks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
import tempfile
from datetime import datetime
from datetime import timedelta

Expand All @@ -26,11 +25,22 @@

class Hook(object):
def __init__(
self, repository, revision, task_name_filter, cache_root, required_platforms=[]
self,
repository,
revision,
task_name_filter,
cache_root,
working_dir,
required_platforms=[],
):
temp_dir = tempfile.mkdtemp()
self.artifacts_dir = os.path.join(temp_dir, "ccov-artifacts")
self.reports_dir = os.path.join(temp_dir, "ccov-reports")
os.makedirs(working_dir, exist_ok=True)
self.artifacts_dir = os.path.join(working_dir, "ccov-artifacts")
self.reports_dir = os.path.join(working_dir, "ccov-reports")
logger.info(
"Local storage initialized.",
artifacts=self.artifacts_dir,
reports=self.reports_dir,
)

self.repository = repository
self.revision = revision
Expand Down
2 changes: 1 addition & 1 deletion bot/code_coverage_bot/hooks/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ def run(self):
def main():
logger.info("Starting code coverage bot for cron")
args = setup_cli(ask_revision=False, ask_repository=False)
hook = CronHook(args.task_name_filter, args.cache_root)
hook = CronHook(args.task_name_filter, args.cache_root, args.working_dir)
hook.run()
4 changes: 3 additions & 1 deletion bot/code_coverage_bot/hooks/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,7 @@ def main():
hook_class = hooks.get(args.repository)
assert hook_class is not None, f"Unsupported repository {args.repository}"

hook = hook_class(args.revision, args.task_name_filter, args.cache_root)
hook = hook_class(
args.revision, args.task_name_filter, args.cache_root, args.working_dir
)
hook.run()
4 changes: 3 additions & 1 deletion bot/taskcluster-hook-cron.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"--taskcluster-secret",
"project/relman/code-coverage/runtime-CHANNEL",
"--cache-root",
"/cache"
"/cache",
"--working-dir",
"/build"
],
"env": {},
"features": {
Expand Down
12 changes: 11 additions & 1 deletion bot/taskcluster-hook-repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
"source": "https://github.com/mozilla/code-coverage"
},
"payload": {

"artifacts": {
"public/code-coverage-report.json": {
"expires": {"$fromNow": "2 weeks"},
"path": "/build/ccov-reports/all.all.json",
"type": "file"
}
},
"cache": {
"code-coverage-bot-CHANNEL": "/cache"
},
Expand All @@ -50,7 +58,9 @@
"--taskcluster-secret",
"project/relman/code-coverage/runtime-CHANNEL",
"--cache-root",
"/cache"
"/cache",
"--working-dir",
"/build"
],
"env": {
"$eval": "payload"
Expand Down