-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring index CI to a more modular approach. #582
Conversation
#dotests |
605e6e3
to
8137fdd
Compare
Sample output so far with test index:
|
7167c0e
to
e797c8e
Compare
#dotests |
ci/container_index/engine.py
Outdated
from glob import glob | ||
import ci.container_index.lib.utils as utils | ||
import ci.container_index.lib.constants as constants | ||
import imp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group the imports like
import a_standard
import b_standard
import a_third_party
import b_third_party
from a_soc import f
from a_soc import g
from b_soc import d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating
ci/container_index/engine.py
Outdated
from glob import glob | ||
import ci.container_index.lib.utils as utils | ||
import ci.container_index.lib.constants as constants | ||
import imp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are you using imp
? and why ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an unused import that i added while experimenting. Sorry forgot to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohammedzee1000 : if you run
pep8 filename.py
flake8 filename.py
pylint --errors-only filename.py
it should help you remove such issues before you even commit to a PR.
ci/container_index/engine.py
Outdated
import imp | ||
|
||
|
||
class Engine(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
ci/container_index/engine.py
Outdated
Initializes the test engine | ||
""" | ||
# Index file location needs to be provided | ||
if not path_exists(index_location): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of renaming imports, I would import and use
from os import path
[..]
if not path.exists(index_location):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
ci/container_index/engine.py
Outdated
(len(self.index_files) == 1 and | ||
any("index_template" in s for s | ||
in self.index_files))): | ||
raise Exception("No index files to match.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the error message should read "No index files to process."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
ci/container_index/lib/utils.py
Outdated
from os import environ, path, mkdir, unsetenv, listdir,\ | ||
unlink, devnull, getenv, getcwd, chdir, system | ||
from shutil import rmtree | ||
from subprocess import check_call, CalledProcessError, STDOUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group the imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ci/container_index/lib/utils.py
Outdated
try: | ||
fnull = open(devnull, "w") | ||
check_call(cmd, stdout=fnull, stderr=STDOUT) | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return True
in else
block of try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ci/container_index/lib/utils.py
Outdated
with open(file_path, "r") as f: | ||
data = yaml.load(f) | ||
except Exception as e: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if yaml is not valid a file, we do nothing to report it, refer to my earlier review comment where I pointed out about doing error check while loading user provided yaml files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing this
ci/container_index/lib/utils.py
Outdated
|
||
branches_cmd = r"""git branch -r | grep -v '\->' | while | ||
read remote; do git branch --track "${remote#origin/}" | ||
$remote" &> /dev/null; done""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comments here about what this command is doing and why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments added.
|
||
system(branches_cmd) | ||
cmd = ["git", "fetch", "--all"] | ||
execute_command(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the fetch should happen before tracking (above operation)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how i have always used this command. Still trying to figure out why in this order, but this is what i got from the reference.
Index CI is being re-written to allow modularity and an easier way to use the existing validation.
Depends on validation moved out of this patch.
- Adding error message and flow in case we failed to fetch data from index file. - Adding docstrings. - Fixing imports
- Fixing imports - Moved return True out of exception - load and dump yaml now returns error message that can be used by callee.
- Adding missing docstrings. - Adding default value UNKNOWN to field_name. - Fixing typo.
- Adding docstrings - Changing dicts to dictionaries - Fixing consistency of Id im comments
e797c8e
to
5727e05
Compare
f6855ad
to
03752e1
Compare
This is the first PR in a series to solve #583.
It aims to achieve the first 2 goals listed in the issue.