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

Integration test #52

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- run: brew install pulumi
if: runner.os == 'macOS'
- run: pulumi version
- run: pulumi login --local

- name: Build language plugin (Windows)
if: runner.os == 'Windows'
Expand All @@ -52,12 +53,13 @@ jobs:
- name: Install wasm-tools
run: cargo install wasm-tools@1.201.0 --locked || wasm-tools --version

- name: Build WASM support (Windows)
if: runner.os == 'Windows'
run: ./build.bat
- name: Build WASM support (Unix)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: ./build.sh
- name: Install wasm32-wasi support
run: rustup target add wasm32-wasi

- name: Build WASM component
run: cargo component build -p pulumi_wasm -p pulumi_wasm_provider_random -p pulumi_wasm_example_simple
- name: Build libraries
run: cargo build -p pulumi_wasm_runner -p pulumi_wasm_rust -p pulumi_wasm_rust_macro -p pulumi_wasm_provider_random_rust

- name: Run tests
run: cargo test --all --verbose
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

32 changes: 0 additions & 32 deletions build.bat

This file was deleted.

23 changes: 0 additions & 23 deletions build.sh

This file was deleted.

28 changes: 0 additions & 28 deletions config.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions entrypoint.bat

This file was deleted.

7 changes: 0 additions & 7 deletions entrypoint.sh

This file was deleted.

4 changes: 2 additions & 2 deletions examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ wasm_common.workspace = true
pulumi_wasm_provider_random_rust.workspace = true

[dev-dependencies]
wasmtime.workspace = true
wasmtime-wasi.workspace = true
assert_cmd.workspace = true
predicates.workspace = true
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions examples/simple/entrypoint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cargo run -p cargo-pulumi
if(!$?) { Exit $LASTEXITCODE }

cargo run -p pulumi_wasm_runner -- run --wasm ../../target/wasm32-wasi/debug/composed.wasm
if(!$?) { Exit $LASTEXITCODE }
1 change: 1 addition & 0 deletions examples/simple/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cargo run -p cargo-pulumi && cargo run -p pulumi_wasm_runner -- run --wasm ../../target/wasm32-wasi/debug/composed.wasm
46 changes: 46 additions & 0 deletions examples/simple/tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use std::process::Command;
use assert_cmd::prelude::*;
use std::str;
use anyhow::anyhow;
use serde_json::{json, Value};

#[test]
fn test_integration() -> Result<(), anyhow::Error> {

Command::new("pulumi")
.args(["stack", "init", "test"])
.env("PULUMI_CONFIG_PASSPHRASE", " ")
.current_dir(".")
.output()?;

Command::new("pulumi")
.args(["stack", "select", "test"])
.current_dir(".")
.assert()
.success();

Command::new("pulumi")
.args(["up", "-y"])
.current_dir(".")
.env("PULUMI_CONFIG_PASSPHRASE", " ")
.assert()
.success();

let binding = Command::new("pulumi")
.args(["stack", "export"])
.current_dir(".")
.env("PULUMI_CONFIG_PASSPHRASE", " ")
.assert()
.success();
let stack = &binding
.get_output()
.stdout;

let stack: Value = serde_json::from_str(str::from_utf8(stack)?)?;

let length = stack.pointer("/deployment/resources/1/inputs/length").ok_or(anyhow!("Cannot find length in stack export"))?;

assert_eq!(length, &json!(36));

Ok(())
}
12 changes: 6 additions & 6 deletions pulumi-language-wasm/executors/executor_windows_os.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (s windows) NewWasmExecutor(opts WasmExecutorOptions) (*WasmExecutor, error
}
probePaths := []string{opts.UseExecutor}
if opts.UseExecutor == "" {
probePaths = []string{".\\entrypoint.bat"}
probePaths = []string{".\\entrypoint.ps1"}
}
cmd, err := fsys.LookPath(opts.WD, probePaths...)
if err != nil {
Expand All @@ -29,10 +29,10 @@ func (s windows) NewWasmExecutor(opts WasmExecutorOptions) (*WasmExecutor, error
func (windows) newWasmCliExecutor(script string) (*WasmExecutor, error) {
return &WasmExecutor{
Name: script,
Cmd: "cmd",
BuildArgs: []string{"/c", script, "build"},
RunArgs: []string{"/c", script, "run"},
PluginArgs: []string{"/c", script, "plugin"},
VersionArgs: []string{"/c", script, "version"},
Cmd: "powershell",
BuildArgs: []string{"-executionpolicy", "bypass", "-File", script, "build"},
RunArgs: []string{"-executionpolicy", "bypass", "-File", script, "run"},
PluginArgs: []string{"-File", script, "plugin"},
VersionArgs: []string{"-File", script, "version"},
}, nil
}
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These scripts must be run from root, not from `scripts` directory.
File renamed without changes.
0 docs.sh → scripts/docs.sh
100755 → 100644
File renamed without changes.