Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #4507 Enable codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
colintheshots committed Aug 7, 2019
1 parent 8194e07 commit 96f0261
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion automation/taskcluster/decision_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def pr():

for variant in get_variants_for_build_type('debug'):
assemble_task_id = taskcluster.slugId()
build_tasks[assemble_task_id] = BUILDER.craft_assemble_task(variant)
build_tasks[assemble_task_id] = BUILDER.craft_assemble_pr_task(variant, True)
build_tasks[taskcluster.slugId()] = BUILDER.craft_test_task(variant)

for craft_function in (
Expand Down
25 changes: 20 additions & 5 deletions automation/taskcluster/lib/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,22 @@ def craft_assemble_raptor_task(self, variant):
},
)

def craft_assemble_task(self, variant):
def craft_assemble_pr_task(self, variant, run_coverage=False):
coverage_flag = '-Pcoverage ' if run_coverage else ''
assemble_gradle_command = ('{} assemble{}'.format(coverage_flag, variant.for_gradle_command),)
post_gradle_command = ('automation/taskcluster/upload_coverage_report.sh' if run_coverage else '',)

command = ' && '.join(
cmd
for commands in (assemble_gradle_command, post_gradle_command)
for cmd in commands
if cmd
)

return self._craft_clean_gradle_task(
name='assemble: {}'.format(variant.raw),
description='Building and testing variant {}'.format(variant.raw),
gradle_task='assemble{}'.format(variant.for_gradle_command),
gradle_task=command,
artifacts=_craft_artifacts_from_variant(variant),
treeherder={
'groupSymbol': variant.build_type,
Expand All @@ -144,6 +155,9 @@ def craft_assemble_task(self, variant):
'symbol': 'A',
'tier': 1,
},
scopes=[
'secrets:get:project/mobile/fenix/pr'
]
)

def craft_test_task(self, variant):
Expand Down Expand Up @@ -299,7 +313,7 @@ def craft_dependencies_task(self):
)

def _craft_clean_gradle_task(
self, name, description, gradle_task, artifacts=None, routes=None, treeherder=None
self, name, description, gradle_task, artifacts=None, routes=None, treeherder=None, scopes=None
):
return self._craft_build_ish_task(
name=name,
Expand All @@ -308,6 +322,7 @@ def _craft_clean_gradle_task(
artifacts=artifacts,
routes=routes,
treeherder=treeherder,
scopes=scopes,
)

def craft_compare_locales_task(self):
Expand All @@ -329,8 +344,8 @@ def craft_compare_locales_task(self):
)

def _craft_build_ish_task(
self, name, description, command, dependencies=None, artifacts=None, scopes=None,
routes=None, treeherder=None, env_vars=None,
self, name, description, command, dependencies=None, artifacts=None,
routes=None, treeherder=None, env_vars=None, scopes=None
):
dependencies = [] if dependencies is None else dependencies
artifacts = {} if artifacts is None else artifacts
Expand Down
19 changes: 19 additions & 0 deletions automation/taskcluster/upload_coverage_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# If a command fails then do not proceed and fail this script too.
set -ex

# Get token for uploading to codecov and append it to codecov.yml
python automation/taskcluster/helper/get-secret.py \
-s project/mobile/fenix/pr \
-k codecov \
-f .cc_token \

# Set some environment variables that will help codecov detect the CI
export CI_BUILD_URL="https://tools.taskcluster.net/tasks/$TASK_ID"

# Execute codecov script for uploading report
# bash <(curl -s https://codecov.io/bash)
bash <(curl -s https://codecov.io/bash) -t @.cc_token
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
codecov:
ci:
- tools.taskcluster.net

coverage:
precision: 2
round: down
range: 60..80

0 comments on commit 96f0261

Please sign in to comment.