Skip to content

Commit 0ff7804

Browse files
author
Bastien Abadie
committed
bot: Export main report as Taskcluster artifact, fixes #151
1 parent dcac151 commit 0ff7804

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

bot/code_coverage_bot/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def setup_cli(ask_repository=True, ask_revision=True):
2424
parser.add_argument(
2525
"--cache-root", required=True, help="Cache root, used to pull changesets"
2626
)
27+
parser.add_argument(
28+
"--working-dir",
29+
help="Optional working dir to download artifacts and build reports",
30+
)
2731
parser.add_argument(
2832
"--task-name-filter",
2933
default="*",

bot/code_coverage_bot/hooks/base.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,25 @@
2626

2727
class Hook(object):
2828
def __init__(
29-
self, repository, revision, task_name_filter, cache_root, required_platforms=[]
29+
self,
30+
repository,
31+
revision,
32+
task_name_filter,
33+
cache_root,
34+
working_dir=None,
35+
required_platforms=[],
3036
):
31-
temp_dir = tempfile.mkdtemp()
32-
self.artifacts_dir = os.path.join(temp_dir, "ccov-artifacts")
33-
self.reports_dir = os.path.join(temp_dir, "ccov-reports")
37+
if working_dir is None:
38+
working_dir = tempfile.mkdtemp()
39+
else:
40+
os.makedirs(working_dir, exist_ok=True)
41+
self.artifacts_dir = os.path.join(working_dir, "ccov-artifacts")
42+
self.reports_dir = os.path.join(working_dir, "ccov-reports")
43+
logger.info(
44+
"Local storage initialized.",
45+
artifacts=self.artifacts_dir,
46+
reports=self.reports_dir,
47+
)
3448

3549
self.repository = repository
3650
self.revision = revision

bot/code_coverage_bot/hooks/cron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ def run(self):
6767
def main():
6868
logger.info("Starting code coverage bot for cron")
6969
args = setup_cli(ask_revision=False, ask_repository=False)
70-
hook = CronHook(args.task_name_filter, args.cache_root)
70+
hook = CronHook(args.task_name_filter, args.cache_root, args.working_dir)
7171
hook.run()

bot/code_coverage_bot/hooks/repo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,7 @@ def main():
220220
hook_class = hooks.get(args.repository)
221221
assert hook_class is not None, f"Unsupported repository {args.repository}"
222222

223-
hook = hook_class(args.revision, args.task_name_filter, args.cache_root)
223+
hook = hook_class(
224+
args.revision, args.task_name_filter, args.cache_root, args.working_dir
225+
)
224226
hook.run()

bot/taskcluster-hook-repo.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"source": "https://github.com/mozilla/code-coverage"
4242
},
4343
"payload": {
44+
45+
"artifacts": {
46+
"public/code-coverage-report.json": {
47+
"expires": {"$fromNow": "2 weeks"},
48+
"path": "/build/ccov-reports/all:all.json",
49+
"type": "file"
50+
}
51+
},
4452
"cache": {
4553
"code-coverage-bot-CHANNEL": "/cache"
4654
},
@@ -50,7 +58,9 @@
5058
"--taskcluster-secret",
5159
"project/relman/code-coverage/runtime-CHANNEL",
5260
"--cache-root",
53-
"/cache"
61+
"/cache",
62+
"--working-dir",
63+
"/build"
5464
],
5565
"env": {
5666
"$eval": "payload"

0 commit comments

Comments
 (0)