Commit ef960aae authored by Hero Bird's avatar Hero Bird Committed by GitHub

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:
CARGO_INCREMENTAL: 0
CI_SERVER_NAME: "GitLab CI"
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
artifacts:
......@@ -32,6 +34,7 @@ variables:
- rustc -vV
- rustup show
- 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
- printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config
- sccache -s
......@@ -52,73 +55,121 @@ variables:
#### stage: check-workspace
cargo-check-af:
check-std:
stage: check-workspace
<<: *docker-env
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
<<: *docker-env
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
<<: *docker-env
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
<<: *docker-env
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
<<: *docker-env
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
<<: *docker-env
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
<<: *docker-env
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
examples-wasm:
examples-test:
stage: examples
<<: *docker-env
script:
- for example in $(ls examples/lang); do
cargo build --release --no-default-features --target=wasm32-unknown-unknown --verbose --manifest-path examples/lang/$example/Cargo.toml;
- for DIR in examples/lang2/*; do
cargo test --verbose --manifest-path ${DIR}/Cargo.toml;
done
- sccache -s
examples-test:
examples-fmt:
stage: examples
<<: *docker-env
script:
- for example in $(ls examples/lang); do
cargo test --verbose --manifest-path examples/lang/$example/Cargo.toml;
- for example in examples/lang2/*; do
cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
done
- sccache -s
examples-abi:
examples-clippy-std:
stage: examples
<<: *docker-env
script:
- for example in $(ls examples/lang); do
cargo run --package abi-gen --manifest-path examples/lang/$example/Cargo.toml;
- for example in examples/lang2/*; do
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
- sccache -s
......@@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
use crate::cmd::{
Result,
};
use crate::cmd::Result;
use cargo_metadata::MetadataCommand;
use std::path::PathBuf;
......@@ -26,13 +24,17 @@ use std::path::PathBuf;
pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
println!(" Generating abi");
super::exec_cargo("run", &[
"--package",
"abi-gen",
"--release",
"--no-default-features",
"--verbose",
], dir)?;
super::exec_cargo(
"run",
&[
"--package",
"abi-gen",
"--release",
// "--no-default-features", // Breaks builds for MacOS (linker errors), we should investigate this issue asap!
"--verbose",
],
dir,
)?;
let metadata = MetadataCommand::new().exec()?;
let mut abi_path = metadata.target_directory.clone();
......@@ -48,8 +50,8 @@ pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
mod tests {
use crate::{
cmd::{
execute_new,
execute_generate_abi,
execute_new,
tests::with_tmp_dir,
},
AbstractionLayer,
......
......@@ -89,12 +89,16 @@ pub fn collect_crate_metadata(working_dir: Option<&PathBuf>) -> Result<CrateMeta
///
/// Currently it assumes that user wants to use `+nightly`.
fn build_cargo_project(working_dir: Option<&PathBuf>) -> Result<()> {
super::exec_cargo("build", &[
"--no-default-features",
"--release",
"--target=wasm32-unknown-unknown",
"--verbose",
], working_dir)
super::exec_cargo(
"build",
&[
"--no-default-features",
"--release",
"--target=wasm32-unknown-unknown",
"--verbose",
],
working_dir,
)
}
/// Ensures the wasm memory import of a given module has the maximum number of pages.
......
......@@ -40,7 +40,11 @@ pub(crate) use self::{
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 is_nightly_cmd = Command::new("cargo");
if let Some(dir) = working_dir {
......@@ -60,10 +64,7 @@ fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf
cmd.arg("+nightly");
}
let output = cmd
.arg(command)
.args(args)
.output()?;
let output = cmd.arg(command).args(args).output()?;
if !output.status.success() {
// 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"
regex = "1.3"
[dev-dependencies]
ink_abi = { path = "../../abi/" }
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"
pretty_assertions = "0.6.1"
......
......@@ -386,16 +386,15 @@ impl TryFrom<syn::ImplItemMethod> for ir::Function {
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 {
kind = new_kind;
Ok(())
} else {
Err(format_err_span!(
attr.span(),
"conflicting ink! marker",
))
Err(format_err_span!(attr.span(), "conflicting ink! marker",))
}
})
.filter_map(Result::err)
......@@ -597,27 +596,29 @@ impl TryFrom<syn::Item> for ir::Item {
}
let event_marker =
markers.iter().position(|marker| marker.is_simple("event"));
let storage_marker =
markers.iter().position(|marker| marker.is_simple("storage"));
let storage_marker = markers
.iter()
.position(|marker| marker.is_simple("storage"));
match (storage_marker, event_marker) {
(Some(_storage_marker), None) => {
ir::ItemStorage::try_from(item_struct)
.map(Into::into)
.map(ir::Item::Ink)
},
}
(None, Some(_event_marker)) => {
ir::ItemEvent::try_from(item_struct)
.map(Into::into)
.map(ir::Item::Ink)
},
}
(None, None) => {
Err(markers
.iter()
.map(|marker| {
format_err_span!(
marker.span(),
"unsupported ink! marker for struct")
"unsupported ink! marker for struct"
)
})
.fold(
format_err!(
......@@ -625,10 +626,10 @@ impl TryFrom<syn::Item> for ir::Item {
"encountered unsupported ink! markers for struct",
),
|mut err1, err2| {
err1.combine(err2);
err1
})
)
err1.combine(err2);
err1
},
))
}
(Some(storage_marker), Some(event_marker)) => {
// Special case: We have both #[ink(storage)] and #[ink(event)].
......@@ -685,17 +686,18 @@ fn split_items(
n => {
Err(storages
.iter()
.map(|storage| {
format_err!(storage.ident, "conflicting storage struct")
})
.map(|storage| format_err!(storage.ident, "conflicting storage struct"))
.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| {
err1.combine(err2);
err1
}
)
)
},
))
}
}?;
let (events, impl_blocks): (Vec<ir::ItemEvent>, Vec<ir::ItemImpl>) =
......@@ -712,7 +714,7 @@ fn split_items(
});
let storage_ident = &storage.ident;
for item_impl in &impl_blocks {
if item_impl.self_ty != storage_ident.to_string() {
if &item_impl.self_ty != storage_ident {
bail!(
item_impl.self_ty,
"ink! impl blocks need to be implemented for the #[ink(storage)] struct"
......
......@@ -219,7 +219,7 @@ where
}
DispatchMode::Call => self.messages.dispatch(&mut self.storage, &call_data),
};
ret.into()
ret
}
}
......
......@@ -40,7 +40,7 @@
trivial_numeric_casts,
unused_extern_crates,
unused_qualifications,
unused_results,
unused_results
)]
#[macro_use]
......
......@@ -17,11 +17,21 @@
declare -A results
cargo check --verbose --all --all-features
results["check_all_features"]=$?
all_crates=("core" "alloc" "utils" "model" "lang" "lang2" "lang2/macro" "cli")
wasm_crates=("core" "alloc" "utils" "model" "lang" "lang2" "lang2/macro")
cargo check --verbose --all --no-default-features
results["check_no_defaults"]=$?
results["check_all_features"]=true
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
results["fmt"]=$?
......@@ -32,12 +42,9 @@ results["clippy_all_features"]=$?
cargo clippy --verbose --all --no-default-features -- -D warnings
results["clippy_no_defaults"]=$?
cargo test --verbose --all --all-features
cargo test --verbose --all --all-features --release
results["test_all_features"]=$?
cargo build --verbose --all --no-default-features --release --target=wasm32-unknown-unknown
results["build_wasm"]=$?
all_checks_passed=0
banner="-----------------"
......
Markdown is supported
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