Unverified Commit ef960aae authored by Hero Bird's avatar Hero Bird Committed by GitHub
Browse files

Improve GitLab CI (#235)

* [lang2/macro] add some dev-dependencies to make CI work better

* [scripts] improve check-workspace script

We introduced "hacks" to make it work with the currently buggy nightly version of cargo ... We hope we can move back to were we came once cargo nightly has been fixed again.

* [*] fix formatting issues

* [cli] re-enable build_template test

* [lang2] fix some clippy warnings

* [cli] fix formatting

* test what's faster

* typo

* debug no config and job name

* bench CI var2

* set of jobs for every crate

* ordered set of jobs for every crate

* right commands for the crates and examples. H/e examples will work after dockerfile update.

* comparing two CI approaches

* typo

* forgot to exclude model and lang crates

* bench CI 2

* will bench in other branch

* fix return in cycle

* review 1

* unset allow_failures

* changed cd to popd

* changed cd to popd

* Update .gitlab-ci.yml

* Update .gitlab-ci.yml

* Update .gitlab-ci.yml

* Update .gitlab-ci.yml

* Update .gitlab-ci.yml

* Update .gitlab-ci.yml

* Update cli/src/cmd/abi.rs
parent 775992ea
Pipeline #56964 failed with stages
in 1 minute and 33 seconds
...@@ -16,6 +16,8 @@ variables: ...@@ -16,6 +16,8 @@ variables:
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
CI_SERVER_NAME: "GitLab CI" CI_SERVER_NAME: "GitLab CI"
REGISTRY: registry.parity.io/parity/infrastructure/scripts REGISTRY: registry.parity.io/parity/infrastructure/scripts
ALL_CRATES: "core alloc utils lang2 lang2/macro cli"
WASM_CRATES: "core alloc utils lang2 lang2/macro"
.collect-artifacts: &collect-artifacts .collect-artifacts: &collect-artifacts
artifacts: artifacts:
...@@ -32,6 +34,7 @@ variables: ...@@ -32,6 +34,7 @@ variables:
- rustc -vV - rustc -vV
- rustup show - rustup show
- bash --version - bash --version
- mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
# global RUSTFLAGS overrides the linker args so this way is better to pass the flags # global RUSTFLAGS overrides the linker args so this way is better to pass the flags
- printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config - printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config
- sccache -s - sccache -s
...@@ -52,73 +55,121 @@ variables: ...@@ -52,73 +55,121 @@ variables:
#### stage: check-workspace #### stage: check-workspace
cargo-check-af: check-std:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo check --verbose --all --all-features - for crate in ${ALL_CRATES}; do
cargo check --verbose --all-features;
done
cargo-check-nf: check-wasm:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo check --verbose --all --no-default-features - for crate in ${WASM_CRATES}; do
cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
done
cargo-fmt: build-std:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo fmt --verbose --all -- --check - for crate in ${ALL_CRATES}; do
cargo build --verbose --all-features --release;
done
cargo-clippy-af: build-wasm:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo clippy --verbose --all --all-features -- -D warnings - for crate in ${WASM_CRATES}; do
cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
done
cargo-clippy-nf: test-std:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo clippy --verbose --all --no-default-features -- -D warnings - for crate in ${ALL_CRATES}; do
cargo test --verbose --all-features --release;
done
cargo-test-af: clippy-std:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo test --verbose --all --all-features - for crate in ${ALL_CRATES}; do
cargo clippy --verbose --all-features -- -D warnings;
done
cargo-build-nf: clippy-wasm:
stage: check-workspace stage: check-workspace
<<: *docker-env <<: *docker-env
script: script:
- cargo build --verbose --all --no-default-features --release --target=wasm32-unknown-unknown - for crate in ${WASM_CRATES}; do
cargo clippy --verbose --manifest-path ${crate}/Cargo.toml --no-default-features -- -D warnings;
done
fmt:
stage: check-workspace
<<: *docker-env
script:
- for crate in ${ALL_CRATES}; do
cargo fmt --verbose -- --check;
done
#### stage: examples #### stage: examples
examples-wasm: examples-test:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
script: script:
- for example in $(ls examples/lang); do - for DIR in examples/lang2/*; do
cargo build --release --no-default-features --target=wasm32-unknown-unknown --verbose --manifest-path examples/lang/$example/Cargo.toml; cargo test --verbose --manifest-path ${DIR}/Cargo.toml;
done done
- sccache -s
examples-test: examples-fmt:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
script: script:
- for example in $(ls examples/lang); do - for example in examples/lang2/*; do
cargo test --verbose --manifest-path examples/lang/$example/Cargo.toml; cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
done done
- sccache -s
examples-abi: examples-clippy-std:
stage: examples stage: examples
<<: *docker-env <<: *docker-env
script: script:
- for example in $(ls examples/lang); do - for example in examples/lang2/*; do
cargo run --package abi-gen --manifest-path examples/lang/$example/Cargo.toml; cargo clippy --verbose --manifest-path ${example}/Cargo.toml --all-features -- -D warnings;
done
examples-clippy-wasm:
stage: examples
<<: *docker-env
script:
- for example in examples/lang2/*; do
cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features -- -D warnings;
done
examples-contract-build:
stage: examples
<<: *docker-env
script:
- for example in examples/lang2/*; do
pushd $example &&
cargo contract build &&
popd;
done
examples-generate-abi:
stage: examples
<<: *docker-env
script:
- for example in examples/lang2/*; do
pushd $example &&
cargo contract generate-abi &&
popd;
done done
- sccache -s
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>. // along with ink!. If not, see <http://www.gnu.org/licenses/>.
use crate::cmd::{ use crate::cmd::Result;
Result,
};
use cargo_metadata::MetadataCommand; use cargo_metadata::MetadataCommand;
use std::path::PathBuf; use std::path::PathBuf;
...@@ -26,13 +24,17 @@ use std::path::PathBuf; ...@@ -26,13 +24,17 @@ use std::path::PathBuf;
pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> { pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
println!(" Generating abi"); println!(" Generating abi");
super::exec_cargo("run", &[ super::exec_cargo(
"--package", "run",
"abi-gen", &[
"--release", "--package",
"--no-default-features", "abi-gen",
"--verbose", "--release",
], dir)?; // "--no-default-features", // Breaks builds for MacOS (linker errors), we should investigate this issue asap!
"--verbose",
],
dir,
)?;
let metadata = MetadataCommand::new().exec()?; let metadata = MetadataCommand::new().exec()?;
let mut abi_path = metadata.target_directory.clone(); let mut abi_path = metadata.target_directory.clone();
...@@ -48,8 +50,8 @@ pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> { ...@@ -48,8 +50,8 @@ pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
mod tests { mod tests {
use crate::{ use crate::{
cmd::{ cmd::{
execute_new,
execute_generate_abi, execute_generate_abi,
execute_new,
tests::with_tmp_dir, tests::with_tmp_dir,
}, },
AbstractionLayer, AbstractionLayer,
......
...@@ -89,12 +89,16 @@ pub fn collect_crate_metadata(working_dir: Option<&PathBuf>) -> Result<CrateMeta ...@@ -89,12 +89,16 @@ pub fn collect_crate_metadata(working_dir: Option<&PathBuf>) -> Result<CrateMeta
/// ///
/// Currently it assumes that user wants to use `+nightly`. /// Currently it assumes that user wants to use `+nightly`.
fn build_cargo_project(working_dir: Option<&PathBuf>) -> Result<()> { fn build_cargo_project(working_dir: Option<&PathBuf>) -> Result<()> {
super::exec_cargo("build", &[ super::exec_cargo(
"--no-default-features", "build",
"--release", &[
"--target=wasm32-unknown-unknown", "--no-default-features",
"--verbose", "--release",
], working_dir) "--target=wasm32-unknown-unknown",
"--verbose",
],
working_dir,
)
} }
/// Ensures the wasm memory import of a given module has the maximum number of pages. /// Ensures the wasm memory import of a given module has the maximum number of pages.
......
...@@ -40,7 +40,11 @@ pub(crate) use self::{ ...@@ -40,7 +40,11 @@ pub(crate) use self::{
new::execute_new, new::execute_new,
}; };
fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf>) -> Result<()> { fn exec_cargo(
command: &str,
args: &[&'static str],
working_dir: Option<&PathBuf>,
) -> Result<()> {
let mut cmd = Command::new("cargo"); let mut cmd = Command::new("cargo");
let mut is_nightly_cmd = Command::new("cargo"); let mut is_nightly_cmd = Command::new("cargo");
if let Some(dir) = working_dir { if let Some(dir) = working_dir {
...@@ -60,10 +64,7 @@ fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf ...@@ -60,10 +64,7 @@ fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf
cmd.arg("+nightly"); cmd.arg("+nightly");
} }
let output = cmd let output = cmd.arg(command).args(args).output()?;
.arg(command)
.args(args)
.output()?;
if !output.status.success() { if !output.status.success() {
// Dump the output streams produced by cargo into the stdout/stderr. // Dump the output streams produced by cargo into the stdout/stderr.
......
...@@ -29,8 +29,10 @@ derive_more = { version = "0.99.1", default-features = false, features = ["from" ...@@ -29,8 +29,10 @@ derive_more = { version = "0.99.1", default-features = false, features = ["from"
regex = "1.3" regex = "1.3"
[dev-dependencies] [dev-dependencies]
ink_abi = { path = "../../abi/" }
ink_core = { path = "../../core/" } ink_core = { path = "../../core/" }
ink_lang2 = { path = ".." } ink_lang2 = { path = "..", default-features = false, features = ["ink-generate-abi"] }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"] }
trybuild = "1.0" trybuild = "1.0"
pretty_assertions = "0.6.1" pretty_assertions = "0.6.1"
......
...@@ -386,16 +386,15 @@ impl TryFrom<syn::ImplItemMethod> for ir::Function { ...@@ -386,16 +386,15 @@ impl TryFrom<syn::ImplItemMethod> for ir::Function {
selector: ir::FunctionSelector::from(&method.sig.ident), selector: ir::FunctionSelector::from(&method.sig.ident),
})) }))
} }
_unknown => Err(format_err_span!(attr.span(), "unknown ink! marker",)), _unknown => {
Err(format_err_span!(attr.span(), "unknown ink! marker",))
}
}?; }?;
if kind == ir::FunctionKind::Method { if kind == ir::FunctionKind::Method {
kind = new_kind; kind = new_kind;
Ok(()) Ok(())
} else { } else {
Err(format_err_span!( Err(format_err_span!(attr.span(), "conflicting ink! marker",))
attr.span(),
"conflicting ink! marker",
))
} }
}) })
.filter_map(Result::err) .filter_map(Result::err)
...@@ -597,27 +596,29 @@ impl TryFrom<syn::Item> for ir::Item { ...@@ -597,27 +596,29 @@ impl TryFrom<syn::Item> for ir::Item {
} }
let event_marker = let event_marker =
markers.iter().position(|marker| marker.is_simple("event")); markers.iter().position(|marker| marker.is_simple("event"));
let storage_marker = let storage_marker = markers
markers.iter().position(|marker| marker.is_simple("storage")); .iter()
.position(|marker| marker.is_simple("storage"));
match (storage_marker, event_marker) { match (storage_marker, event_marker) {
(Some(_storage_marker), None) => { (Some(_storage_marker), None) => {
ir::ItemStorage::try_from(item_struct) ir::ItemStorage::try_from(item_struct)
.map(Into::into) .map(Into::into)
.map(ir::Item::Ink) .map(ir::Item::Ink)
}, }
(None, Some(_event_marker)) => { (None, Some(_event_marker)) => {
ir::ItemEvent::try_from(item_struct) ir::ItemEvent::try_from(item_struct)
.map(Into::into) .map(Into::into)
.map(ir::Item::Ink) .map(ir::Item::Ink)
}, }
(None, None) => { (None, None) => {
Err(markers Err(markers
.iter() .iter()
.map(|marker| { .map(|marker| {
format_err_span!( format_err_span!(
marker.span(), marker.span(),
"unsupported ink! marker for struct") "unsupported ink! marker for struct"
)
}) })
.fold( .fold(
format_err!( format_err!(
...@@ -625,10 +626,10 @@ impl TryFrom<syn::Item> for ir::Item { ...@@ -625,10 +626,10 @@ impl TryFrom<syn::Item> for ir::Item {
"encountered unsupported ink! markers for struct", "encountered unsupported ink! markers for struct",
), ),
|mut err1, err2| { |mut err1, err2| {
err1.combine(err2); err1.combine(err2);
err1 err1
}) },
) ))
} }
(Some(storage_marker), Some(event_marker)) => { (Some(storage_marker), Some(event_marker)) => {
// Special case: We have both #[ink(storage)] and #[ink(event)]. // Special case: We have both #[ink(storage)] and #[ink(event)].
...@@ -685,17 +686,18 @@ fn split_items( ...@@ -685,17 +686,18 @@ fn split_items(
n => { n => {
Err(storages Err(storages
.iter() .iter()
.map(|storage| { .map(|storage| format_err!(storage.ident, "conflicting storage struct"))
format_err!(storage.ident, "conflicting storage struct")
})
.fold( .fold(
format_err_span!(Span::call_site(), "encountered {} conflicting storage structs", n), format_err_span!(
Span::call_site(),
"encountered {} conflicting storage structs",
n
),
|mut err1, err2| { |mut err1, err2| {
err1.combine(err2); err1.combine(err2);
err1 err1
} },
) ))
)
} }
}?; }?;
let (events, impl_blocks): (Vec<ir::ItemEvent>, Vec<ir::ItemImpl>) = let (events, impl_blocks): (Vec<ir::ItemEvent>, Vec<ir::ItemImpl>) =
...@@ -712,7 +714,7 @@ fn split_items( ...@@ -712,7 +714,7 @@ fn split_items(
}); });
let storage_ident = &storage.ident; let storage_ident = &storage.ident;
for item_impl in &impl_blocks { for item_impl in &impl_blocks {
if item_impl.self_ty != storage_ident.to_string() { if &item_impl.self_ty != storage_ident {
bail!( bail!(
item_impl.self_ty, item_impl.self_ty,
"ink! impl blocks need to be implemented for the #[ink(storage)] struct" "ink! impl blocks need to be implemented for the #[ink(storage)] struct"
......
...@@ -219,7 +219,7 @@ where ...@@ -219,7 +219,7 @@ where
} }
DispatchMode::Call => self.messages.dispatch(&mut self.storage, &call_data), DispatchMode::Call => self.messages.dispatch(&mut self.storage, &call_data),
}; };
ret.into() ret
} }
} }
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
trivial_numeric_casts, trivial_numeric_casts,
unused_extern_crates, unused_extern_crates,
unused_qualifications, unused_qualifications,
unused_results, unused_results
)] )]
#[macro_use] #[macro_use]
......
...@@ -17,11 +17,21 @@ ...@@ -17,11 +17,21 @@
declare -A results declare -A results
cargo check --verbose --all --all-features all_crates=("core" "alloc" "utils" "model" "lang" "lang2" "lang2/macro" "cli")
results["check_all_features"]=$? wasm_crates=("core" "alloc" "utils" "model" "lang" "lang2" "lang2/macro")
cargo check --verbose --all --no-default-features results["check_all_features"]=true
results["check_no_defaults"]=$? for crate in "${all_crates[@]}"; do
cargo check --verbose --all-features --manifest-path $crate/Cargo.toml
let "results['check_all_features'] |= $?"
cargo check --verbose --no-default-features --manifest-path $crate/Cargo.toml
let "results['check_no_defaults'] |= $?"
done
for crate in "${wasm_crates[@]}"; do
cargo build --verbose --manifest-path $crate/Cargo.toml --no-default-features --release --target=wasm32-unknown-unknown
let "results['build_wasm'] |= $?"
done
cargo fmt --verbose --all -- --check cargo fmt --verbose --all -- --check
results["fmt"]=$? results["fmt"]=$?
...@@ -32,12 +42,9 @@ results["clippy_all_features"]=$? ...@@ -32,12 +42,9 @@ results["clippy_all_features"]=$?
cargo clippy --verbose --all --no-default-features -- -D warnings cargo clippy --verbose --all --no-default-features -- -D warnings
results["clippy_no_defaults"]=$? results["clippy_no_defaults"]=$?
cargo test --verbose --all --all-features cargo test --verbose --all --all-features --release
results["test_all_features"]=$? results["test_all_features"]=$?
cargo build --verbose --all --no-default-features --release --target=wasm32-unknown-unknown
results["build_wasm"]=$?
all_checks_passed=0 all_checks_passed=0
banner="-----------------" banner="-----------------"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment