From 9b048fb9ae2df48d03bc0ad5da530f279c786ba1 Mon Sep 17 00:00:00 2001 From: Tyler Cloutier Date: Mon, 19 Jun 2023 22:38:26 -0700 Subject: [PATCH] test (#1) * test * Fixed CI * Fixed tests * Fixed formatting * Fixed test error by removing chrono default features * Rename smoketests CI thing * Hopefully fix the testing issue * Fix typos * Fixed install git-hooks * Fixed formatting * Fixed compile error * fixed testing issues --- .github/workflows/ci.yml | 3 ++- Cargo.toml | 2 +- crates/lib/Cargo.toml | 2 +- crates/standalone/src/lib.rs | 6 ++++-- crates/testing/src/lib.rs | 5 +++-- crates/testing/src/modules.rs | 21 ++++++++++++++----- .../tests/standalone_integration_test.rs | 4 ++-- docker-compose-release.yml | 1 - docker-compose.yml | 1 - .../hooks/applypatch-msg.sample | 0 {hooks => git-hooks}/hooks/commit-msg.sample | 0 .../hooks/fsmonitor-watchman.sample | 0 {hooks => git-hooks}/hooks/post-update.sample | 0 .../hooks/pre-applypatch.sample | 0 {hooks => git-hooks}/hooks/pre-commit | 0 {hooks => git-hooks}/hooks/pre-commit.sample | 0 .../hooks/pre-merge-commit.sample | 0 {hooks => git-hooks}/hooks/pre-push.sample | 0 {hooks => git-hooks}/hooks/pre-rebase.sample | 0 {hooks => git-hooks}/hooks/pre-receive.sample | 0 .../hooks/prepare-commit-msg.sample | 0 .../hooks/push-to-checkout.sample | 0 {hooks => git-hooks}/hooks/update.sample | 0 {hooks => git-hooks}/install-hooks.sh | 2 +- .../.gitignore | 0 .../Cargo.toml | 0 .../src/lib.rs | 0 x | 0 28 files changed, 30 insertions(+), 17 deletions(-) rename {hooks => git-hooks}/hooks/applypatch-msg.sample (100%) rename {hooks => git-hooks}/hooks/commit-msg.sample (100%) rename {hooks => git-hooks}/hooks/fsmonitor-watchman.sample (100%) rename {hooks => git-hooks}/hooks/post-update.sample (100%) rename {hooks => git-hooks}/hooks/pre-applypatch.sample (100%) rename {hooks => git-hooks}/hooks/pre-commit (100%) rename {hooks => git-hooks}/hooks/pre-commit.sample (100%) rename {hooks => git-hooks}/hooks/pre-merge-commit.sample (100%) rename {hooks => git-hooks}/hooks/pre-push.sample (100%) rename {hooks => git-hooks}/hooks/pre-rebase.sample (100%) rename {hooks => git-hooks}/hooks/pre-receive.sample (100%) rename {hooks => git-hooks}/hooks/prepare-commit-msg.sample (100%) rename {hooks => git-hooks}/hooks/push-to-checkout.sample (100%) rename {hooks => git-hooks}/hooks/update.sample (100%) rename {hooks => git-hooks}/install-hooks.sh (77%) rename modules/{spacetimedb_quickstart => spacetimedb-quickstart}/.gitignore (100%) rename modules/{spacetimedb_quickstart => spacetimedb-quickstart}/Cargo.toml (100%) rename modules/{spacetimedb_quickstart => spacetimedb-quickstart}/src/lib.rs (100%) delete mode 100644 x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da8dcdc81b1..ef4e063e7eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ name: CI jobs: docker_smoketests: + name: Smoketests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -63,7 +64,7 @@ jobs: - run: echo ::add-matcher::.github/workflows/rust_matcher.json - name: Build rust-wasm-test - run: cargo run -p spacetimedb-cli -- build crates/modules/rust-wasm-test + run: cargo run -p spacetimedb-cli -- build modules/rust-wasm-test - name: Run bindgen tests run: cargo test -p spacetimedb-cli diff --git a/Cargo.toml b/Cargo.toml index 682a99545ed..15f950300de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ members = [ "crates/sqltest", "modules/rust-wasm-test", "modules/benchmarks", - "modules/spacetimedb_quickstart", + "modules/spacetimedb-quickstart", ] default-members = ["crates/cli"] diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 97c2e0c2793..b4bd70f2231 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -28,7 +28,7 @@ anyhow = "1.0.68" spacetimedb-bindings-macro = { path = "../bindings-macro", version = "0.4.1" } spacetimedb-sats = { path = "../sats", version = "0.4.1" } serde_with = { version = "2.2.0", optional = true } -chrono = { version = "0.4.23", optional = true } +chrono = { version = "0.4.23", optional = true, default-features = false } [dev-dependencies] rand = "0.8.5" diff --git a/crates/standalone/src/lib.rs b/crates/standalone/src/lib.rs index a25b0aeda43..f603627852c 100644 --- a/crates/standalone/src/lib.rs +++ b/crates/standalone/src/lib.rs @@ -71,8 +71,10 @@ impl StandaloneEnv { } fn get_or_create_keys() -> anyhow::Result<(DecodingKey, EncodingKey)> { - let public_key_path = get_key_path("SPACETIMEDB_JWT_PUB_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa.pub")); - let private_key_path = get_key_path("SPACETIMEDB_JWT_PRIV_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa")); + let public_key_path = + get_key_path("SPACETIMEDB_JWT_PUB_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa.pub")); + let private_key_path = + get_key_path("SPACETIMEDB_JWT_PRIV_KEY").unwrap_or(PathBuf::from("/etc/spacetimedb/id_ecdsa")); let mut public_key_bytes = read_key(&public_key_path).ok(); let mut private_key_bytes = read_key(&private_key_path).ok(); diff --git a/crates/testing/src/lib.rs b/crates/testing/src/lib.rs index 56021cd4b45..c59b1f2b0c7 100644 --- a/crates/testing/src/lib.rs +++ b/crates/testing/src/lib.rs @@ -1,3 +1,4 @@ +use spacetimedb::stdb_path; use std::env; use std::path::Path; @@ -9,6 +10,6 @@ pub fn set_key_env_vars() { env::set_var(var, Path::new(env!("CARGO_MANIFEST_DIR")).join("../..").join(path)); } }; - set_if_not_exist("SPACETIMEDB_JWT_PUB_KEY", "id_ecdsa.pub"); - set_if_not_exist("SPACETIMEDB_JWT_PRIV_KEY", "id_ecdsa"); + set_if_not_exist("SPACETIMEDB_JWT_PUB_KEY", stdb_path("id_ecdsa.pub")); + set_if_not_exist("SPACETIMEDB_JWT_PRIV_KEY", stdb_path("id_ecdsa")); } diff --git a/crates/testing/src/modules.rs b/crates/testing/src/modules.rs index 73827ae124c..6fc71f88118 100644 --- a/crates/testing/src/modules.rs +++ b/crates/testing/src/modules.rs @@ -49,16 +49,21 @@ where func(runtime, &module); }); } -fn module_path(path: &str) -> PathBuf { + +fn module_path(name: &str) -> PathBuf { let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); - root.join("../modules").join(path) + root.join("../../modules").join(name) } -fn wasm_path(path: &str) -> PathBuf { - module_path(path).join("target/wasm32-unknown-unknown/release/spacetime_module.wasm") +fn wasm_path(name: &str) -> PathBuf { + module_path(name).join(format!( + "target/wasm32-unknown-unknown/release/{}_module.wasm", + name.replace('-', "_") + )) } fn read_module(path: &str) -> Vec { + println!("{}", wasm_path(path).to_str().unwrap()); std::fs::read(wasm_path(path)).unwrap() } @@ -66,7 +71,13 @@ pub fn compile(path: &str) { let path = module_path(path); let output = Command::new("cargo") .current_dir(&path) - .args(["build", "--target=wasm32-unknown-unknown", "--release"]) + .args([ + "build", + "--target=wasm32-unknown-unknown", + "--release", + "--target-dir", + path.join("target").to_str().unwrap(), + ]) .output() .expect("Failed to execute process to compile a test depdendency"); diff --git a/crates/testing/tests/standalone_integration_test.rs b/crates/testing/tests/standalone_integration_test.rs index 28fd7b53d1c..2eacbcb7cd0 100644 --- a/crates/testing/tests/standalone_integration_test.rs +++ b/crates/testing/tests/standalone_integration_test.rs @@ -3,8 +3,8 @@ use spacetimedb_testing::modules::{compile, with_module_async}; #[test] fn test_calling_a_reducer() { - compile("spacetimedb_quickstart"); - with_module_async("spacetimedb_quickstart", |module| async move { + compile("spacetimedb-quickstart"); + with_module_async("spacetimedb-quickstart", |module| async move { let json = r#"{"call": {"fn": "add", "args": ["Tyrion"]}}"#.to_string(); module.send(json).await.unwrap(); let json = r#"{"call": {"fn": "say_hello", "args": []}}"#.to_string(); diff --git a/docker-compose-release.yml b/docker-compose-release.yml index 738c8f4757f..e987af8709e 100644 --- a/docker-compose-release.yml +++ b/docker-compose-release.yml @@ -14,7 +14,6 @@ services: - ./crates/bindings:/usr/src/app/crates/bindings - ./crates/bindings-macro:/usr/src/app/crates/bindings-macro - ./crates/bindings-sys:/usr/src/app/crates/bindings-sys - - ./crates/modules/rust-wasm-test:/usr/src/app/crates/modules/rust-wasm-test - ./crates/vm:/usr/src/app/crates/vm - /stdb ports: diff --git a/docker-compose.yml b/docker-compose.yml index 05546048f9b..bbff328e744 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,6 @@ services: - ./crates/bindings:/usr/src/app/crates/bindings - ./crates/bindings-macro:/usr/src/app/crates/bindings-macro - ./crates/bindings-sys:/usr/src/app/crates/bindings-sys - - ./crates/modules/rust-wasm-test:/usr/src/app/crates/modules/rust-wasm-test - ./crates/vm:/usr/src/app/crates/vm - ./crates/client-api-messages:/usr/src/app/crates/client-api-messages - ./flamegraphs:/usr/src/app/flamegraphs diff --git a/hooks/hooks/applypatch-msg.sample b/git-hooks/hooks/applypatch-msg.sample similarity index 100% rename from hooks/hooks/applypatch-msg.sample rename to git-hooks/hooks/applypatch-msg.sample diff --git a/hooks/hooks/commit-msg.sample b/git-hooks/hooks/commit-msg.sample similarity index 100% rename from hooks/hooks/commit-msg.sample rename to git-hooks/hooks/commit-msg.sample diff --git a/hooks/hooks/fsmonitor-watchman.sample b/git-hooks/hooks/fsmonitor-watchman.sample similarity index 100% rename from hooks/hooks/fsmonitor-watchman.sample rename to git-hooks/hooks/fsmonitor-watchman.sample diff --git a/hooks/hooks/post-update.sample b/git-hooks/hooks/post-update.sample similarity index 100% rename from hooks/hooks/post-update.sample rename to git-hooks/hooks/post-update.sample diff --git a/hooks/hooks/pre-applypatch.sample b/git-hooks/hooks/pre-applypatch.sample similarity index 100% rename from hooks/hooks/pre-applypatch.sample rename to git-hooks/hooks/pre-applypatch.sample diff --git a/hooks/hooks/pre-commit b/git-hooks/hooks/pre-commit similarity index 100% rename from hooks/hooks/pre-commit rename to git-hooks/hooks/pre-commit diff --git a/hooks/hooks/pre-commit.sample b/git-hooks/hooks/pre-commit.sample similarity index 100% rename from hooks/hooks/pre-commit.sample rename to git-hooks/hooks/pre-commit.sample diff --git a/hooks/hooks/pre-merge-commit.sample b/git-hooks/hooks/pre-merge-commit.sample similarity index 100% rename from hooks/hooks/pre-merge-commit.sample rename to git-hooks/hooks/pre-merge-commit.sample diff --git a/hooks/hooks/pre-push.sample b/git-hooks/hooks/pre-push.sample similarity index 100% rename from hooks/hooks/pre-push.sample rename to git-hooks/hooks/pre-push.sample diff --git a/hooks/hooks/pre-rebase.sample b/git-hooks/hooks/pre-rebase.sample similarity index 100% rename from hooks/hooks/pre-rebase.sample rename to git-hooks/hooks/pre-rebase.sample diff --git a/hooks/hooks/pre-receive.sample b/git-hooks/hooks/pre-receive.sample similarity index 100% rename from hooks/hooks/pre-receive.sample rename to git-hooks/hooks/pre-receive.sample diff --git a/hooks/hooks/prepare-commit-msg.sample b/git-hooks/hooks/prepare-commit-msg.sample similarity index 100% rename from hooks/hooks/prepare-commit-msg.sample rename to git-hooks/hooks/prepare-commit-msg.sample diff --git a/hooks/hooks/push-to-checkout.sample b/git-hooks/hooks/push-to-checkout.sample similarity index 100% rename from hooks/hooks/push-to-checkout.sample rename to git-hooks/hooks/push-to-checkout.sample diff --git a/hooks/hooks/update.sample b/git-hooks/hooks/update.sample similarity index 100% rename from hooks/hooks/update.sample rename to git-hooks/hooks/update.sample diff --git a/hooks/install-hooks.sh b/git-hooks/install-hooks.sh similarity index 77% rename from hooks/install-hooks.sh rename to git-hooks/install-hooks.sh index eb2fb396fca..737c174d152 100755 --- a/hooks/install-hooks.sh +++ b/git-hooks/install-hooks.sh @@ -6,4 +6,4 @@ cd "$(dirname "$0")" rm -rf ../.git/hooks # Soft link the .git/hooks directory onto hooks/ -ln -s ../hooks/hooks ../.git/hooks +ln -s ../git-hooks/hooks ../.git/hooks diff --git a/modules/spacetimedb_quickstart/.gitignore b/modules/spacetimedb-quickstart/.gitignore similarity index 100% rename from modules/spacetimedb_quickstart/.gitignore rename to modules/spacetimedb-quickstart/.gitignore diff --git a/modules/spacetimedb_quickstart/Cargo.toml b/modules/spacetimedb-quickstart/Cargo.toml similarity index 100% rename from modules/spacetimedb_quickstart/Cargo.toml rename to modules/spacetimedb-quickstart/Cargo.toml diff --git a/modules/spacetimedb_quickstart/src/lib.rs b/modules/spacetimedb-quickstart/src/lib.rs similarity index 100% rename from modules/spacetimedb_quickstart/src/lib.rs rename to modules/spacetimedb-quickstart/src/lib.rs diff --git a/x b/x deleted file mode 100644 index e69de29bb2d..00000000000