Skip to content
Closed
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
11 changes: 11 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"bindings/js",
"bindings/java",
]
default-members = ["sysand", "core"]

[workspace.package]
version = "0.0.9"
Expand Down
178 changes: 178 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Sysand Local Testing Makefile

# Variables
WORKSPACE := $(shell pwd)
SYSAND := cargo run --manifest-path $(WORKSPACE)/Cargo.toml -p sysand --
TEST_ROOT := /tmp/sysand-test
TEST1_DIR := $(TEST_ROOT)/test1
TEST2_DIR := $(TEST_ROOT)/test2
TEST_USE_ROOT := /tmp/sysand-test-use
TEST_USE_DIR := $(TEST_USE_ROOT)/consumer
INDEX_URL := https://sysand-index-alpha.syside.app
INDEX_READ_URL := https://sysand-index-alpha.syside.app/index/

# Default target
.PHONY: help
help:
@echo "Sysand Testing Makefile"
@echo ""
@echo "Available targets:"
@echo " setup - Initialize test projects (test1 and test2)"
@echo " publish - Publish a project (requires auth, use PROJECT=test1 or test2)"
@echo " test-index-use - Test resolving dependencies from the index (public reads)"
@echo " info - Show project information"
@echo " clean - Remove all test directories"
@echo ""
@echo "Authentication (required for publishing):"
@echo " export SYSAND_CRED_ALPHA='$(INDEX_URL)/**'"
@echo " export SYSAND_CRED_ALPHA_BEARER_TOKEN='sysand_u_your_token_here'"
@echo ""
@echo "Typical workflow:"
@echo " 1. make setup # Create test projects"
@echo " 2. make publish PROJECT=test1 # Publish test1"
@echo " 3. make publish PROJECT=test2 # Publish test2"
@echo " 4. make test-index-use # Test fetching from index"

# Setup: Create test projects
.PHONY: setup
setup: clean
@echo "==> Setting up test projects in $(TEST_ROOT)"
@mkdir -p $(TEST_ROOT)

@echo ""
@echo "==> Creating test1 project..."
@mkdir -p $(TEST1_DIR)
@cd $(TEST1_DIR) && $(SYSAND) init \
--name test1 \
--version 0.1.0

@echo "package Test1Package {" > $(TEST1_DIR)/model.sysml
@echo " part def ExamplePart {" >> $(TEST1_DIR)/model.sysml
@echo " doc /* A simple example part from test1 */" >> $(TEST1_DIR)/model.sysml
@echo " }" >> $(TEST1_DIR)/model.sysml
@echo "}" >> $(TEST1_DIR)/model.sysml

@cd $(TEST1_DIR) && $(SYSAND) include model.sysml
@cd $(TEST1_DIR) && $(SYSAND) build
@echo "✓ test1 built successfully"

@echo ""
@echo "==> Creating test2 project..."
@mkdir -p $(TEST2_DIR)
@cd $(TEST2_DIR) && $(SYSAND) init \
--name test2 \
--version 0.1.0

@cd $(TEST2_DIR) && $(SYSAND) add "pkg:sysand/test1" "0.1.0" --no-lock --no-sync

@echo "package Test2Package {" > $(TEST2_DIR)/model.sysml
@echo " import Test1Package::*;" >> $(TEST2_DIR)/model.sysml
@echo " " >> $(TEST2_DIR)/model.sysml
@echo " part def MyPart {" >> $(TEST2_DIR)/model.sysml
@echo " part example : ExamplePart;" >> $(TEST2_DIR)/model.sysml
@echo " doc /* Uses ExamplePart from test1 */" >> $(TEST2_DIR)/model.sysml
@echo " }" >> $(TEST2_DIR)/model.sysml
@echo "}" >> $(TEST2_DIR)/model.sysml

@cd $(TEST2_DIR) && $(SYSAND) include model.sysml
@cd $(TEST2_DIR) && $(SYSAND) build
@echo "✓ test2 built successfully"

@echo ""
@echo "==> Setup complete!"
@echo " test1: $(TEST1_DIR)"
@echo " test2: $(TEST2_DIR)"
@echo ""
@echo "To publish, run:"
@echo " make publish PROJECT=test1"
@echo " make publish PROJECT=test2"

# Publish: Publish a project to the index
.PHONY: publish
publish:
@if [ -z "$(PROJECT)" ]; then \
echo "Error: PROJECT variable not set"; \
echo "Usage: make publish PROJECT=test1"; \
exit 1; \
fi
@if [ -z "$$SYSAND_CRED_ALPHA_BEARER_TOKEN" ]; then \
echo "Error: Authentication not configured"; \
echo ""; \
echo "Please set the following environment variables:"; \
echo " export SYSAND_CRED_ALPHA='$(INDEX_URL)/**'"; \
echo " export SYSAND_CRED_ALPHA_BEARER_TOKEN='sysand_u_your_token_here'"; \
echo ""; \
echo "Then run: make publish PROJECT=$(PROJECT)"; \
exit 1; \
fi
@if [ ! -d "$(TEST_ROOT)/$(PROJECT)" ]; then \
echo "Error: Project $(PROJECT) not found in $(TEST_ROOT)"; \
echo "Run 'make setup' first"; \
exit 1; \
fi
@echo "==> Publishing $(PROJECT) to $(INDEX_URL)..."
@cd $(TEST_ROOT)/$(PROJECT) && $(SYSAND) publish --default-index $(INDEX_URL)
@echo "✓ $(PROJECT) published successfully"

# Test index usage: Create a consumer project that depends on test2 from the index
.PHONY: test-index-use
test-index-use:
@echo "==> Setting up consumer project in $(TEST_USE_ROOT)"
@rm -rf $(TEST_USE_ROOT)
@mkdir -p $(TEST_USE_DIR)

@echo ""
@echo "==> Creating consumer project..."
@cd $(TEST_USE_DIR) && $(SYSAND) init --name consumer --version 0.1.0

@echo ""
@echo "==> Adding dependency on pkg:sysand/test2 from index..."
@cd $(TEST_USE_DIR) && $(SYSAND) add "pkg:sysand/test2" "^0.1.0" --default-index $(INDEX_READ_URL)

@echo ""
@echo "==> Creating model file that uses test2..."
@echo "package ConsumerPackage {" > $(TEST_USE_DIR)/consumer.sysml
@echo " import Test2Package::*;" >> $(TEST_USE_DIR)/consumer.sysml
@echo " " >> $(TEST_USE_DIR)/consumer.sysml
@echo " part def ConsumerPart {" >> $(TEST_USE_DIR)/consumer.sysml
@echo " part myPart : MyPart;" >> $(TEST_USE_DIR)/consumer.sysml
@echo " doc /* Uses MyPart from test2, which uses ExamplePart from test1 */" >> $(TEST_USE_DIR)/consumer.sysml
@echo " }" >> $(TEST_USE_DIR)/consumer.sysml
@echo "}" >> $(TEST_USE_DIR)/consumer.sysml

@cd $(TEST_USE_DIR) && $(SYSAND) include consumer.sysml
@cd $(TEST_USE_DIR) && $(SYSAND) build

@echo ""
@echo "==> Test index usage complete!"
@echo " Consumer project: $(TEST_USE_DIR)"
@echo " Dependencies resolved from: $(INDEX_READ_URL)"
@echo ""
@echo "To inspect:"
@echo " cd $(TEST_USE_DIR)"
@echo " $(SYSAND) info"

# Clean: Remove test directories
.PHONY: clean
clean:
@echo "==> Cleaning test directories..."
@rm -rf $(TEST_ROOT)
@rm -rf $(TEST_USE_ROOT)
@echo "✓ Cleaned $(TEST_ROOT) and $(TEST_USE_ROOT)"

# Info: Show project information
.PHONY: info
info:
@echo "==> Test1 Project Info:"
@if [ -d "$(TEST1_DIR)" ]; then \
cd $(TEST1_DIR) && $(SYSAND) info; \
else \
echo "Not initialized. Run 'make setup' first."; \
fi
@echo ""
@echo "==> Test2 Project Info:"
@if [ -d "$(TEST2_DIR)" ]; then \
cd $(TEST2_DIR) && $(SYSAND) info; \
else \
echo "Not initialized. Run 'make setup' first."; \
fi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class InterchangeProjectInfo {

private String name;
private String publisher;
private String description;
private String version;
private String license;
Expand All @@ -17,6 +18,7 @@ public class InterchangeProjectInfo {

public InterchangeProjectInfo(
String name,
String publisher,
String description,
String version,
String license,
Expand All @@ -26,6 +28,7 @@ public InterchangeProjectInfo(
InterchangeProjectUsage[] usage
) {
this.name = name;
this.publisher = publisher;
this.description = description;
this.version = version;
this.license = license;
Expand All @@ -39,6 +42,10 @@ public String getName() {
return name;
}

public String getPublisher() {
return publisher;
}

public String getDescription() {
return description;
}
Expand Down
4 changes: 3 additions & 1 deletion bindings/java/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) const INTERCHANGE_PROJECT_USAGE_CLASS: &str =
"com/sensmetry/sysand/model/InterchangeProjectUsage";
pub(crate) const INTERCHANGE_PROJECT_INFO_CLASS: &str =
"com/sensmetry/sysand/model/InterchangeProjectInfo";
pub(crate) const INTERCHANGE_PROJECT_INFO_CLASS_CONSTRUCTOR: &str = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Lcom/sensmetry/sysand/model/InterchangeProjectUsage;)V";
pub(crate) const INTERCHANGE_PROJECT_INFO_CLASS_CONSTRUCTOR: &str = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Lcom/sensmetry/sysand/model/InterchangeProjectUsage;)V";
pub(crate) const INTERCHANGE_PROJECT_METADATA_CLASS: &str =
"com/sensmetry/sysand/model/InterchangeProjectMetadata";
pub(crate) const INTERCHANGE_PROJECT_METADATA_CLASS_CONSTRUCTOR: &str = "(Ljava/util/LinkedHashMap;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/util/LinkedHashMap;)V";
Expand Down Expand Up @@ -260,6 +260,7 @@ impl ToJObject for Vec<InterchangeProjectUsageRaw> {
impl ToJObject for InterchangeProjectInfoRaw {
fn to_jobject<'local>(&self, env: &mut JNIEnv<'local>) -> Option<JObject<'local>> {
let name = self.name.to_jobject(env)?;
let publisher = self.publisher.to_jobject(env)?;
let description = self.description.to_jobject(env)?;
let version = self.version.to_jobject(env)?;
let license = self.license.to_jobject(env)?;
Expand All @@ -272,6 +273,7 @@ impl ToJObject for InterchangeProjectInfoRaw {
INTERCHANGE_PROJECT_INFO_CLASS_CONSTRUCTOR,
&[
JValue::from(&name),
JValue::from(&publisher),
JValue::from(&description),
JValue::from(&version),
JValue::from(&license),
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub extern "system" fn Java_com_sensmetry_sysand_Sysand_init<'local>(
},
};

let command_result = commands::init::do_init_local_file(name, version, license, path.into());
let command_result = commands::init::do_init_local_file(name, None, version, license, path.into());
match command_result {
Ok(_) => {}
Err(error) => match error {
Expand Down
1 change: 1 addition & 0 deletions bindings/js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub fn do_new_js_local_storage(

do_init(
name,
None,
version,
license,
&mut io::local_storage::ProjectLocalBrowserStorage {
Expand Down
1 change: 1 addition & 0 deletions bindings/js/tests/basic_browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod browser_tests {
info,
InterchangeProjectInfo {
name: "test_basic_new".to_string(),
publisher: None,
description: None,
version: Version::parse("1.2.3")?,
license: Some("MIT OR Apache-2.0".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion bindings/py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn do_new_py_local_file(
// library from python runs it
let _ = pyo3_log::try_init();

do_init_local_file(name, version, license, Utf8PathBuf::from(path)).map_err(
do_init_local_file(name, None, version, license, Utf8PathBuf::from(path)).map_err(
|err| match err {
InitError::SemVerParse(..) => PyValueError::new_err(err.to_string()),
InitError::SPDXLicenseParse(..) => PyValueError::new_err(err.to_string()),
Expand Down
6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ log = { version = "0.4.29", default-features = false }
pubgrub = { version = "0.3.0", default-features = false }
# partialzip = { version = "5.0.0", default-features = false, optional = true }
pyo3 = { version = "0.27.2", default-features = false, features = ["macros", "chrono", "indexmap"], optional = true }
reqwest-middleware = { version = "0.5.0" }
reqwest-middleware = { version = "0.5.0", features = ["multipart"] }
semver = { version = "1.0.27", features = ["serde"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = { version = "1.0.145", default-features = false, features = ["preserve_order"] }
Expand All @@ -65,9 +65,9 @@ globset = { version = "0.4.18", default-features = false }

# Use native TLS only on Windows and Apple OSs
[target.'cfg(any(target_os = "windows", target_vendor = "apple"))'.dependencies]
reqwest = { version = "0.13.1", optional = true, default-features = false, features = ["native-tls", "http2", "system-proxy", "stream"] }
reqwest = { version = "0.13.1", optional = true, default-features = false, features = ["native-tls", "http2", "system-proxy", "stream", "multipart"] }
[target.'cfg(not(any(target_os = "windows", target_vendor = "apple")))'.dependencies]
reqwest = { version = "0.13.1", optional = true, features = ["rustls", "stream"] }
reqwest = { version = "0.13.1", optional = true, features = ["rustls", "stream", "multipart"] }

[dev-dependencies]
assert_cmd = "2.1.1"
Expand Down
10 changes: 8 additions & 2 deletions core/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum InitError<ProjectError: ErrorBound> {

pub fn do_init_ext<P: ProjectMut>(
name: String,
publisher: Option<String>,
version: String,
no_semver: bool,
license: Option<String>,
Expand All @@ -55,6 +56,7 @@ pub fn do_init_ext<P: ProjectMut>(
storage.put_project(
&InterchangeProjectInfoRaw {
name: name.to_owned(),
publisher: publisher.to_owned(),
description: None,
version: version.to_owned(),
license,
Expand All @@ -80,22 +82,25 @@ pub fn do_init_ext<P: ProjectMut>(

pub fn do_init<P: ProjectMut>(
name: String,
publisher: Option<String>,
version: String,
license: Option<String>,
storage: &mut P,
) -> Result<(), InitError<P::Error>> {
do_init_ext(name, version, false, license, false, storage)
do_init_ext(name, publisher, version, false, license, false, storage)
}

pub fn do_init_memory<N: AsRef<str>, V: AsRef<str>>(
name: N,
publisher: Option<String>,
version: V,
license: Option<String>,
) -> Result<InMemoryProject, InitError<crate::project::memory::InMemoryError>> {
let mut storage = InMemoryProject::default();

do_init(
name.as_ref().to_owned(),
publisher,
version.as_ref().to_owned(),
license,
&mut storage,
Expand All @@ -107,6 +112,7 @@ pub fn do_init_memory<N: AsRef<str>, V: AsRef<str>>(
#[cfg(feature = "filesystem")]
pub fn do_init_local_file(
name: String,
publisher: Option<String>,
version: String,
license: Option<String>,
path: Utf8PathBuf,
Expand All @@ -116,7 +122,7 @@ pub fn do_init_local_file(
project_path: path,
};

do_init(name, version, license, &mut storage)?;
do_init(name, publisher, version, license, &mut storage)?;

Ok(storage)
}
2 changes: 2 additions & 0 deletions core/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub mod include;
pub mod info;
pub mod init;
pub mod lock;
#[cfg(all(feature = "filesystem", feature = "networking"))]
pub mod publish;
pub mod remove;
#[cfg(feature = "filesystem")]
pub mod root;
Expand Down
Loading
Loading