Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Commit

Permalink
staticanalysis/bot: Use Taskcluster cache for sharebase only, refs #1923
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Abadie authored Mar 12, 2019
1 parent a1476e4 commit b83c801
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/staticanalysis/bot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ let

mkBot = branch:
let
cacheKey = "services-" + branch + "-static-analysis-bot";
secretsKey = "repo:github.com/mozilla-releng/services:branch:" + branch;
hook = mkTaskclusterHook {
name = "Static analysis automated tests";
Expand All @@ -75,12 +76,18 @@ let
# Send emails to relman
"notify:email:*"

# Used by cache
("docker-worker:cache:" + cacheKey)

# Needed to index the task in the TaskCluster index
("index:insert-task:project.releng.services.project." + branch + ".static_analysis_bot.*")

# Needed to download the Android sdks for Infer
"queue:get-artifact:project/gecko/android-*"
];
cache = {
"${cacheKey}" = "/cache";
};
taskEnv = fullTaskEnv {
"SSL_CERT_FILE" = "${cacert}/etc/ssl/certs/ca-bundle.crt";
"APP_CHANNEL" = branch;
Expand Down
11 changes: 10 additions & 1 deletion src/staticanalysis/bot/static_analysis_bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
REPO_TRY = b'https://hg.mozilla.org/try'
SOURCE_PHABRICATOR = 'phabricator'
SOURCE_TRY = 'try'
TASKCLUSTER_CACHE = '/cache'

logger = get_logger(__name__)

Expand Down Expand Up @@ -96,10 +97,10 @@ def setup(self,
except KeyError:
raise Exception('Publication mode should be {}'.format('|'.join(map(lambda p: p .name, Publication))))

# Repository is always on local instance
if not os.path.isdir(work_dir):
os.makedirs(work_dir)
self.repo_dir = os.path.join(work_dir, 'sa-unified')
self.repo_shared_dir = os.path.join(work_dir, 'sa-unified-shared')

# Save Taskcluster ID for logging
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
Expand All @@ -109,6 +110,14 @@ def setup(self,
if not os.path.isdir(self.taskcluster.results_dir):
os.makedirs(self.taskcluster.results_dir)

# Repository sharebase (for robustcheckout) is either
# * on the available Taskcluster cache, when running online
# * on the local instance, for developers
if not self.taskcluster.local and os.path.isdir(TASKCLUSTER_CACHE):
self.repo_shared_dir = os.path.join(TASKCLUSTER_CACHE, 'sa-unified-shared')
else:
self.repo_shared_dir = os.path.join(work_dir, 'sa-unified-shared')

# Save allowed paths
assert isinstance(allowed_paths, list)
assert all(map(lambda p: isinstance(p, str), allowed_paths))
Expand Down
5 changes: 2 additions & 3 deletions src/staticanalysis/bot/static_analysis_bot/workflows/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def clone(self, revision):
'''
Clone mozilla-unified
'''
logger.info('Clone mozilla unified', dir=settings.repo_dir)

logger.info('Clone mozilla unified', dir=settings.repo_dir, shared=settings.repo_shared_dir)
if settings.source == SOURCE_TRY:
# Clone Try using the target revision
assert revision.mercurial_revision is not None, 'Missing try mercurial revision'
Expand Down Expand Up @@ -108,7 +107,7 @@ def _log_process(output, name):
while proc.poll() is None:
_log_process(proc.stdout, 'clone')
_log_process(proc.stderr, 'clone (err)')
time.sleep(1)
time.sleep(2)

out, err = proc.communicate()
if proc.returncode != 0:
Expand Down

0 comments on commit b83c801

Please sign in to comment.