From b1eef8057c2e438881cd8687d81963452e868c90 Mon Sep 17 00:00:00 2001 From: Daniel Bigos Date: Sat, 21 Sep 2024 00:32:56 +0200 Subject: [PATCH] ref: new workspace structure and version management (#280) - [x] Set `motsu` version to `v0.1.0` - [x] Improve version management for the workspace - `contracts`, `lib/crypto`, `examples`, and `benches` use version set for the whole workspace - `motsu`, `motsu-proc`, `e2e`, `e2e-proc` have their own version per crate - [x] Cleanup dependencies for the workspace - [x] Add CI checks for pre-publishing on crates.io - [x] Fix issues with publishing `motsu` to crates.io: ``` cargo publish -p motsu --target wasm32-unknown-unknown --dry-run Updating crates.io index error: all dependencies must have a version specified when publishing. dependency `motsu-proc` does not specify a version Note: The published dependency will use the version from crates.io, the `path` specification will be removed from the dependency declaration. ``` --------- --- .github/workflows/check-publish.yml | 42 ++++++++++++++++++++++++++ Cargo.lock | 20 ++++++------ Cargo.toml | 9 ++++++ benches/Cargo.toml | 6 ++-- contracts/Cargo.toml | 4 +-- examples/access-control/Cargo.toml | 6 ++-- examples/basic/token/Cargo.toml | 4 +-- examples/ecdsa/Cargo.toml | 6 ++-- examples/erc20-permit/Cargo.toml | 6 ++-- examples/erc20/Cargo.toml | 6 ++-- examples/erc721-consecutive/Cargo.toml | 6 ++-- examples/erc721-metadata/Cargo.toml | 6 ++-- examples/erc721/Cargo.toml | 6 ++-- examples/merkle-proofs/Cargo.toml | 4 +-- examples/ownable/Cargo.toml | 4 +-- lib/crypto/Cargo.toml | 2 +- lib/e2e/Cargo.toml | 2 +- lib/motsu-proc/Cargo.toml | 2 +- lib/motsu/Cargo.toml | 2 +- 19 files changed, 97 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/check-publish.yml diff --git a/.github/workflows/check-publish.yml b/.github/workflows/check-publish.yml new file mode 100644 index 00000000..67bbb311 --- /dev/null +++ b/.github/workflows/check-publish.yml @@ -0,0 +1,42 @@ +name: check-publish +# This workflow checks that the libraries can be published on crates.io. +permissions: + contents: read +on: + push: + branches: [ main ] + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +env: + CARGO_TERM_COLOR: always +jobs: + check-publish: + name: Check publish on crates.io + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: set up rust + uses: dtolnay/rust-toolchain@master + id: toolchain + with: + target: wasm32-unknown-unknown + components: rust-src + toolchain: nightly-2024-01-01 + + - uses: Swatinem/rust-cache@v2 + + - name: check motsu-proc + run: cargo publish -p motsu-proc --dry-run + + - name: check motsu + run: cargo publish -p motsu --dry-run + + - name: check openzeppelin-crypto + run: cargo publish -p openzeppelin-crypto --target wasm32-unknown-unknown --dry-run + + # TODO: https://github.com/OpenZeppelin/rust-contracts-stylus/issues/291 + # - name: check openzeppelin-stylus + # run: cargo publish -p openzeppelin-stylus --target wasm32-unknown-unknown --dry-run diff --git a/Cargo.lock b/Cargo.lock index ebb25bb5..591250ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "access-control-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -794,7 +794,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy-primitives", "mini-alloc", @@ -816,7 +816,7 @@ dependencies = [ [[package]] name = "benches" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1262,7 +1262,7 @@ dependencies = [ [[package]] name = "cryptography-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1514,7 +1514,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erc20-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1529,7 +1529,7 @@ dependencies = [ [[package]] name = "erc20-permit-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1544,7 +1544,7 @@ dependencies = [ [[package]] name = "erc721-consecutive-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1561,7 +1561,7 @@ dependencies = [ [[package]] name = "erc721-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -1577,7 +1577,7 @@ dependencies = [ [[package]] name = "erc721-metadata-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy", "alloy-primitives", @@ -2360,7 +2360,7 @@ checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merkle-proofs-example" -version = "0.0.0" +version = "0.1.0-rc" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/Cargo.toml b/Cargo.toml index f196fd18..059b99e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ edition = "2021" license = "MIT" keywords = ["arbitrum", "ethereum", "stylus"] repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" +version = "0.1.0-rc" [workspace.lints.rust] missing_docs = "warn" @@ -95,6 +96,14 @@ syn = { version = "2.0.58", features = ["full"] } proc-macro2 = "1.0.79" quote = "1.0.35" +# members +openzeppelin-stylus = { path = "contracts" } +openzeppelin-crypto = { path = "lib/crypto" } +motsu = { path = "lib/motsu"} +motsu-proc = { path = "lib/motsu-proc", version = "0.1.0" } +e2e = { path = "lib/e2e" } +e2e-proc = {path = "lib/e2e-proc"} + [profile.release] codegen-units = 1 panic = "abort" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 921de2f6..f16effd4 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -4,15 +4,15 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives = { workspace = true, features = ["tiny-keccak"] } alloy.workspace = true tokio.workspace = true eyre.workspace = true koba.workspace = true -e2e = { path = "../lib/e2e" } +e2e.workspace = true serde = "1.0.203" keccak-const = "0.2.0" diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index d7c64340..f079ce0e 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true keywords.workspace = true license.workspace = true repository.workspace = true -version = "0.1.0-rc" +version.workspace = true [dependencies] alloy-primitives.workspace = true @@ -18,7 +18,7 @@ keccak-const.workspace = true [dev-dependencies] alloy-primitives = { workspace = true, features = ["arbitrary"] } -motsu = { path = "../lib/motsu" } +motsu.workspace = true rand.workspace = true [features] diff --git a/examples/access-control/Cargo.toml b/examples/access-control/Cargo.toml index d3fdeef2..cf032181 100644 --- a/examples/access-control/Cargo.toml +++ b/examples/access-control/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -15,7 +15,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true diff --git a/examples/basic/token/Cargo.toml b/examples/basic/token/Cargo.toml index baee1283..077980f9 100644 --- a/examples/basic/token/Cargo.toml +++ b/examples/basic/token/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true diff --git a/examples/ecdsa/Cargo.toml b/examples/ecdsa/Cargo.toml index 2d5b3a91..7cac7e54 100644 --- a/examples/ecdsa/Cargo.toml +++ b/examples/ecdsa/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -15,7 +15,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true diff --git a/examples/erc20-permit/Cargo.toml b/examples/erc20-permit/Cargo.toml index 29cc3424..90081954 100644 --- a/examples/erc20-permit/Cargo.toml +++ b/examples/erc20-permit/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives = { workspace = true, features = ["tiny-keccak"] } stylus-sdk.workspace = true stylus-proc.workspace = true @@ -17,7 +17,7 @@ mini-alloc.workspace = true alloy.workspace = true eyre.workspace = true tokio.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true [features] e2e = [] diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml index 18156804..037d3be9 100644 --- a/examples/erc20/Cargo.toml +++ b/examples/erc20/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -17,7 +17,7 @@ mini-alloc.workspace = true alloy.workspace = true eyre.workspace = true tokio.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true [features] e2e = [] diff --git a/examples/erc721-consecutive/Cargo.toml b/examples/erc721-consecutive/Cargo.toml index 2c6eef27..08b7f5b4 100644 --- a/examples/erc721-consecutive/Cargo.toml +++ b/examples/erc721-consecutive/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true stylus-sdk.workspace = true @@ -16,7 +16,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true diff --git a/examples/erc721-metadata/Cargo.toml b/examples/erc721-metadata/Cargo.toml index 1bc6050a..62b1f298 100644 --- a/examples/erc721-metadata/Cargo.toml +++ b/examples/erc721-metadata/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -15,7 +15,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml index 6f70bb7f..c11254dc 100644 --- a/examples/erc721/Cargo.toml +++ b/examples/erc721/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -15,7 +15,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true rand.workspace = true diff --git a/examples/merkle-proofs/Cargo.toml b/examples/merkle-proofs/Cargo.toml index 60931af4..e741ccbe 100644 --- a/examples/merkle-proofs/Cargo.toml +++ b/examples/merkle-proofs/Cargo.toml @@ -4,10 +4,10 @@ edition.workspace = true license.workspace = true repository.workspace = true publish = false -version = "0.0.0" +version.workspace = true [dependencies] -openzeppelin-crypto = { path = "../../lib/crypto" } +openzeppelin-crypto.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true stylus-sdk.workspace = true diff --git a/examples/ownable/Cargo.toml b/examples/ownable/Cargo.toml index 13ebcbe7..6ac97fa3 100644 --- a/examples/ownable/Cargo.toml +++ b/examples/ownable/Cargo.toml @@ -7,7 +7,7 @@ publish = false version = "0.0.0" [dependencies] -openzeppelin-stylus = { path = "../../contracts" } +openzeppelin-stylus.workspace = true alloy-primitives.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true @@ -15,7 +15,7 @@ mini-alloc.workspace = true [dev-dependencies] alloy.workspace = true -e2e = { path = "../../lib/e2e" } +e2e.workspace = true tokio.workspace = true eyre.workspace = true diff --git a/lib/crypto/Cargo.toml b/lib/crypto/Cargo.toml index cf119fc9..81a44fd8 100644 --- a/lib/crypto/Cargo.toml +++ b/lib/crypto/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true keywords.workspace = true license.workspace = true repository.workspace = true -version = "0.1.0-rc" +version.workspace = true [dependencies] mini-alloc.workspace = true diff --git a/lib/e2e/Cargo.toml b/lib/e2e/Cargo.toml index 6d6cf933..0c48aa14 100644 --- a/lib/e2e/Cargo.toml +++ b/lib/e2e/Cargo.toml @@ -15,7 +15,7 @@ eyre.workspace = true regex.workspace = true once_cell.workspace = true koba.workspace = true -e2e-proc = { path = "../e2e-proc" } +e2e-proc.workspace = true toml = "0.8.13" [lints] diff --git a/lib/motsu-proc/Cargo.toml b/lib/motsu-proc/Cargo.toml index 1e6bbbcf..7b172b60 100644 --- a/lib/motsu-proc/Cargo.toml +++ b/lib/motsu-proc/Cargo.toml @@ -13,7 +13,7 @@ quote.workspace = true syn.workspace = true [dev-dependencies] -motsu = { path = "../motsu" } +motsu.workspace = true alloy-primitives.workspace = true alloy-sol-types.workspace = true stylus-sdk.workspace = true diff --git a/lib/motsu/Cargo.toml b/lib/motsu/Cargo.toml index ed66709e..57f1f19a 100644 --- a/lib/motsu/Cargo.toml +++ b/lib/motsu/Cargo.toml @@ -12,7 +12,7 @@ const-hex.workspace = true once_cell.workspace = true tiny-keccak.workspace = true stylus-sdk.workspace = true -motsu-proc = { path = "../motsu-proc" } +motsu-proc.workspace = true [lints] workspace = true