Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
tell Changes client to use path in artifact name for bazel projects
Browse files Browse the repository at this point in the history
Summary: This passes an extra command line argument --use-path-in-artifact-name to Changes client.

Test Plan: unit tests

Reviewers: anupc

Reviewed By: anupc

Subscribers: changesbot, kylec

Differential Revision: https://tails.corp.dropbox.com/D223290
  • Loading branch information
Naphat Sanguansin committed Aug 31, 2016
1 parent fbd6c51 commit 4eafc93
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changes/buildsteps/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self, commands=None, repo_path=None, path=None, env=None,
max_executors=10, cpus=DEFAULT_CPUS, memory=DEFAULT_MEMORY_MB, clean=True,
debug_config=None, test_stats_from=None, cluster=None,
other_repos=None, artifact_search_path=None,
use_path_in_artifact_name=False,
**kwargs):
"""
Constructor for DefaultBuildStep.
Expand Down Expand Up @@ -132,6 +133,9 @@ def __init__(self, commands=None, repo_path=None, path=None, env=None,
can be specified with "revision".
artifact_search_path: Absolute path in which test artifacts can be
found in. This defaults to the value for `path`.
use_path_in_artifact_name: Tell Changes client to append the hash
of the file path to the artifact name, before any file extension
or suffixes.
"""
if commands is None:
raise ValueError("Missing required config: need commands")
Expand All @@ -152,6 +156,7 @@ def __init__(self, commands=None, repo_path=None, path=None, env=None,
self.repo_path = path or DEFAULT_PATH
self.path = self.repo_path
self.artifact_search_path = artifact_search_path if artifact_search_path else self.path
self.use_path_in_artifact_name = use_path_in_artifact_name
self.release = release
self.max_executors = max_executors
self.resources = {
Expand Down Expand Up @@ -497,6 +502,7 @@ def get_allocation_params(self, jobstep):
'post-launch': current_app.config['LXC_POST_LAUNCH'],
'release': self.release,
'use-external-env': 'false',
'use-path-in-artifact-name': 'true' if self.use_path_in_artifact_name else 'false',
}

if current_app.config['CLIENT_SENTRY_DSN']:
Expand Down
1 change: 1 addition & 0 deletions changes/models/jobplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def get_build_step_for_job(cls, job_id):
cpus=bazel_cpus,
memory=bazel_memory,
max_executors=bazel_max_executors,
use_path_in_artifact_name=True,
)
return jobplan, implementation

Expand Down
27 changes: 27 additions & 0 deletions tests/changes/buildsteps/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ def test_get_allocation_params(self):
'artifact-search-path': 'source/tests',
'use-external-env': 'false',
'dist': 'ubuntu',
'use-path-in-artifact-name': 'false',
}

def test_get_allocation_params_with_artifact_search_path(self):
Expand All @@ -586,6 +587,7 @@ def test_get_allocation_params_with_artifact_search_path(self):
'artifact-search-path': '/out',
'use-external-env': 'false',
'dist': 'ubuntu',
'use-path-in-artifact-name': 'false',
}

def test_get_allocation_params_with_artifact_search_path_from_jobstep(self):
Expand All @@ -611,6 +613,31 @@ def test_get_allocation_params_with_artifact_search_path_from_jobstep(self):
'artifact-search-path': '/out',
'use-external-env': 'false',
'dist': 'ubuntu',
'use-path-in-artifact-name': 'false',
}

def test_get_allocation_params_use_path_in_artifact_name(self):
project = self.create_project()
build = self.create_build(project)
job = self.create_job(build)
jobphase = self.create_jobphase(job)
jobstep = self.create_jobstep(jobphase)

buildstep = self.get_buildstep(repo_path='source', path='tests', use_path_in_artifact_name=True)
result = buildstep.get_allocation_params(jobstep)
assert result == {
'adapter': 'basic',
'server': 'http://changes-int.example.com/api/0/',
'jobstep_id': jobstep.id.hex,
'release': 'precise',
's3-bucket': 'snapshot-bucket',
'pre-launch': 'echo pre',
'post-launch': 'echo post',
'artifacts-server': 'http://localhost:1234',
'artifact-search-path': 'source/tests',
'use-external-env': 'false',
'dist': 'ubuntu',
'use-path-in-artifact-name': 'true',
}

def test_get_allocation_params_for_snapshotting(self):
Expand Down
1 change: 1 addition & 0 deletions tests/changes/buildsteps/test_lxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ def test_get_allocation_params(self):
'artifact-search-path': DEFAULT_PATH,
'use-external-env': 'false',
'dist': 'ubuntu',
'use-path-in-artifact-name': 'false',
}
4 changes: 4 additions & 0 deletions tests/changes/models/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def test_autogenerated_commands(self, get_config):

assert implementation.max_executors == 1

assert implementation.use_path_in_artifact_name is True

assert implementation.commands[0].type == CommandType.setup
assert implementation.commands[0].script == bazel_setup_expected

Expand Down Expand Up @@ -121,6 +123,8 @@ def test_autogenerated_commands_with_exclusions(self, get_config):

assert implementation.max_executors == 3

assert implementation.use_path_in_artifact_name is True

assert implementation.resources['cpus'] == 2
assert implementation.resources['mem'] == 1234

Expand Down

0 comments on commit 4eafc93

Please sign in to comment.