Skip to content

Commit

Permalink
Umbrella crate: exclude chain-specific crates (#5173)
Browse files Browse the repository at this point in the history
Uses custom metadata to exclude chain-specific crates.  
The only concern is that devs who want to use chain-specific crates,
still need to select matching versions numbers. Could possibly be
addresses with chain-specific umbrella crates, but currently it should
be possible to use [psvm](https://github.com/paritytech/psvm).

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored Aug 7, 2024
1 parent 8af9889 commit 0fb6e3c
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 157 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bridges/chains/chain-asset-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-asset-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-bridge-hub-cumulus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-bridge-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-bridge-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-bridge-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-polkadot-bulletin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions bridges/chains/chain-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition.workspace = true
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
39 changes: 39 additions & 0 deletions docs/contributor/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,45 @@ Non "silent" PRs must come with documentation in the form of a `.prdoc` file.

See more about `prdoc` [here](./prdoc.md)

## Crate Configuration `Cargo.toml`

The Polkadot SDK uses many conventions when configuring a crate. Watch out for these things when you
are creating a new crate.

### Is the Crate chain-specific?

Chain-specific crates, for example
[`bp-bridge-hub-rococo`](https://github.com/paritytech/polkadot-sdk/blob/4014b9bf2bf8f74862f63e7114e5c78009529be5/bridges/chains/chain-bridge-hub-rococo/Cargo.toml#L10-L11)
, should not be released as part of the Polkadot-SDK umbrella crate. We have a custom metadata
attribute that is picked up by the [generate-umbrella.py](../../scripts/generate-umbrella.py)
script, that should be applied to all chain-specific crates like such:

```toml
[package]
# Other stuff...

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

# Other stuff...
```

### Is the Crate a Test, Example or Fuzzer?

Test or example crates, like
[`pallet-example-task`](https://github.com/paritytech/polkadot-sdk/blob/9b4acf27b869d7cbb07b03f0857763b8c8cc7566/substrate/frame/examples/tasks/Cargo.toml#L9)
, should not be released to crates.io. To ensure this, you must add `publish = false` to your
crate's `package` section:

```toml
[package]
# Other stuff...

publish = false

# Other stuff...
```

## Helping out

We use [labels](https://github.com/paritytech/polkadot-sdk/labels) to manage PRs and issues and communicate state of a
Expand Down
3 changes: 3 additions & 0 deletions polkadot/runtime/rococo/constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ authors.workspace = true
edition.workspace = true
license.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
3 changes: 3 additions & 0 deletions polkadot/runtime/westend/constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ authors.workspace = true
edition.workspace = true
license.workspace = true

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[lints]
workspace = true

Expand Down
39 changes: 39 additions & 0 deletions prdoc/pr_5173.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
title: "Umbrella crate: exclude chain-specific crates"

doc:
- audience: Runtime Dev
description: |
The `polkadot-sdk` umbrella crate does now not contain chain-specific crates. The reasoning is
that the SDK should be mostly chain-agnostic. Please check out
[psvm](https://github.com/paritytech/psvm) to select matching version numbers for chain-
specific crates.

crates:
- name: polkadot-sdk
bump: major
- name: rococo-runtime-constants
bump: none
- name: westend-runtime-constants
bump: none
- name: bp-asset-hub-rococo
bump: none
- name: bp-asset-hub-westend
bump: none
- name: bp-bridge-hub-cumulus
bump: none
- name: bp-bridge-hub-kusama
bump: none
- name: bp-bridge-hub-polkadot
bump: none
- name: bp-bridge-hub-rococo
bump: none
- name: bp-bridge-hub-westend
bump: none
- name: bp-kusama
bump: none
- name: bp-polkadot-bulletin
bump: none
- name: bp-rococo
bump: none
- name: bp-westend
bump: none
3 changes: 2 additions & 1 deletion scripts/generate-umbrella.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"""
def exclude(crate):
name = crate.name
if crate.metadata.get("polkadot-sdk.skip-umbrella", False):
if crate.metadata.get("polkadot-sdk.exclude-from-umbrella", False):
return True

# No fuzzers or examples:
if "example" in name or name.endswith("fuzzer"):
return True

# No runtime crates:
if name.endswith("-runtime"):
# Note: this is a bit hacky. We should use custom crate metadata instead.
Expand Down
Loading

0 comments on commit 0fb6e3c

Please sign in to comment.