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

Use cargo workspace feature #89

Merged
merged 8 commits into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ workflows:
jobs:
contract_cw721_base:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
working_directory: ~/project/contracts/cw721-base
steps:
- checkout:
Expand All @@ -31,7 +31,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-cw721-base-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-cw721-base-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
Expand All @@ -53,11 +53,11 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-cw721-base-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-cw721-base-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}

contract_cw721_metadata_onchain:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
working_directory: ~/project/contracts/cw721-metadata-onchain
steps:
- checkout:
Expand All @@ -67,7 +67,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-cw721-metadata-onchain-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-cw721-metadata-onchain-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
Expand All @@ -89,11 +89,11 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-cw721-metadata-onchain-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-cw721-metadata-onchain-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}

contract_cw721_fixed_price:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
working_directory: ~/project/contracts/cw721-fixed-price
steps:
- checkout:
Expand All @@ -103,7 +103,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-cw721-fixed-price-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-cw721-fixed-price-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
environment:
Expand All @@ -125,11 +125,11 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-cw721-fixed-price-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-cw721-fixed-price-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}

package_cw721:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
working_directory: ~/project/packages/cw721
steps:
- checkout:
Expand All @@ -139,7 +139,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version; rustup target list --installed
- restore_cache:
keys:
- cargocache-v2-cw721:1.60.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-v2-cw721:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Build library for native target
command: cargo build --locked
Expand All @@ -162,19 +162,19 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-v2-cw721:1.60.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-v2-cw721:1.64.0-{{ checksum "~/project/Cargo.lock" }}

lint:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
steps:
- checkout
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version; rustup target list --installed
- restore_cache:
keys:
- cargocache-v2-lint-rust:1.60.0-{{ checksum "Cargo.lock" }}
- cargocache-v2-lint-rust:1.64.0-{{ checksum "Cargo.lock" }}
- run:
name: Add rustfmt component
command: rustup component add rustfmt
Expand All @@ -193,15 +193,15 @@ jobs:
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
key: cargocache-v2-lint-rust:1.60.0-{{ checksum "Cargo.lock" }}
key: cargocache-v2-lint-rust:1.64.0-{{ checksum "Cargo.lock" }}

# This runs one time on the top level to ensure all contracts compile properly into wasm.
# We don't run the wasm build per contract build, and then reuse a lot of the same dependencies, so this speeds up CI time
# for all the other tests.
# We also sanity-check the resultant wasm files.
wasm-build:
docker:
- image: rust:1.60.0
- image: rust:1.64.0
steps:
- checkout:
path: ~/project
Expand All @@ -210,7 +210,7 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-wasm-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
- cargocache-wasm-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Add wasm32 target
command: rustup target add wasm32-unknown-unknown
Expand All @@ -230,7 +230,7 @@ jobs:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-wasm-rust:1.60.0-{{ checksum "~/project/Cargo.lock" }}
key: cargocache-wasm-rust:1.64.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Check wasm contracts
command: cosmwasm-check ./target/wasm32-unknown-unknown/release/*.wasm
Expand Down
18 changes: 2 additions & 16 deletions Cargo.lock

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

21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
[workspace]
members = ["packages/*", "contracts/*"]

[workspace.package]
version = "0.15.0"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/CosmWasm/cw-nfts"
homepage = "https://cosmwasm.com"
documentation = "https://docs.cosmwasm.com"

[workspace.dependencies]
cosmwasm-schema = "1.1.0"
cosmwasm-std = "1.1.0"
cw2 = "0.15.0"
cw20 = "0.15.0"
cw721 = { version = "0.15.0", path = "./packages/cw721" }
cw721-base = { version = "0.15.0", path = "./contracts/cw721-base" }
cw-storage-plus = "0.15.0"
cw-utils = "0.15.0"
schemars = "0.8.10"
serde = { version = "1.0.140", default-features = false, features = ["derive"] }
thiserror = "1.0.31"

[profile.release.package.cw721-base]
codegen-units = 1
incremental = false
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.6
cosmwasm/workspace-optimizer:0.12.9
40 changes: 16 additions & 24 deletions contracts/cw2981-royalties/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
[package]
name = "cw2981-royalties"
version = "0.15.0"
authors = ["Alex Lynham <[email protected]>"]
edition = "2021"
description = "Basic implementation of royalties for cw721 NFTs with token level royalties"
license = "Apache-2.0"
repository = "https://github.com/CosmWasm/cw-nfts"
homepage = "https://cosmwasm.com"
documentation = "https://docs.cosmwasm.com"
name = "cw2981-royalties"
description = "Basic implementation of royalties for cw721 NFTs with token level royalties"
authors = ["Alex Lynham <[email protected]>"]
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"artifacts/*",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]

Expand All @@ -25,12 +19,10 @@ backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-schema = "1.1.0"
cosmwasm-std = "1.1.0"
cw2 = "0.15.0"
cw721 = { path = "../../packages/cw721", version = "0.15.0" }
cw721-base = { path = "../cw721-base", version = "0.15.0", features = [
"library",
] }
schemars = "0.8.10"
serde = { version = "1.0.140", default-features = false, features = ["derive"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
cw721 = { workspace = true }
cw721-base = { workspace = true, features = ["library"] }
schemars = { workspace = true }
serde = { workspace = true }
42 changes: 18 additions & 24 deletions contracts/cw721-base/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
[package]
name = "cw721-base"
version = "0.15.0"
authors = [
name = "cw721-base"
description = "Basic implementation cw721 NFTs"
authors = [
"Ethan Frey <[email protected]>",
"Orkun Külçe <[email protected]>",
]
edition = "2021"
description = "Basic implementation cw721 NFTs"
license = "Apache-2.0"
repository = "https://github.com/CosmWasm/cw-nfts"
homepage = "https://cosmwasm.com"
documentation = "https://docs.cosmwasm.com"
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"artifacts/*",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]

Expand All @@ -28,12 +22,12 @@ backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-schema = "1.1.0"
cosmwasm-std = "1.1.0"
cw-utils = "0.15.0"
cw2 = "0.15.0"
cw721 = { path = "../../packages/cw721", version = "0.15.0" }
cw-storage-plus = "0.15.0"
schemars = "0.8.10"
serde = { version = "1.0.140", default-features = false, features = ["derive"] }
thiserror = "1.0.31"
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-utils = { workspace = true }
cw2 = { workspace = true }
cw721 = { workspace = true }
cw-storage-plus = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
Loading