Skip to content

Commit

Permalink
chore: merge branch 'main' into pop-install
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed May 8, 2024
2 parents ebe83d1 + b9a2754 commit 225441d
Show file tree
Hide file tree
Showing 30 changed files with 538 additions and 404 deletions.
36 changes: 36 additions & 0 deletions .github/actions/init/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Initialize
description: This action initializes a runner for use in other actions.
inputs:
cache-key:
description: "The key to be used for the cache"
git-user:
required: true
description: "The user name to be used for git config"

runs:
using: "composite"
steps:
- name: Setup Ubuntu dependencies
shell: bash
run: sudo apt update && sudo apt install -y protobuf-compiler

- name: Free up space on runner
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Setup git config
shell: bash
run: |
git config --global user.name ${{ inputs.git-user }}
git config --global user.email ${{ inputs.git-user }}@users.noreply.github.com
- name: Rust Cache
uses: Swatinem/[email protected]
with:
cache-on-failure: true
cache-all-crates: true
key: ${{ inputs.cache-key }}
110 changes: 60 additions & 50 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,68 @@ env:
GITHUB_ACTOR: pop-cli

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check formatting
run: cargo fmt --all -- --check

build:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Check Feature Contracts Excl.
run: cargo check --no-default-features --features contract

- name: Check Features Parachain Excl.
run: cargo check --no-default-features --features parachain

- name: Build default features
run: cargo build

unit-tests:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Run unit tests
run: cargo test --lib

contract-integration-tests:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Run integration tests
run: cargo test --no-default-features --features contract --test contract

parachain-integration-tests:
needs: lint
runs-on: ubuntu-latest
steps:
- name: Free up space on runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Rust Cache
uses: Swatinem/[email protected]
with:
cache-on-failure: true
cache-all-crates: true

- name: Setup git config
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Install Protoc
uses: arduino/[email protected]
with:
version: "3.6.1"

- name: Rust Setup
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy, rust-src

- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all -- --check

- uses: actions/checkout@v3
- name: Check Feature Contracts Excl.
run: cargo check --no-default-features --features contract

- uses: actions/checkout@v3
- name: Check Features Parachain Excl.
run: cargo check --no-default-features --features parachain

- uses: actions/checkout@v3
- name: Build default features
run: cargo build

- name: Run tests
run: cargo test --all-features
- uses: actions/checkout@v4

- uses: "./.github/actions/init"
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Run integration tests
run: cargo test --no-default-features --features parachain --test parachain
4 changes: 2 additions & 2 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ duct = "0.13"
git2 = "0.18"
tempfile = "3.8"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
url = { version = "2.5"}
url = { version = "2.5" }

# contracts
subxt-signer = { version = "0.34.0", features = ["subxt", "sr25519"]}
subxt-signer = { version = "0.34.0", features = ["subxt", "sr25519"] }
subxt = { version = "0.34.0" }
ink_env = { version = "5.0.0-rc.2" }
sp-core = { version = "30.0.0"}
sp-core = { version = "30.0.0" }
sp-weights = { version = "29.0.0" }
contract-build = { version = "4.0.2" }
contract-extrinsics = { version = "4.0.0-rc.3"}
contract-extrinsics = { version = "4.0.0-rc.3" }

# parachains
askama = "0.12"
regex="1.5.4"
regex = "1.5.4"
walkdir = "2.4"
indexmap = { version = "2.2"}
indexmap = { version = "2.2" }
toml_edit = { version = "0.22", features = ["serde"] }
symlink = { version = "0.1" }
reqwest = { version = "0.11" }
serde_json = { version = "1.0"}
serde_json = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
zombienet-sdk = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", version = "0.1.0-alpha.1"}
zombienet-sdk = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", version = "0.1.0-alpha.1" }
zombienet-support = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", version = "0.1.0-alpha.1" }
git2_credentials = "0.13.0"

# pop-cli
clap = { version = "4.4", features = ["derive"] }
cliclack = "0.1"
cliclack = "0.2"
console = "0.15"
strum = "0.26"
strum_macros = "0.26"
53 changes: 21 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,35 @@ cargo install --locked --git https://github.com/r0gue-io/pop-cli

Use `pop` to create a new Parachain project.
To be guided through the entire parachain creation process, simply execute

```sh
pop new parachain
```

If no guidance is needed, proceed with:

```sh
# Create a minimal parachain
pop new parachain my-app
```


We also integrate other provider templates in the tool, check them running:

```sh
pop new parachain --help
```
Some examples are:

Some examples are:

```sh
# Get Parity's pallet-contracts enabled parachain template
pop new parachain my-app parity -t cpt
# Get Parity's evm compatible parachain template
pop new parachain my-app parity -t fpt
```

For Pop templates you can also customize your parachain by providing config options for token symbol (as it appears in chain metadata),
token decimals, and the initial endowment for developer accounts. Here's how:
For Pop templates you can also customize your parachain by providing config options for token symbol (as it appears in
chain metadata), token decimals, and the initial endowment for developer accounts. Here's how:

```sh
# Create a minimal parachain with "DOT" as token symbol, 6 token decimals and 1 billion tokens per dev account
Expand All @@ -71,7 +75,6 @@ cd my-app
pop build parachain
```


Finally, to build your Parachain:

```sh
Expand All @@ -90,7 +93,6 @@ pop up parachain -f ./tests/zombienet.toml -p https://github.com/r0gue-io/pop-no
> :information_source: Pop CLI will automatically source the necessary polkadot binaries. Currently, these will be built
> if on a non-linux system.

### Contracts

Use `pop` to create a new Smart Contract project:
Expand Down Expand Up @@ -221,55 +223,42 @@ Build the tool only for Smart Contracts functionality:
cargo build --features contract
```

## Testing Pop CLI
## Testing Pop CLI

To test the tool locally.
To test the tool locally. Due to the time it can take to build a Parachain or a Smart Contract, some tests have been
separated from the normal testing flow into integration tests.

Run the unit tests:
Run the unit tests only:

```sh
cargo test
cargo test --lib
```

Due to the time it can take to build a Parachain or a Smart Contract, some tests have been separated from the normal testing flow.

To run the unit tests that involves building a Smart Contract:
To run the integration tests relating to Smart Contracts:

```sh
cargo test --features unit_contract
cargo test --test contract
```

To run the unit tests that involves building a Parachain:
To run the integration tests relating to Parachains:

```sh
cargo test --features unit_parachain
cargo test --test parachain
```

Then we have some tests that check all the flows are correct:

Run the e2e tests for Smart Contracts functionality:

```sh
cargo test --features e2e_contract
```

Run the e2e tests for Parachain functionality:
Run all tests (unit + integration):

```sh
cargo test --features e2e_parachain
cargo test
```

Run all tests:

```sh
cargo test --all-features
```
## Acknowledgements

Pop CLI would not be possible without these awesome crates!

- Local network deployment powered by [zombienet-sdk](https://github.com/paritytech/zombienet-sdk)
- [cargo contract](https://github.com/paritytech/cargo-contract) a setup and deployment tool for developing Wasm based Smart Contracts via ink!
- [cargo contract](https://github.com/paritytech/cargo-contract) a setup and deployment tool for developing Wasm based
Smart Contracts via ink!

## License

Expand Down
5 changes: 0 additions & 5 deletions crates/pop-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ contract = [
"dep:sp-core",
"dep:sp-weights",
]
e2e_contract = []
unit_contract = []
parachain = [
"dep:pop-parachains",
"dep:dirs",
]
e2e_parachain = []
unit_parachain = []

6 changes: 3 additions & 3 deletions crates/pop-cli/src/commands/call/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl CallContractCommand {
.await?;

if !self.execute {
let mut spinner = cliclack::spinner();
let spinner = cliclack::spinner();
spinner.start("Calling the contract...");
let call_dry_run_result = dry_run_call(&call_exec).await?;
log::info(format!("Result: {}", call_dry_run_result))?;
Expand All @@ -89,7 +89,7 @@ impl CallContractCommand {
weight_limit =
Weight::from_parts(self.gas_limit.unwrap(), self.proof_size.unwrap());
} else {
let mut spinner = cliclack::spinner();
let spinner = cliclack::spinner();
spinner.start("Doing a dry run to estimate the gas...");
weight_limit = match dry_run_gas_estimate_call(&call_exec).await {
Ok(w) => {
Expand All @@ -103,7 +103,7 @@ impl CallContractCommand {
},
};
}
let mut spinner = cliclack::spinner();
let spinner = cliclack::spinner();
spinner.start("Calling the contract...");

let call_result = call_smart_contract(call_exec, weight_limit, &self.url)
Expand Down
6 changes: 2 additions & 4 deletions crates/pop-cli/src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl NewContractCommand {
fs::remove_dir_all(contract_path.as_path())?;
}
fs::create_dir_all(contract_path.as_path())?;
let mut spinner = cliclack::spinner();
let spinner = cliclack::spinner();
spinner.start("Generating contract...");
create_smart_contract(&self.name, contract_path.as_path())?;
spinner.stop("Smart contract created!");
Expand All @@ -68,9 +68,7 @@ mod tests {
name: "test_contract".to_string(),
path: Some(PathBuf::from(temp_contract_dir.path())),
};
let result = command.execute().await;
assert!(result.is_ok());

command.execute().await?;
Ok(())
}
}
Loading

0 comments on commit 225441d

Please sign in to comment.