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

Fix gloo-worker tests #244

Merged
merged 5 commits into from
Aug 18, 2022
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
45 changes: 42 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,51 @@ jobs:
wasm-pack test --headless --firefox --chrome crates/$x --no-default-features
done

- name: Run tests for gloo worker


test-worker:
name: Test gloo-worker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
profile: minimal

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Setup trunk
uses: jetli/trunk-action@v0.1.0
with:
version: 'latest'

- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-browser-tests-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
cargo-${{ runner.os }}-test-worker-
cargo-${{ runner.os }}-

- name: Build and Run Test Server
run: |
cargo build -p example-markdown --bin example_markdown_test_server
nohup target/debug/example_markdown_test_server examples/markdown/dist &

- name: Build Test Worker
run: |
trunk build examples/markdown/index.html
nohup cargo run -p example-markdown --bin example_markdown_test_server -- examples/markdown/dist &

wasm-pack test --headless --firefox --chrome examples/markdown
- name: Run tests for gloo worker
run: |
wasm-pack test --headless --firefox --chrome examples/markdown


test-net:
Expand Down
21 changes: 13 additions & 8 deletions examples/markdown/src/bin/example_markdown_test_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(not(target_arch = "wasm32"))]

use warp::reply::with_header;
use warp::Filter;

// This server is purely to faclitate testing.
Expand All @@ -10,14 +11,18 @@ use warp::Filter;
async fn main() {
let dir = std::env::args().nth(1).expect("expected a target dir.");

let route = warp::fs::dir(dir).with(
// We need a server that serves the request with cross origin resource sharing.
warp::cors()
.allow_method("GET")
.allow_method("HEAD")
.allow_method("OPTIONS")
.allow_any_origin(),
);
let route = warp::fs::dir(dir)
.with(
// We need a server that serves the request with cross origin resource sharing.
warp::cors()
.allow_method("GET")
.allow_method("HEAD")
.allow_method("OPTIONS")
.allow_any_origin(),
)
.map(|m| with_header(m, "cross-origin-resource-policy", "cross-origin"));

println!("Test server is running at: http://127.0.0.1:9999/");

warp::serve(route).run(([127, 0, 0, 1], 9999)).await;
}