Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for Windows #261

Merged
merged 7 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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:
- name: Install sudo for windows #https://github.com/actions/virtual-environments/issues/572
run: choco install sudo

- name: Set cache_hash ENV and prepare cache dir
run: |
echo "cache_hash=${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ matrix.compiler }}-${{ hashFiles('**/Cargo.toml') }}" >> "$GITHUB_ENV"
sudo chmod -R a+w $HOME/.cargo
shell: bash

- name: Cache cargo registry
cmichi marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/cache@master
with:
path: $HOME/.cargo/registry
key: cargo-registry-${{ env['cache_hash'] }}

- name: Cache cargo index
uses: actions/cache@master
with:
path: $HOME/.cargo/git
key: cargo-git-${{ env['cache_hash'] }}

- name: Cache cargo build
uses: actions/cache@master
with:
path: target
key: cargo-target-${{ env['cache_hash'] }}

- uses: engineerd/[email protected]
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: 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

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)

Expand Down
22 changes: 0 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ serde = { version = "1.0.125", default-features = false, features = ["derive"] }
serde_json = "1.0.64"
tempfile = "3.2.0"
url = { version = "2.2.1", features = ["serde"] }
binaryen = { version = "0.12.0", optional = true }
impl-serde = "0.3.1"
regex = "1.4"

Expand Down
10 changes: 9 additions & 1 deletion src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand All @@ -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");
{
Expand Down Expand Up @@ -829,6 +833,7 @@ mod tests_ci_only {
})
}

#[cfg(unix)]
#[test]
fn incompatible_wasm_opt_version_must_be_detected_if_built_from_repo() {
with_tmp_dir(|path| {
Expand All @@ -849,6 +854,7 @@ mod tests_ci_only {
})
}

#[cfg(unix)]
#[test]
fn compatible_wasm_opt_version_must_be_detected_if_built_from_repo() {
with_tmp_dir(|path| {
Expand All @@ -865,6 +871,7 @@ mod tests_ci_only {
})
}

#[cfg(unix)]
#[test]
fn incompatible_wasm_opt_version_must_be_detected_if_installed_as_package() {
with_tmp_dir(|path| {
Expand All @@ -885,6 +892,7 @@ mod tests_ci_only {
})
}

#[cfg(unix)]
#[test]
fn compatible_wasm_opt_version_must_be_detected_if_installed_as_package() {
with_tmp_dir(|path| {
Expand Down
2 changes: 2 additions & 0 deletions src/workspace/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 12 additions & 2 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down