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
282d4cac
Commit
282d4cac
authored
Sep 11, 2017
by
syed-awais-ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add docker/plays files to list of changed files
parent
5ec97225
Show 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 @
282d4cac
...
@@ -9,9 +9,11 @@ import argparse
...
@@ -9,9 +9,11 @@ import argparse
TRAVIS_BUILD_DIR
=
os
.
environ
.
get
(
"TRAVIS_BUILD_DIR"
)
TRAVIS_BUILD_DIR
=
os
.
environ
.
get
(
"TRAVIS_BUILD_DIR"
)
DOCKER_PATH_ROOT
=
pathlib2
.
Path
(
TRAVIS_BUILD_DIR
,
"docker"
,
"build"
)
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"
)
CONFIG_FILE_PATH
=
pathlib2
.
Path
(
TRAVIS_BUILD_DIR
,
"util"
,
"parsefiles_config.yml"
)
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
build_graph
(
git_dir
,
roles_dirs
,
aws_play_dirs
,
docker_play_dirs
):
def
build_graph
(
git_dir
,
roles_dirs
,
aws_play_dirs
,
docker_play_dirs
):
"""
"""
Builds a dependency graph that shows relationships between roles and playbooks.
Builds a dependency graph that shows relationships between roles and playbooks.
...
@@ -149,6 +151,7 @@ def _open_yaml_file(file_str):
...
@@ -149,6 +151,7 @@ def _open_yaml_file(file_str):
LOGGER
.
error
(
"error in configuration file:
%
s"
%
str
(
exc
))
LOGGER
.
error
(
"error in configuration file:
%
s"
%
str
(
exc
))
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
change_set_to_roles
(
files
,
git_dir
,
roles_dirs
,
playbooks_dirs
,
graph
):
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.
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):
...
@@ -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
))
items
.
add
(
_get_role_name_from_file
(
file_path
))
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
...
@@ -211,6 +215,7 @@ def get_plays(files, git_dir, playbooks_dirs):
...
@@ -211,6 +215,7 @@ def get_plays(files, git_dir, playbooks_dirs):
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.
...
@@ -235,6 +240,7 @@ def _get_role_name_from_file(path):
...
@@ -235,6 +240,7 @@ def _get_role_name_from_file(path):
# name of role is the next part of the file path after "roles"
# name of role is the next part of the file path after "roles"
return
dirs
[
dirs
.
index
(
"roles"
)
+
1
]
return
dirs
[
dirs
.
index
(
"roles"
)
+
1
]
def
get_dependencies
(
roles
,
graph
):
def
get_dependencies
(
roles
,
graph
):
"""
"""
Determines all roles dependent on set of roles and returns set containing both.
Determines all roles dependent on set of roles and returns set containing both.
...
@@ -257,6 +263,7 @@ def get_dependencies(roles, graph):
...
@@ -257,6 +263,7 @@ def get_dependencies(roles, graph):
return
items
return
items
def
get_docker_plays
(
roles
,
graph
):
def
get_docker_plays
(
roles
,
graph
):
"""Gets all docker plays that contain at least role in common with roles."""
"""Gets all docker plays that contain at least role in common with roles."""
...
@@ -291,6 +298,7 @@ def get_docker_plays(roles, graph):
...
@@ -291,6 +298,7 @@ def get_docker_plays(roles, graph):
return
items
return
items
def
filter_docker_plays
(
plays
,
repo_path
):
def
filter_docker_plays
(
plays
,
repo_path
):
"""Filters out docker plays that do not have a Dockerfile."""
"""Filters out docker plays that do not have a Dockerfile."""
...
@@ -306,6 +314,7 @@ def filter_docker_plays(plays, repo_path):
...
@@ -306,6 +314,7 @@ def filter_docker_plays(plays, repo_path):
return
items
return
items
def
_get_role_name
(
role
):
def
_get_role_name
(
role
):
"""
"""
Resolves a role name from either a simple declaration or a dictionary style declaration.
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):
...
@@ -347,6 +356,23 @@ def _get_modified_dockerfiles(files, git_dir):
if
play
is
not
None
:
if
play
is
not
None
:
items
.
add
(
play
)
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
return
items
...
@@ -372,6 +398,7 @@ def _get_play_name(path):
...
@@ -372,6 +398,7 @@ def _get_play_name(path):
return
suffix_parts
[
0
]
return
suffix_parts
[
0
]
return
None
return
None
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 '
...
@@ -432,5 +459,9 @@ if __name__ == '__main__':
...
@@ -432,5 +459,9 @@ if __name__ == '__main__':
# Add playbooks to the list whose docker file has been modified
# Add playbooks to the list whose docker file has been modified
modified_docker_files
=
_get_modified_dockerfiles
(
change_set
,
TRAVIS_BUILD_DIR
)
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
)
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