diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7aa11e9..1a18f22 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,6 +32,8 @@ jobs: cross build --examples --bins --release --target aarch64-unknown-linux-gnu mv target/aarch64-unknown-linux-gnu/release/STS1_EDU_Scheduler . mv target/aarch64-unknown-linux-gnu/release/examples/cli . + cp scheduler/config.toml . + cp scheduler/scheduler.service . - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 1d89898..e874859 100644 --- a/.gitignore +++ b/.gitignore @@ -4,11 +4,11 @@ __pycache__/ venv .vscode log -archives/ -data/ +archives/* +data/* tests/tmp/ lib/**/target # Added by cargo -/target \ No newline at end of file +/target diff --git a/Cargo.toml b/Cargo.toml index 05f0d5c..81f39e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,35 +1,11 @@ -[package] -name = "STS1_EDU_Scheduler" -version = "0.1.0" -edition = "2021" - -[dependencies] -log = "0.4.22" -simplelog = "0.12.2" -subprocess = "0.2.9" -crc = "3.2.1" -toml = "0.8.19" -rppal = "0.18.0" -serde = { version = "1.0.204", features = ["derive"] } -strum = { version = "0.26.3", features = ["derive"] } -serialport = "4.4.0" -test-case = "3.3.1" -tar = "0.4.41" -thiserror = "1.0.63" -anyhow = { version = "1.0.86", features = ["backtrace"] } - -[dependencies.filevec] -path = "lib/filevec" - -[features] -mock = [] -rpi = [] - -[dev-dependencies] -file-per-thread-logger = "0.2.0" -inquire = "0.7.5" - -[lints.clippy] +[workspace] +resolver = "2" +members = [ + "scheduler", + "filevec", +] + +[workspace.lints.clippy] pedantic = { level = "warn", priority = -1 } missing_errors_doc = "allow" module_name_repetitions = "allow" diff --git a/Makefile b/Makefile index ea7eb3d..15f8317 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,11 @@ packs: clean: rm -rf *.profraw - rm -f ThreadId* updatepin - rm -f data/* - rm -rf archives/* - rm -rf tests/tmp - rm -f tests/*.pack + rm -f scheduler/ThreadId* scheduler/updatepin + rm -f scheduler/data/* + rm -rf scheduler/archives/* + rm -rf scheduler/tests/tmp + rm -f scheduler/tests/*.pack rebuild_student_archive: rm -f tests/student_program.zip diff --git a/archives/.gitkeep b/archives/.gitkeep index 74cfd77..e69de29 100644 --- a/archives/.gitkeep +++ b/archives/.gitkeep @@ -1,2 +0,0 @@ -Folder for storing student programs -Used by tests diff --git a/lib/filevec/Cargo.lock b/filevec/Cargo.lock similarity index 100% rename from lib/filevec/Cargo.lock rename to filevec/Cargo.lock diff --git a/lib/filevec/Cargo.toml b/filevec/Cargo.toml similarity index 100% rename from lib/filevec/Cargo.toml rename to filevec/Cargo.toml diff --git a/lib/filevec/src/lib.rs b/filevec/src/lib.rs similarity index 100% rename from lib/filevec/src/lib.rs rename to filevec/src/lib.rs diff --git a/scheduler/Cargo.toml b/scheduler/Cargo.toml new file mode 100644 index 0000000..0ea93e4 --- /dev/null +++ b/scheduler/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "STS1_EDU_Scheduler" +version = "0.1.0" +edition = "2021" + +[dependencies] +log = "0.4.22" +simplelog = "0.12.2" +subprocess = "0.2.9" +crc = "3.2.1" +toml = "0.8.19" +rppal = "0.18.0" +serde = { version = "1.0.204", features = ["derive"] } +strum = { version = "0.26.3", features = ["derive"] } +serialport = "4.4.0" +test-case = "3.3.1" +tar = "0.4.41" +thiserror = "1.0.63" +anyhow = { version = "1.0.86", features = ["backtrace"] } + +[dependencies.filevec] +path = "../filevec" + +[features] +mock = [] +rpi = [] + +[dev-dependencies] +file-per-thread-logger = "0.2.0" +inquire = "0.7.5" + +[lints] +workspace = true diff --git a/config.toml b/scheduler/config.toml similarity index 100% rename from config.toml rename to scheduler/config.toml diff --git a/docs/protocol.py b/scheduler/docs/protocol.py similarity index 100% rename from docs/protocol.py rename to scheduler/docs/protocol.py diff --git a/examples/cli.rs b/scheduler/examples/cli.rs similarity index 100% rename from examples/cli.rs rename to scheduler/examples/cli.rs diff --git a/scheduler.service b/scheduler/scheduler.service similarity index 100% rename from scheduler.service rename to scheduler/scheduler.service diff --git a/src/command/common.rs b/scheduler/src/command/common.rs similarity index 100% rename from src/command/common.rs rename to scheduler/src/command/common.rs diff --git a/src/command/error.rs b/scheduler/src/command/error.rs similarity index 100% rename from src/command/error.rs rename to scheduler/src/command/error.rs diff --git a/src/command/execute_program.rs b/scheduler/src/command/execute_program.rs similarity index 100% rename from src/command/execute_program.rs rename to scheduler/src/command/execute_program.rs diff --git a/src/command/execution_context.rs b/scheduler/src/command/execution_context.rs similarity index 100% rename from src/command/execution_context.rs rename to scheduler/src/command/execution_context.rs diff --git a/src/command/get_status.rs b/scheduler/src/command/get_status.rs similarity index 100% rename from src/command/get_status.rs rename to scheduler/src/command/get_status.rs diff --git a/src/command/mod.rs b/scheduler/src/command/mod.rs similarity index 100% rename from src/command/mod.rs rename to scheduler/src/command/mod.rs diff --git a/src/command/return_result.rs b/scheduler/src/command/return_result.rs similarity index 100% rename from src/command/return_result.rs rename to scheduler/src/command/return_result.rs diff --git a/src/command/stop_program.rs b/scheduler/src/command/stop_program.rs similarity index 100% rename from src/command/stop_program.rs rename to scheduler/src/command/stop_program.rs diff --git a/src/command/store_archive.rs b/scheduler/src/command/store_archive.rs similarity index 100% rename from src/command/store_archive.rs rename to scheduler/src/command/store_archive.rs diff --git a/src/command/update_time.rs b/scheduler/src/command/update_time.rs similarity index 100% rename from src/command/update_time.rs rename to scheduler/src/command/update_time.rs diff --git a/src/communication/cep.rs b/scheduler/src/communication/cep.rs similarity index 100% rename from src/communication/cep.rs rename to scheduler/src/communication/cep.rs diff --git a/src/communication/mod.rs b/scheduler/src/communication/mod.rs similarity index 100% rename from src/communication/mod.rs rename to scheduler/src/communication/mod.rs diff --git a/src/communication/socket.rs b/scheduler/src/communication/socket.rs similarity index 100% rename from src/communication/socket.rs rename to scheduler/src/communication/socket.rs diff --git a/src/lib.rs b/scheduler/src/lib.rs similarity index 100% rename from src/lib.rs rename to scheduler/src/lib.rs diff --git a/src/main.rs b/scheduler/src/main.rs similarity index 100% rename from src/main.rs rename to scheduler/src/main.rs diff --git a/tests/simulation/command_execution.rs b/scheduler/tests/simulation/command_execution.rs similarity index 100% rename from tests/simulation/command_execution.rs rename to scheduler/tests/simulation/command_execution.rs diff --git a/tests/simulation/full_run.rs b/scheduler/tests/simulation/full_run.rs similarity index 100% rename from tests/simulation/full_run.rs rename to scheduler/tests/simulation/full_run.rs diff --git a/tests/simulation/logging.rs b/scheduler/tests/simulation/logging.rs similarity index 100% rename from tests/simulation/logging.rs rename to scheduler/tests/simulation/logging.rs diff --git a/tests/simulation/mod.rs b/scheduler/tests/simulation/mod.rs similarity index 98% rename from tests/simulation/mod.rs rename to scheduler/tests/simulation/mod.rs index 3ffb798..cddb258 100644 --- a/tests/simulation/mod.rs +++ b/scheduler/tests/simulation/mod.rs @@ -92,7 +92,7 @@ fn start_scheduler( std::io::Error, > { let test_dir = format!("./tests/tmp/{unique}"); - let scheduler_bin = std::fs::canonicalize("./target/release/STS1_EDU_Scheduler")?; + let scheduler_bin = std::fs::canonicalize("../target/release/STS1_EDU_Scheduler")?; let _ = std::fs::remove_dir_all(&test_dir); std::fs::create_dir_all(&test_dir)?; std::fs::write(format!("{}/config.toml", &test_dir), get_config_str(unique))?; diff --git a/tests/simulation/socket.rs b/scheduler/tests/simulation/socket.rs similarity index 100% rename from tests/simulation/socket.rs rename to scheduler/tests/simulation/socket.rs diff --git a/tests/simulation/timeout.rs b/scheduler/tests/simulation/timeout.rs similarity index 100% rename from tests/simulation/timeout.rs rename to scheduler/tests/simulation/timeout.rs diff --git a/tests/software_tests/command_integration.rs b/scheduler/tests/software_tests/command_integration.rs similarity index 100% rename from tests/software_tests/command_integration.rs rename to scheduler/tests/software_tests/command_integration.rs diff --git a/tests/software_tests/common.rs b/scheduler/tests/software_tests/common.rs similarity index 97% rename from tests/software_tests/common.rs rename to scheduler/tests/software_tests/common.rs index c113786..564d855 100644 --- a/tests/software_tests/common.rs +++ b/scheduler/tests/software_tests/common.rs @@ -109,10 +109,12 @@ impl Write for TestCom { /// Copy the mockup student program from `tests/test_data/main.py` into `archives/{path}`. This absolves the need /// to include an extra `store_archive` command. pub fn prepare_program(path: &str) { - let ret = std::fs::create_dir(format!("./archives/{path}")); + let ret = std::fs::create_dir_all(format!("./archives/{path}")); if let Err(e) = ret { assert!(e.kind() == std::io::ErrorKind::AlreadyExists, "Setup Error: {e}"); } + let _ = std::fs::create_dir_all("./data"); + let ret = std::fs::copy("./tests/test_data/main.py", format!("./archives/{path}/main.py")); if let Err(e) = ret { assert!(e.kind() == std::io::ErrorKind::AlreadyExists, "Setup Error: {e}"); diff --git a/tests/software_tests/communication_tests.rs b/scheduler/tests/software_tests/communication_tests.rs similarity index 100% rename from tests/software_tests/communication_tests.rs rename to scheduler/tests/software_tests/communication_tests.rs diff --git a/tests/software_tests/execute_program.rs b/scheduler/tests/software_tests/execute_program.rs similarity index 100% rename from tests/software_tests/execute_program.rs rename to scheduler/tests/software_tests/execute_program.rs diff --git a/tests/software_tests/get_status.rs b/scheduler/tests/software_tests/get_status.rs similarity index 100% rename from tests/software_tests/get_status.rs rename to scheduler/tests/software_tests/get_status.rs diff --git a/tests/software_tests/mod.rs b/scheduler/tests/software_tests/mod.rs similarity index 100% rename from tests/software_tests/mod.rs rename to scheduler/tests/software_tests/mod.rs diff --git a/tests/software_tests/return_result.rs b/scheduler/tests/software_tests/return_result.rs similarity index 100% rename from tests/software_tests/return_result.rs rename to scheduler/tests/software_tests/return_result.rs diff --git a/tests/software_tests/stop_program.rs b/scheduler/tests/software_tests/stop_program.rs similarity index 100% rename from tests/software_tests/stop_program.rs rename to scheduler/tests/software_tests/stop_program.rs diff --git a/tests/software_tests/store_archive.rs b/scheduler/tests/software_tests/store_archive.rs similarity index 100% rename from tests/software_tests/store_archive.rs rename to scheduler/tests/software_tests/store_archive.rs diff --git a/tests/student_program.zip b/scheduler/tests/student_program.zip similarity index 100% rename from tests/student_program.zip rename to scheduler/tests/student_program.zip diff --git a/tests/test_data/main.py b/scheduler/tests/test_data/main.py similarity index 100% rename from tests/test_data/main.py rename to scheduler/tests/test_data/main.py diff --git a/tests/test_data/module0/__init__.py b/scheduler/tests/test_data/module0/__init__.py similarity index 100% rename from tests/test_data/module0/__init__.py rename to scheduler/tests/test_data/module0/__init__.py diff --git a/tests/tests.rs b/scheduler/tests/tests.rs similarity index 100% rename from tests/tests.rs rename to scheduler/tests/tests.rs