Unverified Commit c40da7c1 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Improve error reporting during installation + Release `1.0.1` (#469)

* Improve error output during build script

* Bump version to `1.0.1`

* Update changelog

* Canonicalize `ink_dylint_driver_dir` directly

* Remove unneeded check for dir existence

* Apply `cargo fmt`
parent 82157f46
Pipeline #184337 failed with stages
in 8 minutes and 28 seconds
......@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `--skip-linting` flag that allows to skip the linting step during build process - [#468](https://github.com/paritytech/cargo-contract/pull/468)
## [1.0.1] - 2022-03-18
- Improved error reporting during installation - [#468](https://github.com/paritytech/cargo-contract/pull/468)
## [1.0.0] - 2022-03-17
### Changed
......
......@@ -465,7 +465,7 @@ dependencies = [
[[package]]
name = "cargo-contract"
version = "1.0.0"
version = "1.0.1"
dependencies = [
"anyhow",
"assert_cmd",
......
......@@ -3,7 +3,7 @@ members = [".", "metadata"]
[package]
name = "cargo-contract"
version = "1.0.0"
version = "1.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2021"
......
......@@ -70,6 +70,14 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf)
let dylint_driver_dst_file = out_dir.join("ink-dylint-driver.zip");
let ink_dylint_driver_dir = manifest_dir.join("ink_linting");
let ink_dylint_driver_dir = ink_dylint_driver_dir.canonicalize().map_err(|err| {
anyhow::anyhow!(
"Unable to canonicalize '{:?}': {:?}\nDoes the folder exist? {}",
ink_dylint_driver_dir,
err,
ink_dylint_driver_dir.exists()
)
})?;
// The `ink_linting/Cargo.toml` file is named `_Cargo.toml` in the repository.
// This is because we need to have the `ink_linting` folder part of the release,
......@@ -85,24 +93,34 @@ fn zip_template_and_build_dylint_driver(manifest_dir: PathBuf, out_dir: PathBuf)
// > * Any sub-packages will be skipped (any subdirectory that contains a Cargo.toml file).
//
// (from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields)
std::fs::rename(
ink_dylint_driver_dir.join("_Cargo.toml"),
ink_dylint_driver_dir.join("Cargo.toml"),
)?;
let res = build_and_zip_dylint_driver(
ink_dylint_driver_dir.clone(),
out_dir,
dylint_driver_dst_file,
);
let original_name = ink_dylint_driver_dir.join("_Cargo.toml");
if !original_name.exists() {
anyhow::bail!("'{:?}' does not exist", original_name);
}
let tmp_name = ink_dylint_driver_dir.join("Cargo.toml");
std::fs::rename(&original_name, &tmp_name).map_err(|err| {
anyhow::anyhow!(
"Failed renaming '{:?}' to '{:?}': {:?}",
original_name,
tmp_name,
err
)
})?;
let res = build_and_zip_dylint_driver(ink_dylint_driver_dir, out_dir, dylint_driver_dst_file);
// After the build process of `ink_linting` happened we need to name back to the original
// `_Cargo.toml` name, otherwise the directory would be "dirty" and `cargo publish` would
// fail with `Source directory was modified by build.rs during cargo publish`.
std::fs::rename(
ink_dylint_driver_dir.join("Cargo.toml"),
ink_dylint_driver_dir.join("_Cargo.toml"),
)?;
std::fs::rename(&tmp_name, &original_name).map_err(|err| {
anyhow::anyhow!(
"Failed renaming '{:?}' to '{:?}': {:?}",
tmp_name,
original_name,
err
)
})?;
res
}
......
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