Skip to content
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

DO NOT MERGE: Review PR for ProjectService and Pytest plugin #672

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

lengau
Copy link
Contributor

@lengau lengau commented Mar 4, 2025

This PR is for reviewing documentation on the hybrid-commands feature branch. Fixes should be collected into another PR.

Stuff to review here:

There will be more later, but this is what's currently on that feature branch.

CRAFT-4305

This adds a pytest plugin for craft-application, including the fixtures:

1. debug_mode: This fixture puts the app into debug mode by default.
2. production_mode: Overrides debug_mode for a function.

This is a breaking change because debug_mode is an auto-used fixture,
meaning any tests that rely on production mode will break.
…655)

This modifies the fake_host_architecture fixture in the pytest plugin so it makes craft_parts also think it's running on that machine.
Removes the ability to use secrets. This can be added to applications if necessary using the prototype secrets service.
This makes the ServiceFactory no longer a dataclass. It's only a dataclass for historical reasons around the old way of registering services, but this is no longer necessary.
This moves set_kwargs() from pending deprecation to deprecated. It
doesn't change any behaviour other than the type of warning that it
raises.
This adds the project service and makes the relevant changes to the rest of the application to handle it. Some tests have been disabled because of necessary future changes before we can merge this feature branch.
@lengau lengau requested a review from medubelko March 4, 2025 19:23
@lengau lengau changed the title DO NOT MERGE: Documentation for hybrid-commands feature branch DO NOT MERGE: Review PR for ProjectService and Pytest plugin Mar 4, 2025
@lengau lengau requested a review from jahn-junior March 4, 2025 19:23
lengau and others added 4 commits March 4, 2025 16:32
This adds a BuildPlanService that creates build plans for crafts.
These were deprecated, so we can remove them.
This creates partitioncraft, a very basic craft app that uses partitions.
…ft (#674)

This modifies the ProjectService so that it will work for Imagecraft. Most specifically, it adds a get_partitions_for method that is a generic partition generator and changes the prime project's partitions to a property.

Co-authored-by: Upils <[email protected]>
Copy link
Contributor

@medubelko medubelko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this review as a comment, since more pages are planned.

I don't feel qualified to review the docstrings, so I left them as-is.

Comment on lines +13 to +14
- A new :doc:`services/project` now handles the creation and management of the project
for this run of the application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this run

Looking at this sentence in isolation, I'm not quite sure what this means. I might be missing something obvious?

- Setting the arguments for a service using the service factory's ``set_kwargs`` is
deprecated. Use ``update_kwargs`` instead or file `an issue
<https://github.com/canonical/craft-application/issues/new?template=bug.yaml>`_
if you still need this method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to be clearer about our intent here. If this is an experimental change that is subject to change from feedback, I think we should state that plainly.

Testing
=======

- A new :doc:`pytest-plugin` with a fixture that enables production mode for the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A new :doc:`pytest-plugin` with a fixture that enables production mode for the
- Added a new :doc:`pytest-plugin` with a fixture that enables production mode for the

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting here that we're using past tense in this changelog, unlike the product changelogs.

Services
========

- A new :doc:`services/project` now handles the creation and management of the project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit iffy on the way we're stating this, since (I believe) we're replacing a class with a service with the same name. Will that have an effect on how it's instantiated?

~~~~~~~~~~~~~~~~

At this step, any user-added grammar is validated using
:external+craft-grammar:doc:`Craft Grammar <index>`. No grammar is applied yet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

Later we use "processed". Same idea?

during the application-specific transforms step, meaning that transforms may add
grammar-aware syntax if needed.

Validate Pydantic model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Validate Pydantic model
Validate the Pydantic model

Comment on lines +6 to +7
craft-application includes a `pytest`_ plugin to help ease the testing of apps that use
it as a framework.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
craft-application includes a `pytest`_ plugin to help ease the testing of apps that use
it as a framework.
The pytest plugin makes testing apps that use `pytest`_ easier.

Comment on lines +28 to +29
Auto-used fixtures
~~~~~~~~~~~~~~~~~~
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this an H2.

~~~~~~~~~~~~~~~~~~

Some fixtures are automatically enabled for tests, changing the default behaviour of
applications during the testing process. This is kept to a minimum, but is done when
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
applications during the testing process. This is kept to a minimum, but is done when
applications during the testing process. Fixtures generally only change behaviour when

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants