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

fix(remote): parse comma-separated architectures #4543

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

mr-cal
Copy link
Collaborator

@mr-cal mr-cal commented Jan 24, 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)

2 commits:

  • fix(remote): make --build-for and --build-on mutually exclusive
    • This was not working as intended (and was not tested)
    • This is only for the new remote-build and makes no changes to how legacy remote build handles these arguments
  • fix(remote): parse comma-separated architectures
    • This uses the same style that legacy remote-build uses for passing architectures - a single comma-separated set

Fixes #4516
(CRAFT-2386)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal requested review from lengau and tigarmo January 25, 2024 17:50
help=HIDDEN,
)
parser.add_argument(
"--build-for",
type=lambda arg: [arch.strip() for arch in arg.split(",")],
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this support something wacky like --build-for=amd64 --build-for=arm64,armhf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. When there are duplicates, argparse/craft-cli uses the last --build-{on|for}, silently ignores the other --build-{on|for}s, and always provides a single string for this lambda.

Normally I wouldn't add a test for standard behavior, but since this is a delicate situation, I added an extra unit test.

Copy link
Contributor

Choose a reason for hiding this comment

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

to be clear, this wouldn't be a change in behavior right? The previous code would also only use the last --build-x?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, this behavior is unchanged.

The only "loss" is that snapcraft remote-build --build-for amd64 arm64 doesn't work.

And I think that "loss" is OK because it is a regression in the new remote builder: snapcraft 7 only supported comma-separated architectures, not space-separated architectures.

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
@mr-cal mr-cal requested a review from tigarmo January 25, 2024 19:34
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ef10848) 89.18% compared to head (afb963b) 89.19%.
Report is 1 commits behind head on hotfix/8.0.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@              Coverage Diff               @@
##           hotfix/8.0    #4543      +/-   ##
==============================================
+ Coverage       89.18%   89.19%   +0.01%     
==============================================
  Files             321      322       +1     
  Lines           21763    21814      +51     
==============================================
+ Hits            19409    19457      +48     
- Misses           2354     2357       +3     

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

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.

thankss

@mr-cal
Copy link
Collaborator Author

mr-cal commented Jan 26, 2024

Merging because spread test failures are completely unrelated (appears to be an issue with the devel image to be resolved via canonical/craft-providers#501

@mr-cal mr-cal merged commit 655afb8 into hotfix/8.0 Jan 26, 2024
7 of 10 checks passed
@mr-cal mr-cal deleted the remote-build-architectures branch January 26, 2024 20:40
sergiusens pushed a commit that referenced this pull request Feb 6, 2024
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
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.

4 participants