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

Add workspace-enabled example contracts #44

Closed
wants to merge 8 commits into from
Closed
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
46 changes: 40 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ on:
- '.images/**'
- '**README.md'


jobs:
check:
name: examples
Expand Down Expand Up @@ -61,6 +60,9 @@ jobs:
- vesting
runs-on: ${{ matrix.platform }}
env:
MULTI_CONTRACT_CALLER_SUBCONTRACTS: "accumulator adder subber"
UPGRADEABLE_CONTRACTS: "delegator set-code-hash"
WORKSPACE_CONTRACTS: "erc20 flipper incrementer"
RUST_BACKTRACE: full
steps:
- name: Checkout sources & submodules
Expand Down Expand Up @@ -111,30 +113,62 @@ jobs:
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-linux/substrate-contracts-node &&
./artifacts/substrate-contracts-node-linux/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &

- name: Download and run latest `substrate-contracts-node` binary
if: runner.os == 'macOS'
run: |
curl -L -o substrate-contracts-node.zip 'https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download?job=build-mac' && \
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-mac/substrate-contracts-node &&
./artifacts/substrate-contracts-node-mac/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &

- name: Install and run latest `substrate-contracts-node` binary
if: runner.os == 'Windows'
run: |
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked && \
substrate-contracts-node -lruntime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &

- name: Output versions
run: |
cargo -vV
cargo contract --version

- name: Build ${{ matrix.contract }} examples on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os == 'Windows'
run: |
$multi_contract_caller_subcontracts = "accumulator","adder","subber"
foreach ($contract in $multi_contract_caller_subcontracts) {
echo "Processing multi-contract-caller contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path multi-contract-caller/${contract}/Cargo.toml;
}
$upgradeable_contracts = "delegator","set-code-hash"
foreach ($contract in $upgradeable_contracts) {
echo "Processing upgradeable contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path upgradeable-contracts/${contract}/Cargo.toml;
}
$workspace_contracts = "erc20","flipper","incrementer"
foreach ($contract in $workspace_contracts) {
echo "Processing workspace contract: $contract";
cargo ${{ matrix.job }} --verbose --manifest-path workspace-contracts/${contract}/Cargo.toml;
}
foreach ($example in Get-ChildItem -Directory "\*") {
if ($example -Match 'artifacts') { continue }
echo "Processing example: $example";
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
cargo clean --manifest-path=$example/Cargo.toml;
}
- name: Build ${{ matrix.contract }} on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows'
run: cargo contract build --verbose --manifest-path=${{ matrix.contract }}/Cargo.toml;

for contract in ${{ env.WORKSPACE_CONTRACTS }}
do
echo "Processing workspace contract: $contract "
cargo ${{ matrix.job }} --verbose --manifest-path=workspace-contracts/$contract/Cargo.toml;
done

for example in ./*/; do
if [ "$example" = "./artifacts/" ] || [ "$example" = "./upgradeable-contracts/" ]|| [ "$example" = "./workspace-contracts/" ]; then continue; fi;
echo "Processing example: $example";
cargo ${{ matrix.job }} --verbose --manifest-path=$example/Cargo.toml;
done

- name: Test ${{ matrix.contract }} on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows'
run: cargo test --verbose --manifest-path=${{ matrix.contract }}/Cargo.toml;
run: cargo test --verbose --manifest-path=${{ matrix.contract }}/Cargo.toml;
9 changes: 9 additions & 0 deletions workspace-contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore build artifacts from the local tests sub-crate.
/target/

# Ignore backup files creates by cargo fmt.
**/*.rs.bk

# Remove Cargo.lock when creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock
10 changes: 10 additions & 0 deletions workspace-contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = ["*"]
exclude = [".cargo", "target"]
resolver = "2"

[workspace.dependencies]
ink = { version = "4.3.0", default-features = false }
ink_e2e = "4.3.0"
scale = { package = "parity-scale-codec", version = "=3.6.5", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"] }
28 changes: 28 additions & 0 deletions workspace-contracts/erc20/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "erc20"
version = "4.3.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
publish = false

[dependencies]
ink = { workspace = true }

scale = { workspace = true, package = "parity-scale-codec" }
scale-info = { workspace = true, optional = true }

[dev-dependencies]
ink_e2e = { workspace = true }

[lib]
path = "lib.rs"

[features]
default = ["std"]
std = [
"ink/std",
"scale/std",
"scale-info/std",
]
ink-as-dependency = []
e2e-tests = []
Loading