Commit 8165b244 authored by Hero Bird's avatar Hero Bird Committed by GitHub

Fix CI (finally) (#265)

* Update some deps
Signed-off-by: Qinxuan Chen's avatarkoushiro <koushiro.cqx@gmail.com>

* Format
Signed-off-by: Qinxuan Chen's avatarkoushiro <koushiro.cqx@gmail.com>

* Fix clippy-wasm
Signed-off-by: Qinxuan Chen's avatarkoushiro <koushiro.cqx@gmail.com>

* [examples] fix minor formatting issues

* [examples] fix some clippy warnings

* [lang2/macro] silence warning for ink! constructors named "new"

* [*] replace documentation link in Cargo.toml to ink! tutorial

* [abi] specify allow(clippy::trivially_copy_pass_by_ref) in a smaller scope

* [abi] specify allow(clippy::new_ret_no_self) in smaller scope

* [ci] adjust gitlab-ci.yml

* [ci] update Travis CI to just do coverage reporting
parent 00ea3938
Pipeline #69591 passed with stages
in 29 minutes and 43 seconds
......@@ -122,7 +122,7 @@ clippy-wasm:
- check-wasm
script:
- for crate in ${WASM_CRATES}; do
cargo clippy --verbose --manifest-path ${crate}/Cargo.toml --no-default-features -- -D warnings;
cargo clippy --verbose --manifest-path ${crate}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
done
fmt:
......@@ -157,7 +157,7 @@ examples-clippy-std:
<<: *docker-env
script:
- for example in examples/lang2/*; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --all-features -- -D warnings;
cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings;
done
examples-clippy-wasm:
......@@ -165,7 +165,7 @@ examples-clippy-wasm:
<<: *docker-env
script:
- for example in examples/lang2/*; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features -- -D warnings;
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
done
examples-contract-build:
......
......@@ -4,16 +4,11 @@ dist: trusty
sudo: true
rust:
# - stable
# - beta
- nightly
- nightly-2019-10-04
- nightly-2019-11-17
matrix:
allow_failures:
- rust: nightly
# - rust: stable
# - rust: beta
env:
global:
......@@ -56,31 +51,9 @@ install:
# Print current work directory state as directions.
- ls -lah
before_script:
- rustup component add clippy rustfmt
- rustup target add wasm32-unknown-unknown
script:
- |
./scripts/check-workspace.sh
check_workspace=$?
if [ $check_workspace -eq 0 ]
then
# Execute and upload kcov results
cargo kcov --verbose --coveralls --all --no-clean-rebuild
kcov=$?
bash <(curl -s https://codecov.io/bash)
fi
./scripts/check-examples.sh
check_examples=$?
if [ $check_examples -eq 0 ] && [ $check_workspace -eq 0 ]
then
echo "All checks have passed!"
exit 0
else
echo "Some checks have not passed!"
exit 1
fi
cargo test --all-features --all
cargo kcov --verbose --coveralls --all --no-clean-rebuild
bash <(curl -s https://codecov.io/bash)
exit 0
......@@ -6,16 +6,17 @@ edition = "2018"
license = "APACHE-2.0"
readme = "README.md"
description = "Rust based eDSL for writing smart contracts for Substrate"
repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/"
homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[dependencies]
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
derive_more = { version = "0.99.1", default-features = false, features = ["from"] }
derive_more = { version = "0.99.2", default-features = false, features = ["from"] }
ink_abi_derive = { version = "0.1.0", path = "derive", default-features = false, optional = true }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"] }
......@@ -27,11 +28,11 @@ default = [
"std",
"derive",
]
derive = [
"ink_abi_derive"
]
std = [
"ink_abi_derive/std",
"serde/std",
"type-metadata/std",
]
derive = [
"ink_abi_derive"
]
......@@ -3,9 +3,15 @@ name = "ink_abi_derive"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
readme = "../README.md"
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/"
homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[lib]
proc-macro = true
......
../../LICENSE
\ No newline at end of file
../../README.md
\ No newline at end of file
......@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::impl_wrapper::wrap;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{
......@@ -28,6 +27,8 @@ use syn::{
Token,
};
use crate::impl_wrapper::wrap;
pub fn generate(input: TokenStream2) -> TokenStream2 {
match generate_impl(input) {
Ok(output) => output,
......
......@@ -14,6 +14,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
extern crate alloc;
extern crate proc_macro;
......
......@@ -12,12 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[cfg(not(feature = "std"))]
use alloc::{
string::String,
vec::Vec,
};
use core::fmt::Write;
use derive_more::From;
use serde::{
Serialize,
Serializer,
};
use std::fmt::Write;
use type_metadata::{
form::{
CompactForm,
......@@ -28,9 +34,6 @@ use type_metadata::{
Registry,
};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
/// Implemented by types that have a storage layout.
///
/// Has to be used on previously allocated instances of the types.
......
......@@ -12,7 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(clippy::new_ret_no_self)]
#[cfg(not(feature = "std"))]
use alloc::{
format,
vec,
vec::Vec,
};
use core::marker::PhantomData;
use serde::{
Serialize,
Serializer,
......@@ -28,12 +37,6 @@ use type_metadata::{
Registry,
};
#[cfg(not(feature = "std"))]
use alloc::{
vec,
vec::Vec,
};
/// Describes a contract.
#[derive(Debug, PartialEq, Eq, Serialize)]
#[serde(bound = "F::TypeId: Serialize")]
......@@ -717,7 +720,6 @@ impl EventParamSpecBuilder {
docs: docs.into_iter().collect::<Vec<_>>(),
..self.spec
},
..self
}
}
......@@ -823,6 +825,7 @@ impl MessageParamSpecBuilder {
}
}
#[allow(clippy::trivially_copy_pass_by_ref)]
fn serialize_selector<S>(s: &[u8; 4], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
......@@ -841,10 +844,10 @@ mod tests {
#[test]
fn construct_selector_must_serialize_to_hex() {
// given
let name = <MetaForm as Form>::String::from("foo");
let name = "foo";
let cs: ConstructorSpec<MetaForm> = ConstructorSpec {
name,
selector: 123456789u32.to_be_bytes(),
selector: 123_456_789u32.to_be_bytes(),
args: Vec::new(),
docs: Vec::new(),
};
......
......@@ -6,16 +6,13 @@ edition = "2018"
license = "APACHE-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://github.com/paritytech/ink/wiki"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/"
homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[dependencies]
wee_alloc = { version = "0.4", default-features = false }
......
......@@ -17,6 +17,8 @@ pub fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::intrinsics::abort() }
}
// `extern` fn uses type `core::alloc::Layout`, which is not FFI-safe
#[allow(improper_ctypes)]
#[alloc_error_handler]
pub extern "C" fn oom(_: core::alloc::Layout) -> ! {
unsafe { core::intrinsics::abort() }
......
......@@ -13,7 +13,7 @@
// limitations under the License.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler, core_intrinsics,))]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler, core_intrinsics))]
// Use `wee_alloc` as the global allocator.
#[cfg(not(feature = "std"))]
......
......@@ -7,26 +7,27 @@ edition = "2018"
license = "APACHE-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/"
homepage = "https://www.parity.io/"
description = "Setup and deployment tool for developing Wasm based smart contracts via ink!"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["cli", "tool"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[dependencies]
env_logger = "0.6"
derive_more = { version = "0.99.1", default-features = false, features = ["from", "display"] }
structopt = "0.2.15"
env_logger = "0.7"
derive_more = { version = "0.99.2", default-features = false, features = ["from", "display"] }
structopt = "0.3"
itertools = "0.8"
log = "0.4"
heck = "0.3"
futures = "0.1.28"
jsonrpc-core-client = { version = "13.0", features = ["ws"] }
jsonrpc-core-client = { version = "14.0", features = ["ws"] }
zip = { version = "0.5", default-features = false }
pwasm-utils = "0.11.0"
parity-wasm = "0.40.2"
cargo_metadata = "0.8.2"
pwasm-utils = "0.12"
parity-wasm = "0.41"
cargo_metadata = "0.9"
substrate-primitives = { git = "https://github.com/paritytech/substrate/", package = "substrate-primitives" }
subxt = { git = "https://github.com/paritytech/substrate-subxt/", branch = "v0.2", package = "substrate-subxt" }
tokio = "0.1.21"
......@@ -34,7 +35,7 @@ url = "1.7"
[build-dependencies]
zip = { version = "0.5", default-features = false }
walkdir = "1.0"
walkdir = "2.2"
[dev-dependencies]
assert_matches = "1.3.0"
......
......@@ -14,13 +14,20 @@
use std::{
error::Error,
fs::File,
io::{
prelude::*,
Write,
},
iter::Iterator,
path::{
Path,
PathBuf,
},
result::Result,
};
use walkdir::WalkDir;
use zip::{
result::ZipError,
write::FileOptions,
......@@ -28,15 +35,6 @@ use zip::{
ZipWriter,
};
use std::{
fs::File,
path::{
Path,
PathBuf,
},
};
use walkdir::WalkDir;
const DEFAULT_UNIX_PERMISSIONS: u32 = 0o755;
fn main() {
......
......@@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::cmd::{
CommandError as Error,
Result,
};
use std::path::PathBuf;
use cargo_metadata::MetadataCommand;
use parity_wasm::elements::{
External,
......@@ -23,7 +21,11 @@ use parity_wasm::elements::{
Module,
Section,
};
use std::path::PathBuf;
use crate::cmd::{
CommandError as Error,
Result,
};
/// This is the maximum number of pages available for a contract to allocate.
const MAX_MEMORY_PAGES: u32 = 16;
......
......@@ -12,20 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::cmd::{
build::{
self,
CrateMetadata,
},
Result,
};
use futures::future::Future;
use std::{
fs,
io::Read,
path::PathBuf,
};
use futures::future::Future;
use substrate_primitives::{
crypto::Pair,
sr25519,
......@@ -37,6 +30,14 @@ use subxt::{
DefaultNodeRuntime,
};
use crate::cmd::{
build::{
self,
CrateMetadata,
},
Result,
};
/// Load the wasm blob from the specified path.
///
/// Defaults to the target contract wasm in the current project, inferred via the crate metadata.
......@@ -105,13 +106,14 @@ pub(crate) fn execute_deploy(
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use std::{
fs,
io::Write,
path,
};
use assert_matches::assert_matches;
#[test]
#[ignore] // depends on a local substrate node running
fn deploy_contract() {
......
......@@ -12,11 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use jsonrpc_core_client::RpcError;
use std::{
io::Error as IoError,
result::Result as StdResult,
};
use jsonrpc_core_client::RpcError;
use substrate_primitives::crypto::SecretStringError;
use subxt::Error as SubXtError;
use zip::result::ZipError;
......
......@@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::cmd::Result;
use cargo_metadata::MetadataCommand;
use std::path::PathBuf;
use cargo_metadata::MetadataCommand;
use crate::cmd::Result;
/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying.
///
/// It does so by invoking build by cargo and then post processing the final binary.
......@@ -35,7 +37,7 @@ pub(crate) fn execute_generate_metadata(dir: Option<&PathBuf>) -> Result<String>
)?;
let cargo_metadata = MetadataCommand::new().exec()?;
let mut out_path = cargo_metadata.target_directory.clone();
let mut out_path = cargo_metadata.target_directory;
out_path.push("metadata.json");
Ok(format!(
......@@ -48,8 +50,8 @@ pub(crate) fn execute_generate_metadata(dir: Option<&PathBuf>) -> Result<String>
mod tests {
use crate::{
cmd::{
execute_new,
execute_generate_metadata,
execute_new,
tests::with_tmp_dir,
},
AbstractionLayer,
......@@ -62,9 +64,10 @@ mod tests {
execute_new(AbstractionLayer::Lang, "new_project", Some(path))
.expect("new project creation failed");
let working_dir = path.join("new_project");
super::execute_generate_metadata(Some(&working_dir)).expect("generate metadata failed");
execute_generate_metadata(Some(&working_dir))
.expect("generate metadata failed");
let mut abi_file = working_dir.clone();
let mut abi_file = working_dir;
abi_file.push("target");
abi_file.push("metadata.json");
assert!(abi_file.exists())
......
......@@ -21,20 +21,20 @@ use std::{
process::Command,
};
mod metadata;
mod build;
mod deploy;
mod error;
mod metadata;
mod new;
pub(crate) use self::{
metadata::execute_generate_metadata,
build::execute_build,
deploy::execute_deploy,
error::{
CommandError,
Result,
},
metadata::execute_generate_metadata,
new::execute_new,
};
......
......@@ -12,14 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{
cmd::{
CommandError,
Result,
},
AbstractionLayer,
};
use heck::CamelCase as _;
use std::{
env,
fs,
......@@ -33,6 +25,16 @@ use std::{
path::PathBuf,
};
use heck::CamelCase as _;
use crate::{
cmd::{
CommandError,
Result,
},
AbstractionLayer,
};
/// Initializes a project structure for the `lang` abstraction layer.
fn initialize_for_lang(name: &str, target_dir: Option<&PathBuf>) -> Result<String> {
if name.contains('-') {
......
......@@ -15,7 +15,7 @@
mod cmd;
use structopt::{
clap::AppSettings,
clap,
StructOpt,
};
use url::Url;
......@@ -23,15 +23,11 @@ use url::Url;
#[derive(Debug, StructOpt)]
#[structopt(bin_name = "cargo")]
pub(crate) enum Opts {
#[structopt(
name = "contract",
raw(
setting = "AppSettings::UnifiedHelpMessage",
setting = "AppSettings::DeriveDisplayOrder",
setting = "AppSettings::DontCollapseArgsInUsage"
)
)]
/// Utilities to develop Wasm smart contracts.
#[structopt(name = "contract")]
#[structopt(setting = clap::AppSettings::UnifiedHelpMessage)]
#[structopt(setting = clap::AppSettings::DeriveDisplayOrder)]
#[structopt(setting = clap::AppSettings::DontCollapseArgsInUsage)]
Contract(ContractArgs),
}
......
......@@ -6,25 +6,22 @@ edition = "2018"
license = "APACHE-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://github.com/paritytech/ink/wiki"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/"
homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[dependencies]
ink_abi = { path = "../abi/", default-features = false, features = ["derive"], optional = true }
ink_alloc = { path = "../alloc/", default-features = false }
ink_utils = { path = "../utils/", default-features = false }
ink_utils = { path = "../utils/" }
scale = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive", "full"] }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
derive_more = { version = "0.99.1", default-features = false, features = ["from"] }
derive_more = { version = "0.99.2", default-features = false, features = ["from"] }
smallvec = { version = "1.0", default-features = false, features = ["union"] }
cfg-if = "0.1"
......@@ -36,7 +33,6 @@ test-env = [
std = [
"ink_abi/std",
"ink_alloc/std",
"ink_utils/std",
"scale/std",
"type-metadata/std",
]
......@@ -44,4 +40,4 @@ ink-generate-abi = [
"ink_abi",
"type-metadata",
"std",
]
\ No newline at end of file
]
......@@ -12,6 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use scale::{
Decode,
Encode,
};
use super::ContractEnvStorage;
use crate::{
env::{
......@@ -26,10 +31,6 @@ use crate::{
memory::vec::Vec,
storage::Key,
};
use scale::{
Decode,
Encode,
};
/// Stores the given value under the specified key in the contract storage.
///
......
......@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[rustfmt::skip]
use core::marker::PhantomData;
use scale::Decode;
use crate::{
env::{
self,
......@@ -26,8 +29,6 @@ use crate::{
vec::Vec,
},
};
use core::marker::PhantomData;
use scale::Decode;
/// Consists of the input data to a call.
/// The first four bytes are the function selector and the rest are SCALE encoded inputs.
......
......@@ -12,6 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::marker::PhantomData;
use scale::{
Decode,
Encode,
};
use crate::{
env::{
srml::sys,
......@@ -24,11 +31,6 @@ use crate::{
memory::vec::Vec,
storage::Key,
};
use core::marker::PhantomData;
use scale::{
Decode,
Encode,
};
/// Load the contents of the scratch buffer
fn read_scratch_buffer() -> Vec<u8> {
......
......@@ -17,14 +17,16 @@ use core::{
convert::TryFrom,