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
397661d1
Commit
397661d1
authored
Aug 10, 2016
by
Michael Roytman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify playbook case
parent
746ed762
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
util/parsefiles.py
+32
-10
No files found.
util/parsefiles.py
View file @
397661d1
...
...
@@ -179,6 +179,19 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
if
file_path
in
candidate_files
:
# get name of role and add it to set of roles of the change set
items
.
add
(
_get_resource_name
(
file_path
,
"roles"
))
return
items
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
"""
Determines which files in the change set are aws playbooks
files: A list of files modified by a commit range.
git_dir: A path to the top-most directory in the local git repository tool is to be run in.
playbook_dirs: A list of relative paths to directories in which Ansible playbooks reside.
"""
plays
=
set
()
# for all directories containing playbooks
for
play_dir
in
playbooks_dirs
:
...
...
@@ -192,17 +205,21 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
for
f
in
files
:
file_path
=
pathlib2
.
Path
(
git_dir
,
f
)
# if the change set file is in t
eh
set of playbook files
# if the change set file is in t
he
set of playbook files
if
file_path
in
candidate_files
:
# gets first level of children of playbook in graph, which represents
# all roles the playbook uses
descendants
=
nx
.
all_neighbors
(
graph
,
(
file_path
.
stem
,
"aws_playbook"
))
# adds all the roles that a playbook uses to set of roles of the change set
items
|=
{
desc
.
name
for
desc
in
descendants
}
return
items
# if looking in playbooks directory
if
play_dir
==
"playbooks"
:
play
=
_get_resource_name
(
file_path
,
"playbooks"
)
# remove ".yml" file ending
play
=
play
[:
-
4
]
plays
.
add
(
play
)
elif
play_dir
==
"playbooks/edx-east"
:
play
=
_get_resource_name
(
file_path
,
"edx-east"
)
# remove ".yml" file ending
play
=
play
[:
-
4
]
plays
.
add
(
play
)
return
plays
def
_get_resource_name
(
path
,
kind
):
"""
Gets name of resource from the filepath, which is the directory following occurence of kind.
...
...
@@ -355,6 +372,9 @@ if __name__ == '__main__':
# build graph
graph
=
build_graph
(
TRAVIS_BUILD_DIR
,
config
[
"roles_paths"
],
config
[
"aws_plays_paths"
],
config
[
"docker_plays_paths"
])
# gets any playbooks in the commit range
plays
=
get_plays
(
change_set
,
TRAVIS_BUILD_DIR
,
config
[
"aws_plays_paths"
])
# transforms list of roles and plays into list of original roles and the roles contained in the plays
roles
=
change_set_to_roles
(
change_set
,
TRAVIS_BUILD_DIR
,
config
[
"roles_paths"
],
config
[
"aws_plays_paths"
],
graph
)
...
...
@@ -364,6 +384,8 @@ if __name__ == '__main__':
# determine which docker plays cover at least one role
docker_plays
=
get_docker_plays
(
dependent_roles
,
graph
)
docker_plays
=
docker_plays
|
plays
# filter out docker plays without a Dockerfile
docker_plays
=
filter_docker_plays
(
docker_plays
,
TRAVIS_BUILD_DIR
)
...
...
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