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

Insert "--head" defenses into the binary cache and block "default" when calculating feature ABIs. #336

Merged
merged 4 commits into from
Jan 31, 2022

Conversation

BillyONeal
Copy link
Member

This is fallout from code review / investigation of #331

  • It ensures the binary cache does reasonable things when an action's ABI is not established, as if it were --head, and adds tests.
  • In support of those tests, the VcpkgPaths is sucked out of a parameter passed through the binary cache and is made a member of the providers if necessary.

<expected.h>: Add the missing T& overloads used elsewhere.

<binarycaching.h>:

  • Remove VcpkgPaths from the IBinaryProvider interface; add it as a member of the concrete implementations.
  • Hoist BinaryConfigParserState (formerly State in binarycaching.cpp) here. It would be nice to make this more shiny, but hiding the definition of this struct wasn't buying us too much, and being unable to test stuff was a worse evil.
  • create_binary_providers_from_configs_pure now returns ExpectedS; this lets the tests of the parser machinery continue to be unchanged while still moving paths in as a member.

binarycaching.cpp:

  • Push vcpkgpaths as a member into the concrete implementations.
  • Change/audit all IBinaryProvider::prefetch to support nullptr. We pass in the underlying action plan vector here, and preparing a vector with the ABI-less packages removed would require extra indirection or flattening of the data we don't want to do in a bugfix.
  • Change/audit all IBinaryProvider::precheck to not support nullptr. That is used only by CI and everything there should have a package ABI.
  • Change BinaryCache::prefetch to explicitly document that nullptr package_abi is acceptable.
  • Change BinaryCache::precheck to explicitly error out on nullptr package_abi.

vcpkg-test/binarycaching.cpp:

  • Add tests for nullptr package ABIs passed to BinaryCache.

ras0219-msft and others added 2 commits January 27, 2022 14:00
<expected.h>: Add the missing T& overloads used elsewhere.

<binarycaching.h>:
* Remove VcpkgPaths from the IBinaryProvider interface; add it as a member of the concrete implementations.
* Hoist BinaryConfigParserState (formerly State in binarycaching.cpp) here. It would be nice to make this more shiny, but hiding the definition of this struct wasn't buying us too much, and being unable to test stuff was a worse evil.
* create_binary_providers_from_configs_pure now returns ExpectedS<BinaryConfigParserState>; this lets the tests of the parser machinery continue to be unchanged while still moving paths in as a member.

binarycaching.cpp:
* Push vcpkgpaths as a member into the concrete implementations.
* Change/audit all IBinaryProvider::prefetch to support nullptr. We pass in the underlying action plan vector here, and preparing a vector with the ABI-less packages removed would require extra indirection or flattening of the data we don't want to do in a bugfix.
* Change/audit all IBinaryProvider::precheck to not support nullptr. That is used only by CI and everything there should have a package ABI.
* Change BinaryCache::prefetch to explicitly document that nullptr package_abi is acceptable.
* Change BinaryCache::precheck to explicitly error out on nullptr package_abi.

vcpkg-test/binarycaching.cpp:
* Add tests for nullptr package ABIs passed to BinaryCache.
std::vector<std::string> sorted_feature_list = action.feature_list;
Util::sort(sorted_feature_list);
InternalFeatureSet sorted_feature_list = action.feature_list;
// Check that no "default" feature is present. Default features must be resolved before attempting to calculate
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that unlike #336 this does not insert "core" and rejects "default".

Copy link
Contributor

Choose a reason for hiding this comment

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

The current documentation string for InternalFeatureSet indicates that default is valid:

/// In an internal feature set, "default" represents default features and missing "core" has no semantic

How do we know that there won't be pseudo-features here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ras0219-msft We could introduce InternalResolvedFeatureSet or something like that if you wanted, but pseudo-features getting into an ABI calculation is a bug (since it would result in the same input having different ABIs depending on whether the pseudo-feature was resolved first).

@@ -16,27 +17,6 @@

namespace vcpkg
{
enum class RestoreResult
Copy link
Member Author

Choose a reason for hiding this comment

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

These got put into the fwd header

std::vector<std::string> sorted_feature_list = action.feature_list;
Util::sort(sorted_feature_list);
InternalFeatureSet sorted_feature_list = action.feature_list;
// Check that no "default" feature is present. Default features must be resolved before attempting to calculate
Copy link
Contributor

Choose a reason for hiding this comment

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

The current documentation string for InternalFeatureSet indicates that default is valid:

/// In an internal feature set, "default" represents default features and missing "core" has no semantic

How do we know that there won't be pseudo-features here?

@BillyONeal BillyONeal merged commit c76e0de into microsoft:main Jan 31, 2022
@BillyONeal BillyONeal deleted the bincache_rework branch January 31, 2022 23:41
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