-
Notifications
You must be signed in to change notification settings - Fork 445
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
refactor: use init command from craft-application #5129
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@property | ||
def command_groups(self): | ||
"""Replace craft-application's LifecycleCommand group.""" | ||
_command_groups = super().command_groups | ||
for index, command_group in enumerate(_command_groups): | ||
if command_group.name == "Lifecycle": | ||
_command_groups[index] = cli.CORE24_LIFECYCLE_COMMAND_GROUP | ||
|
||
return _command_groups |
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 would have had to do more hacks for InitCommand
, hence canonical/craft-application#545.
c11a314
to
d235c56
Compare
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
d235c56
to
57d4325
Compare
|
||
if parsed_args.name: | ||
craft_cli.emit.progress( | ||
"Ignoring '--name' parameter because it is not supported yet.", |
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'm not sure if this should be an error, a warning, or if I should change the default template to use this as the snap name.
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.
if you changed the default template to support the name, would you be able to drop this class wholesale?
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.
No. The other extra things that snapcraft adds are:
- checking for a project file under
snapcraft.yaml
,snap/snapcraft.yaml
,build-aux/snap/snapcraft.yaml
or.snapcraft.yaml
- An emit message pointing to documentation.
I think the first is worth keeping. The second could be added as a comment to the snapcraft.yaml file.
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.
Alright. Then I think it should be an error and we should plan to address it soon
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'd vote for starting to support the name from the start, and address the rest in the separate item.
Out of curiosity, shouldn't you override the InitService
and use the command from upstream (if you ignore the documentation message)?
@@ -24,9 +24,9 @@ click==8.1.7 | |||
codespell==2.3.0 | |||
colorama==0.4.6 | |||
coverage==7.6.1 | |||
craft-application==4.2.6 | |||
git+https://github.com/canonical/craft-application@work/CRAFT-3543-use-app-commands#egg=craft-application |
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.
reminder to update this
|
||
if parsed_args.name: | ||
craft_cli.emit.progress( | ||
"Ignoring '--name' parameter because it is not supported yet.", |
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.
if you changed the default template to support the name, would you be able to drop this class wholesale?
try: | ||
project = get_snap_project() | ||
craft_cli.emit.progress("Checking for an existing 'snapcraft.yaml'.") | ||
project = get_snap_project(project_dir) |
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 one sounds like maybe it should go on Snapcraft's (new) InitService
(we can also do this later)
|
||
emit.message(f"Created {str(snapcraft_yaml_path)!r}.") | ||
emit.message( | ||
craft_cli.emit.message( |
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 also feels like maybe this message should be on the initservice; or maybe a way for the service to give a template-based string to be presented to the user after init is done (this would be useful in rockcraft, which has per-profile docs)
(we can also do this later)
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 good!
|
||
if parsed_args.name: | ||
craft_cli.emit.progress( | ||
"Ignoring '--name' parameter because it is not supported yet.", |
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'd vote for starting to support the name from the start, and address the rest in the separate item.
Out of curiosity, shouldn't you override the InitService
and use the command from upstream (if you ignore the documentation message)?
fi | ||
|
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.
fi | |
fi | |
snapcraft clean |
PROFILE/default_profile: null | ||
PROFILE/simple_profile: simple | ||
PROFILE: null | ||
PROJECT_DIR/default_dir: null | ||
PROJECT_DIR/project_dir: test-project-dir | ||
PROJECT_DIR: null |
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 recently realized that in that case it will be one test case per variant, so it won't create a combination of simple_profile
with project_dir
set. Is that ok ?
It will create 4 variant's: default_profile
, simple_profile
, project_dir
, default_dir
.
In that case if I can see correctly default_profile
and default_dir
will be the same test with different name
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.
spread variants are so annoying. I also only semi-recently internalized that this:
environment:
VAR1/bla: var1-bla
VAR1/ble: var1-ble
VAR2/bla: var2-bla
VAR2/ble: var2-ble
can be thought of as:
environment:
bla:
VAR1: var1-bla
VAR2: var2-bla
ble:
VAR1: var1-be
VAR2: var2-ble
tox run -m lint
?tox run -e test-py310
? (supported versions:py39
,py310
,py311
,py312
)Replace Snapcraft's
init
implementation with craft-application's implementation. Somehow I added more lines of code 🙃There are no behavioral changes with just
snapcraft init
. However, the command now accepts additional parameters added in craft-application:name
,profile
, andproject-dir
.Fixes #5098
(CRAFT-3543)