-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add conditional compilation support for impl_runtime_apis!
#14709
Conversation
@@ -224,6 +224,8 @@ test-linux-stable: | |||
--features runtime-benchmarks,try-runtime,experimental | |||
--manifest-path ./bin/node/cli/Cargo.toml | |||
--partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL} | |||
# run runtime-api tests with `enable-staging-api` feature |
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.
Is this a good idea?
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 suggest not to do this for now, as runtime API versions often activate experimental features which may be buggy. It's acceptable for experimental features to be buggy in master, but it should not lead to test failures.
In the PR that stabilizes experimental APIs, we'd encounter the test failure in CI anyway.
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 haven't marked the correct line. It doesn't run all tests with enable-staging-api
but only sp-api-test
:
time cargo nextest run -p sp-api-test --features enable-staging-api
I've got some runtime api unit tests with feature flags, but they need to be invoked individually.
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
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.
Ty! Looks good, just some last nitpicks :)
bot rebase |
Rebased |
Co-authored-by: Bastian Köcher <git@kchr.de>
This reverts commit 4da20a7.
bot merge |
iml_runtime_apis!
impl_runtime_apis!
This PR handles
cfg_attr
attribute foriml_runtime_apis!
. It allows conditionally to compile different runtime api version implementations based on feature flag. E.g.:The code above will compile version 1 (with just
stable_one
) by default and version 99 (withstable_one
andstaging_one
) ifenable-staging-api
feature is enabled.EDIT: modified the sample code to match the latest implementation suggested by @bkchr