Unverified Commit 6774f341 authored by Michael Müller's avatar Michael Müller Committed by GitHub

Add CI for Windows (#261)

* Add CI for building contract template under Windows

* Disable `unix` specific tests

* Remove build warnings due to `dead_code` with default features

* Remove unused `binaryen` dependency

* Ensure path is always canonicalized for comparison

* Apply auto-formatting to yml

* CI: optimize caching
Co-authored-by: Denis_P's avatarDenis P <denis.pisarev@parity.io>
parent 7ecf8a36
Pipeline #135375 passed with stages
in 6 minutes and 44 seconds
name: continuous-intergration/windows
on:
pull_request:
push:
branches:
- master
tags:
- v*
paths-ignore:
- 'README.md'
jobs:
check:
name: build-contract-template
strategy:
matrix:
platform:
- windows-latest
toolchain:
- nightly
runs-on: ${{ matrix.platform }}
env:
RUST_BACKTRACE: full
steps:
- uses: engineerd/configurator@v0.0.6
with:
name: "wasm-opt.exe"
url: "https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-windows.tar.gz"
pathInArchive: "binaryen-version_101/bin/wasm-opt.exe"
- name: Checkout sources & submodules
uses: actions/checkout@master
with:
fetch-depth: 1
submodules: recursive
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
components: rust-src
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v1.2.0
- name: Build contract template on ${{ matrix.platform }}-${{ matrix.toolchain }}
run: |
wasm-opt --version
cargo -vV
cargo run -- contract --version
cargo run -- contract new foobar
echo "[workspace]" >> foobar/Cargo.toml
cargo run -- contract build --manifest-path=foobar/Cargo.toml
......@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fixed `ERROR: The workspace root package should be a workspace member` when building a contract
under Windows - [#261](https://github.com/paritytech/cargo-contract/pull/261)
### Removed
- Remove support for `--binaryen-as-dependency` - [#251](https://github.com/paritytech/cargo-contract/pull/251)
- Remove support for the deprecated `cargo contract generate-metadata` command - [#265](https://github.com/paritytech/cargo-contract/pull/265)
......
......@@ -596,9 +596,10 @@ mod tests_ci_only {
BuildArtifacts, ManifestPath, OptimizationPasses, UnstableFlags, UnstableOptions,
Verbosity, VerbosityFlags,
};
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
use std::{
io::Write,
os::unix::fs::PermissionsExt,
path::{Path, PathBuf},
};
......@@ -623,6 +624,9 @@ mod tests_ci_only {
/// "wasm-opt version `version`".
///
/// Returns the path to this file.
///
/// Currently works only on `unix`.
#[cfg(unix)]
fn mock_wasm_opt_version(tmp_dir: &Path, version: &str) -> PathBuf {
let path = tmp_dir.join("wasm-opt-mocked");
{
......@@ -820,6 +824,7 @@ mod tests_ci_only {
})
}
#[cfg(unix)]
#[test]
fn incompatible_wasm_opt_version_must_be_detected_if_built_from_repo() {
with_tmp_dir(|path| {
......@@ -840,6 +845,7 @@ mod tests_ci_only {
})
}
#[cfg(unix)]
#[test]
fn compatible_wasm_opt_version_must_be_detected_if_built_from_repo() {
with_tmp_dir(|path| {
......@@ -856,6 +862,7 @@ mod tests_ci_only {
})
}
#[cfg(unix)]
#[test]
fn incompatible_wasm_opt_version_must_be_detected_if_installed_as_package() {
with_tmp_dir(|path| {
......@@ -876,6 +883,7 @@ mod tests_ci_only {
})
}
#[cfg(unix)]
#[test]
fn compatible_wasm_opt_version_must_be_detected_if_installed_as_package() {
with_tmp_dir(|path| {
......
......@@ -177,6 +177,7 @@ impl Manifest {
}
/// Set `optimization-passes` in `[package.metadata.contract]`
#[cfg(feature = "test-ci-only")]
#[cfg(test)]
pub fn set_profile_optimization_passes(
&mut self,
......@@ -205,6 +206,7 @@ impl Manifest {
}
/// Set the dependency version of `package` to `version`.
#[cfg(feature = "test-ci-only")]
#[cfg(test)]
pub fn set_dependency_version(
&mut self,
......
......@@ -108,14 +108,24 @@ impl Workspace {
.members
.iter_mut()
.find_map(|(_, (_, manifest))| {
if manifest.path().directory() == Some(package_path) {
// `package_path` is always absolute and canonicalized. Thus we need to
// canonicalize the manifest's directory path as well in order to compare
// both of them.
let manifest_path = manifest.path().directory()?;
let manifest_path = manifest_path
.canonicalize()
.unwrap_or_else(|_| panic!("Cannot canonicalize {}", manifest_path.display()));
if manifest_path == package_path {
Some(manifest)
} else {
None
}
})
.ok_or_else(|| {
anyhow::anyhow!("The workspace root package should be a workspace member")
anyhow::anyhow!(
"Cannot find package with package path {} in workspace members",
package_path.display(),
)
})?;
f(manifest)?;
Ok(self)
......
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