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

feat: add platforms and drop architectures for core24 #4630

Merged
merged 17 commits into from
Mar 11, 2024

Conversation

mr-cal
Copy link
Collaborator

@mr-cal mr-cal commented Mar 4, 2024

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run tox run -m lint?
  • Have you successfully run tox run -e test-py310? (supported versions: py39, py310, py311, py312)

This PR is a draft.

  • Add platforms in core24
  • Drop architectures in core24

Similar to architectures, the platforms keyword is optional and defaults to building-on and building-for the host architecture.

As much as possible, I tried to follow charmcraft's and rockcraft's implementation of platform support.

(CRAFT-2535)

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 98.98990% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 89.23%. Comparing base (a019fe7) to head (554d8c7).
Report is 24 commits behind head on feature/craft-application.

Files Patch % Lines
snapcraft/models/project.py 98.68% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feature/craft-application    #4630      +/-   ##
=============================================================
+ Coverage                      89.14%   89.23%   +0.08%     
=============================================================
  Files                            331      335       +4     
  Lines                          22078    22323     +245     
=============================================================
+ Hits                           19682    19919     +237     
- Misses                          2396     2404       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-cal mr-cal requested a review from lengau March 4, 2024 20:17
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 4, 2024

@lengau or @tigarmo: could I get some early feedback of this draft? You can hide the code coverage annotations for now, I am missing a ton of unit tests.

@mr-cal mr-cal marked this pull request as draft March 4, 2024 20:18
Copy link
Contributor

@tigarmo tigarmo left a comment

Choose a reason for hiding this comment

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

Did a first review pass, thanks!

snapcraft/application.py Outdated Show resolved Hide resolved
if len(build_for) > 1:
raise CraftValidationError(
str(
f"Trying to build a rock for {build_for} "
Copy link
Contributor

Choose a reason for hiding this comment

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

(this refers to rock)

snapcraft/application.py Outdated Show resolved Hide resolved
snapcraft/models/project.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
snapcraft/models/project.py Outdated Show resolved Hide resolved
snapcraft/models/project.py Outdated Show resolved Hide resolved
snapcraft/models/project.py Outdated Show resolved Hide resolved
snapcraft/application.py Outdated Show resolved Hide resolved
snapcraft/application.py Outdated Show resolved Hide resolved
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal force-pushed the work/CRAFT-2535-platforms branch from 84dfa5c to a136703 Compare March 6, 2024 20:58
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 6, 2024

Sorry for the force-push, there were file conflicts. The already-reviewed commit has not been changed.

@tigarmo
Copy link
Contributor

tigarmo commented Mar 7, 2024

@mr-cal is this ready for review?

@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 7, 2024

@mr-cal is this ready for review?

Not yet 🙃

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal marked this pull request as ready for review March 7, 2024 16:02
@mr-cal mr-cal requested review from tigarmo and lengau March 7, 2024 16:03
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 7, 2024

This is now ready for review.

A few outstanding items:

  1. Should the contents of meta/snap.yaml change from architectures to platforms?
  2. I need to add a spread test for --platforms
  3. What should be done for scenarios like this spread test? It has:
name: core2x
type: base
build-base: core22

Which means the effective base is core2x. Should that use architectures or platforms? Or should we update this test to be realistic (i.e change the snapcraft.yaml to name: core22 or name: core24)?

grade: devel
confinement: strict
base: core22
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might have uncovered a new bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or was this test in the core24 suite accidentally not updated to base: core24?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tests/unit/commands/test_expand_extensions.py Outdated Show resolved Hide resolved
tests/unit/test_application.py Outdated Show resolved Hide resolved
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 7, 2024

tests/spread/core24/platforms/snaps/platform-match` fails because snapcraft is not using the build-for from the build plan and is instead using the host architecture.

Snapcraft creates the correct build plan but it feels like the build-for isn't getting passed from craft-application to craft-parts. I haven't figured this out yet.

@tigarmo
Copy link
Contributor

tigarmo commented Mar 7, 2024

tests/spread/core24/platforms/snaps/platform-match` fails because snapcraft is not using the build-for from the build plan and is instead using the host architecture.

Snapcraft creates the correct build plan but it feels like the build-for isn't getting passed from craft-application to craft-parts. I haven't figured this out yet.

I think the problem is this: https://github.com/canonical/snapcraft/blob/main/snapcraft/application.py#L47
In the absence of a command-line build-for, that code is defaulting to the host arch (in this case amd64). I think the right solution here is to pass the filtered build plan to the package service, like craft-application does with the lifecycle service

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 7, 2024

Thank you! I'm not sure I would have figured that out on my own.

@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 8, 2024

Looks like some spread tests are failing because there are a handful of get_build_for() calls in snapcraft/parts/lifecycle.py that assume the architectures keyword exists and has been filtered.

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Copy link
Contributor

@lengau lengau left a comment

Choose a reason for hiding this comment

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

Fantastic work! This was a biggie

@tigarmo
Copy link
Contributor

tigarmo commented Mar 8, 2024

Some of the failures are like this:

2024-03-08T16:26:32.6531590Z 2024-03-08 16:26:32 Error executing google:ubuntu-22.04-64:tests/spread/plugins/craft-parts/python-symlinks:bare_provisioned (mar081610-674143) : 
2024-03-08T16:26:32.6533187Z -----
2024-03-08T16:26:32.6533878Z + cd bare-provisioned
2024-03-08T16:26:32.6534676Z + '[' -f expected-symlink ']'
2024-03-08T16:26:32.6535450Z + snapcraft prime
2024-03-08T16:26:32.6536663Z Bad snapcraft.yaml content:
2024-03-08T16:26:32.6538192Z - 'architectures' keyword is not supported for base 'bare'. Use 'platforms' keyword instead.

Looks like this validation should a) look at the build-base (probably use the get_effective_base() function if it's not) and b) only fail if the build-base is core24 (or devel I guess), instead of only accepting core22

Copy link
Contributor

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

After a long discussion we understood the issues and the platforms validation pattern used in this PR. Although it works, there is redundant and/or sub-optimal model validation that also exists in Rockcraft. These can be addressed in follow-up PRs for both Snapcraft and Rockcraft.

snapcraft/application.py Outdated Show resolved Hide resolved
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 9, 2024

For the test failures for google:ubuntu-24.04-64:tests/spread/core24/grammar:arm64:

I think we need something like this in craft-application: canonical/craft-application@main...work/grammar-build-for . Maybe this should follow the same path as canonical/craft-application#259 now that there is a self._build_plan to use.

But even after that patch, snapcraft clean --destructive-mode fails with Multiple builds match the current platform, which I also think is a craft-application quandary.

Otherwise, the spread tests look good.

@tigarmo
Copy link
Contributor

tigarmo commented Mar 11, 2024

@mr-cal I think the problem with the snapcraft clean --destructive-mode is again the assumption that build-for is provided which we need to fix upstream in craft-application
my suggestion is to ignore that particular failure for this PR

@sergiusens sergiusens merged commit f771a4a into feature/craft-application Mar 11, 2024
7 of 12 checks passed
@mr-cal
Copy link
Collaborator Author

mr-cal commented Mar 11, 2024

Sounds good, I'll make an issue after

@mr-cal I think the problem with the snapcraft clean --destructive-mode is again the assumption that build-for is provided which we need to fix upstream in craft-application my suggestion is to ignore that particular failure for this PR

New issue in craft-application: canonical/craft-application#261

@t4saha
Copy link

t4saha commented Jun 21, 2024

@mr-cal Just migrated my app to core24. Platforms is declared only as amd64 and arm64 but remote build is trying to build for all platforms.
https://github.com/t4saha/stellarium-snap

Screenshot_20240621-103608

@sergiusens
Copy link
Collaborator

@t4saha I created #4867 to track it in case you want to follow

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.

6 participants