Commit 78d7376e by syed-awais-ali Committed by GitHub

Merge pull request #4019 from edx/aali/OPS-1832_add_modified_dockerfiles

add modified dockerfiles to the list of plays
parents bfad917f 4afe58f8
......@@ -330,6 +330,38 @@ def _get_role_name(role):
LOGGER.warning("role %s could not be resolved to a role name." % role)
return None
def _get_modified_dockerfiles(files, git_dir):
"""
Return changed files under docker/build directory
:param files:
:param git_dir:
:return:
"""
items = set()
candidate_files = {f for f in DOCKER_PATH_ROOT.glob("**/*")}
for f in files:
file_path = pathlib2.Path(git_dir, f)
if file_path in candidate_files:
items.add(_get_play_name(file_path))
return items
def _get_play_name(path):
"""
Gets name of play from the filepath, which is
the directory following occurence of the word "build".
Input:
path: A path to the changed file under docker/build dir
"""
# get individual parts of a file path
dirs = path.parts
# name of play
return dirs[dirs.index("build")+1]
def arg_parse():
parser = argparse.ArgumentParser(description = 'Given a commit range, analyze Ansible dependencies between roles and playbooks '
......@@ -387,5 +419,11 @@ if __name__ == '__main__':
# filter out docker plays without a Dockerfile
docker_plays = filter_docker_plays(docker_plays, TRAVIS_BUILD_DIR)
# Add playbooks to the list whose docker file has been modified
modified_docker_files = _get_modified_dockerfiles(change_set, TRAVIS_BUILD_DIR)
# prints Docker plays
print " ".join(str(play) for play in docker_plays)
print " ".join(str(play) for play in docker_plays),
print " ".join(str(dock) for dock in modified_docker_files)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment