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
many: refactor snapcraft.yaml loading out of load_config #2160
Conversation
In order to have separated logical bits and clear overlaying communicated a logical separation is introduced between the actual snapcraft loading in raw form and its processed/validated form. LP: #1775849 Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
Codecov Report
@@ Coverage Diff @@
## master #2160 +/- ##
==========================================
- Coverage 91.25% 91.19% -0.06%
==========================================
Files 196 198 +2
Lines 12447 12471 +24
Branches 1845 1846 +1
==========================================
+ Hits 11358 11373 +15
- Misses 734 742 +8
- Partials 355 356 +1
Continue to review full report at Codecov.
|
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.
For such a significant PR, this was surprisingly easy to review. I only have a few suggestions, but nothing large.
snapcraft/project/_project_info.py
Outdated
self.confinement = data.get('confinement') | ||
self.grade = data.get('grade') | ||
def __init__(self, *, snapcraft_yaml_file_path) -> None: | ||
self.snapcraft_yaml_file_path = get_snapcraft_yaml() |
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 should probably be using snapcraft_yaml_file_path
, no?
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.
err, yes!
snapcraft/cli/_options.py
Outdated
@@ -52,7 +52,13 @@ def _add_build_options(func): | |||
return _add_build_options | |||
|
|||
|
|||
def get_project_options(**kwargs): | |||
def get_project(**kwargs): | |||
skip_snapcraft_yaml = kwargs.pop('skip_snapcraft_yaml', False) |
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.
It would be cleaner and more intuitive to include this as an actual kwarg so you don't need to pop it:
def get_project(*, skip_snapcraft_yaml: bool=False, **kwargs):
# ...
snapcraft/project/_project_info.py
Outdated
return yaml_contents | ||
|
||
|
||
def get_snapcraft_yaml(base_dir=None): |
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 suggest putting this either in snapcraft/project/__init__.py
, or in another module imported by __init__.py
. Reasoning: it shouldn't be used here, but belongs in the snapcraft/project
package somewhere for use elsewhere.
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.
ok, which means the tests for it need to be moved as well
Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
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.
Looks excellent with the changes, thank you!
In order to have separated logical bits and clear overlaying
communicated a logical separation is introduced between the
actual snapcraft loading in raw form and its processed/validated
form.
LP: #1775849
Signed-off-by: Sergio Schvezov sergio.schvezov@canonical.com
./runtests.sh static
?./runtests.sh unit
?