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
f0c76717
Commit
f0c76717
authored
Sep 12, 2017
by
syed-awais-ali
Committed by
GitHub
Sep 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4084 from edx/aali/OPS-2340_modified_docker_files_in_plays
add docker/plays files to list of changed files
parents
2e8aad83
282d4cac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletions
+32
-1
util/parsefiles.py
+32
-1
No files found.
util/parsefiles.py
View file @
f0c76717
...
...
@@ -9,9 +9,11 @@ import argparse
TRAVIS_BUILD_DIR
=
os
.
environ
.
get
(
"TRAVIS_BUILD_DIR"
)
DOCKER_PATH_ROOT
=
pathlib2
.
Path
(
TRAVIS_BUILD_DIR
,
"docker"
,
"build"
)
DOCKER_PLAYS_PATH
=
pathlib2
.
Path
(
TRAVIS_BUILD_DIR
,
"docker"
,
"plays"
)
CONFIG_FILE_PATH
=
pathlib2
.
Path
(
TRAVIS_BUILD_DIR
,
"util"
,
"parsefiles_config.yml"
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
build_graph
(
git_dir
,
roles_dirs
,
aws_play_dirs
,
docker_play_dirs
):
"""
Builds a dependency graph that shows relationships between roles and playbooks.
...
...
@@ -149,6 +151,7 @@ def _open_yaml_file(file_str):
LOGGER
.
error
(
"error in configuration file:
%
s"
%
str
(
exc
))
sys
.
exit
(
1
)
def
change_set_to_roles
(
files
,
git_dir
,
roles_dirs
,
playbooks_dirs
,
graph
):
"""
Converts change set consisting of a number of files to the roles that they represent/contain.
...
...
@@ -181,6 +184,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
items
.
add
(
_get_role_name_from_file
(
file_path
))
return
items
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
"""
Determines which files in the change set are aws playbooks
...
...
@@ -211,6 +215,7 @@ def get_plays(files, git_dir, playbooks_dirs):
return
plays
def
_get_playbook_name_from_file
(
path
):
"""
Gets name of playbook from the filepath, which is the last part of the filepath.
...
...
@@ -235,6 +240,7 @@ def _get_role_name_from_file(path):
# name of role is the next part of the file path after "roles"
return
dirs
[
dirs
.
index
(
"roles"
)
+
1
]
def
get_dependencies
(
roles
,
graph
):
"""
Determines all roles dependent on set of roles and returns set containing both.
...
...
@@ -257,6 +263,7 @@ def get_dependencies(roles, graph):
return
items
def
get_docker_plays
(
roles
,
graph
):
"""Gets all docker plays that contain at least role in common with roles."""
...
...
@@ -291,6 +298,7 @@ def get_docker_plays(roles, graph):
return
items
def
filter_docker_plays
(
plays
,
repo_path
):
"""Filters out docker plays that do not have a Dockerfile."""
...
...
@@ -306,6 +314,7 @@ def filter_docker_plays(plays, repo_path):
return
items
def
_get_role_name
(
role
):
"""
Resolves a role name from either a simple declaration or a dictionary style declaration.
...
...
@@ -347,6 +356,23 @@ def _get_modified_dockerfiles(files, git_dir):
if
play
is
not
None
:
items
.
add
(
play
)
return
items
def
get_modified_dockerfiles_plays
(
files
,
git_dir
):
"""
Return changed files under docker/plays directory
:param files:
:param git_dir:
:return:
"""
items
=
set
()
candidate_files
=
{
f
for
f
in
DOCKER_PLAYS_PATH
.
glob
(
"*.yml"
)}
for
f
in
files
:
file_path
=
pathlib2
.
Path
(
git_dir
,
f
)
if
file_path
in
candidate_files
:
items
.
add
(
_get_playbook_name_from_file
(
file_path
))
return
items
...
...
@@ -372,6 +398,7 @@ def _get_play_name(path):
return
suffix_parts
[
0
]
return
None
def
arg_parse
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Given a commit range, analyze Ansible dependencies between roles and playbooks '
...
...
@@ -432,5 +459,9 @@ if __name__ == '__main__':
# Add playbooks to the list whose docker file has been modified
modified_docker_files
=
_get_modified_dockerfiles
(
change_set
,
TRAVIS_BUILD_DIR
)
all_plays
=
set
(
set
(
docker_plays
)
|
set
(
modified_docker_files
))
# Add plays to the list which got changed in docker/plays directory
docker_plays_dir
=
get_modified_dockerfiles_plays
(
change_set
,
TRAVIS_BUILD_DIR
)
all_plays
=
set
(
set
(
docker_plays
)
|
set
(
modified_docker_files
)
|
set
(
docker_plays_dir
))
print
" "
.
join
(
all_plays
)
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