Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
78d7376e
Commit
78d7376e
authored
Aug 04, 2017
by
syed-awais-ali
Committed by
GitHub
Aug 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4019 from edx/aali/OPS-1832_add_modified_dockerfiles
add modified dockerfiles to the list of plays
parents
bfad917f
4afe58f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
4 deletions
+42
-4
util/parsefiles.py
+42
-4
No files found.
util/parsefiles.py
View file @
78d7376e
...
@@ -182,7 +182,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
...
@@ -182,7 +182,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
return
items
return
items
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
"""
"""
Determines which files in the change set are aws playbooks
Determines which files in the change set are aws playbooks
files: A list of files modified by a commit range.
files: A list of files modified by a commit range.
...
@@ -210,7 +210,7 @@ def get_plays(files, git_dir, playbooks_dirs):
...
@@ -210,7 +210,7 @@ def get_plays(files, git_dir, playbooks_dirs):
plays
.
add
(
_get_playbook_name_from_file
(
file_path
))
plays
.
add
(
_get_playbook_name_from_file
(
file_path
))
return
plays
return
plays
def
_get_playbook_name_from_file
(
path
):
def
_get_playbook_name_from_file
(
path
):
"""
"""
Gets name of playbook from the filepath, which is the last part of the filepath.
Gets name of playbook from the filepath, which is the last part of the filepath.
...
@@ -220,7 +220,7 @@ def _get_playbook_name_from_file(path):
...
@@ -220,7 +220,7 @@ def _get_playbook_name_from_file(path):
"""
"""
# get last part of filepath
# get last part of filepath
return
path
.
stem
return
path
.
stem
def
_get_role_name_from_file
(
path
):
def
_get_role_name_from_file
(
path
):
"""
"""
...
@@ -330,6 +330,38 @@ def _get_role_name(role):
...
@@ -330,6 +330,38 @@ def _get_role_name(role):
LOGGER
.
warning
(
"role
%
s could not be resolved to a role name."
%
role
)
LOGGER
.
warning
(
"role
%
s could not be resolved to a role name."
%
role
)
return
None
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
():
def
arg_parse
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Given a commit range, analyze Ansible dependencies between roles and playbooks '
parser
=
argparse
.
ArgumentParser
(
description
=
'Given a commit range, analyze Ansible dependencies between roles and playbooks '
...
@@ -387,5 +419,11 @@ if __name__ == '__main__':
...
@@ -387,5 +419,11 @@ if __name__ == '__main__':
# filter out docker plays without a Dockerfile
# filter out docker plays without a Dockerfile
docker_plays
=
filter_docker_plays
(
docker_plays
,
TRAVIS_BUILD_DIR
)
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
# 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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment