From 7dee3f87b8550d9c75bbfc7763a423c69895f017 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Thu, 8 Aug 2024 10:18:36 +0200 Subject: [PATCH 1/3] Add a test to piglet that checks "--version" works and outputs the correct version --- Cargo.lock | 41 +++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 ++- tests/piglet.rs | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86818d32..b3e01115 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4044,6 +4044,7 @@ dependencies = [ "serde", "serde_arrays", "serde_json", + "serial_test", "service-manager", "sysinfo", "tempfile", @@ -5058,6 +5059,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ff467073ddaff34c3a39e5b454f25dd982484a26fff50254ca793c56a1b714" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.23" @@ -5102,6 +5112,12 @@ dependencies = [ "tiny-skia", ] +[[package]] +name = "sdd" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177258b64c0faaa9ffd3c65cd3262c2bc7e2588dbbd9c1641d0346145c1bbda8" + [[package]] name = "sec1" version = "0.7.3" @@ -5234,6 +5250,31 @@ dependencies = [ "serde", ] +[[package]] +name = "serial_test" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot 0.12.3", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "service-manager" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 8c946e54..9e14e2ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,10 +65,11 @@ lyon_algorithms = { version = "1.0", default-features = false } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tempfile = "3" +serial_test = "3.1.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] rfd = "0.14.1" -clap = { version = "4.5.13", default-features = false, features = ["std", "help", "error-context"]} +clap = { version = "4.5.13", default-features = false, features = ["std", "help", "error-context"] } [target.aarch64-unknown-linux-gnu.dependencies] rppal = "0.18.0" diff --git a/tests/piglet.rs b/tests/piglet.rs index bbe647a5..9f31e912 100644 --- a/tests/piglet.rs +++ b/tests/piglet.rs @@ -1,17 +1,24 @@ +use serial_test::serial; use std::io::{BufRead, BufReader}; use std::path::PathBuf; use std::process::{Command, Stdio}; #[cfg(not(target_arch = "wasm32"))] -pub fn run_piglet(config: Option) -> String { +pub fn run_piglet(options: Vec, config: Option) -> String { let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let mut piglet_command = Command::new("cargo"); - let mut args = vec!["run".to_string(), "--bin".to_string(), "piglet".to_string()]; + let mut args = vec![ + "run".to_string(), + "--bin".to_string(), + "piglet".to_string(), + "--".into(), + ]; + + args.extend(options); // If a config file path was supplied, add it as a CLI argument if let Some(config_path) = config { - args.push("--".to_string()); let path = config_path.as_path().to_string_lossy().to_string(); args.push(path); } @@ -53,11 +60,33 @@ pub fn run_piglet(config: Option) -> String { target_arch = "wasm32" )))] #[test] +#[serial] fn node_id_is_output() { - let output = run_piglet(None); + let output = run_piglet(vec![], None); println!("Output: {}", output); assert!( output.contains("nodeid"), "Output of piglet does not contain nodeid" ); } + +#[cfg(not(any( + all( + target_os = "linux", + any(target_arch = "aarch64", target_arch = "arm"), + target_env = "gnu" + ), + target_arch = "wasm32" +)))] +#[test] +#[serial] +fn version_number() { + let output = run_piglet(vec!["--version".into()], None); + println!("Output: {}", output); + assert!( + output.contains("piglet"), + "Output of piglet does not contain version" + ); + let version = output.split(' ').nth(1).unwrap().trim(); + assert_eq!(version, env!("CARGO_PKG_VERSION")); +} From cf9a04e7ac0fc7ad9d70bda4c92ea8e40d00c209 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Thu, 8 Aug 2024 10:28:41 +0200 Subject: [PATCH 2/3] Add INSTALLING.md and link to it from README.md --- INSTALLING.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 59 +++++++++++++++++----------------------------- 2 files changed, 87 insertions(+), 37 deletions(-) create mode 100644 INSTALLING.md diff --git a/INSTALLING.md b/INSTALLING.md new file mode 100644 index 00000000..451cf5db --- /dev/null +++ b/INSTALLING.md @@ -0,0 +1,65 @@ +# Installing + +Up-to-date instructions for installing are also be in the release notes of the +[latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) + +## Install prebuilt binaries via shell script + +If your platform supports `sh` (and you have `curl` installed), then you can install the appropriate prebuilt binary +using: + +```sh +curl --proto '=https' --tlsv1.2 -LsSf https://github.com/andrewdavidmackenzie/pigg/releases/download/0.3.4/pigg-installer.sh | sh +``` + +(example shown is for version 0.3.4. Check +the [latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) page +for the line to be used for the latest release, after 0.3.4) + +## Install prebuilt binaries via Homebrew + +For platforms that use homebrew, you can install the appropriate prebuilt binary using: + +```sh +brew install andrewdavidmackenzie/pigg-tap/pigg +``` + +## Install pre-built binaries via "cargo binstall" + +If you have installed a rust toolchain, then you can +install [`cargo-binstall`](https://crates.io/crates/cargo-binstall/1.4.3) +which you can then use to install the pre-built binaries, without building from source: + +```sh +cargo binstall pigg +``` + +## Other Installation options for Windows + +See the Downloads section in the [latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) +where you can find a downloadable "msi" installer for Windows that will install the appropriate pre-built binary. + +You can also download a "zip" file with the prebuilt binary for Windows and run or install that manually. + +## Other Installation options for Mac + +See the Downloads section in the [latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) +where you can find "tar.xz" downloads for x86 and Apple Silicon Macs. + +Expand the downloaded file with `tar -xvf` and then run or manually install the binary + +## Other Installation options for Mac + +See the Downloads section in the [latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) +where you can find "tar.xz" downloads for Linux x86 machines + +Expand the downloaded file with `tar -xvf` and then run or manually install the binary + +## Checking the version installed + +Check the version you have installed is the latest with + +```sh +piggui --version +piglet --version +``` diff --git a/README.md b/README.md index b844c40d..c91b7b56 100644 --- a/README.md +++ b/README.md @@ -38,28 +38,13 @@ hardware remotely. -## Latest NEW Feature - Networked GPIO! +## Latest NEW Feature - pre-built images and installers -* The GUI (`piggui`) can connect to a Pi (that is running `piglet`) over the network, to control and view the GPIO - hardware - from a distance. The GUI can run on Mac, Linux, Windows or Raspberry Pis. Events are timestamped at source (as - close to the hardware as possible) so network delays should not affect the waveforms displayed. Provide us - feedback and ideas related to networking in Discussions or GH issues. -* The data required to connect to a remote node via iroh-net is called the `nodeid`. `piglet` prints this out for you if - it - is started in the foreground. When `piglet` has been started as a system service, start another instance in the - foreground and this will detect the background instance and display its `nodeid` for you then exit. -* Take the `nodeid` and either supply it as a command line option to `piggui` (`--nodeid $nodeid`, prefixed with `-- ` - if using - `cargo run`) or enter it into the GUI. To connect to a remote instance from the GUI, click on the "hardware menu" in - the - left of the info bar at the bottom of the screen and select the "Connect to remote Pi..:" menu item. Then enter the - `nodeid` into the field provided and hit "Connect" - -Here are two videos showing the two ways to use it, with piglet running on a RPi shown via VNC. +We have added pre-built images for different OS and CPU architecture, along with installers, to the automated +release process using `cargo dist`. See [INSTALLING.md](INSTALLING.md) for details. -* Video with Dialog: https://youtu.be/aToJ1aT7NeM -* Video using CLI argument: https://youtu.be/zcEa_Oke014 +Up-to-date instructions for installing are also be in the release notes of the +[latest release](https://github.com/andrewdavidmackenzie/pigg/releases/latest) ## Other Features @@ -75,6 +60,20 @@ Here are two videos showing the two ways to use it, with piglet running on a RPi inversions of the stable level, plus a waveform view showing the recent history of the level set on the Output. - GPIO configurations can be loaded at startup with a command line filename option, or loaded via file-picker from the UI or saved to file via file picker. +- The GUI (`piggui`) can connect to a Pi (that is running `piglet`) over the network, to control and view the GPIO + hardware from a distance. The GUI can run on Mac, Linux, Windows or Raspberry Pis. Events are timestamped at source + (as close to the hardware as possible) so network delays should not affect the waveforms displayed. Provide us + feedback and ideas related to networking in Discussions or GH issues. +- The data required to connect to a remote node via iroh-net is called the `nodeid`. `piglet` prints this out for you + if it is started in the foreground. When `piglet` has been started as a system service, start another instance in the + foreground and this will detect the background instance and display its `nodeid` for you then exit. +- Take the `nodeid` and either supply it as a command line option to `piggui` (`--nodeid $nodeid`, prefixed with `-- ` + if using `cargo run`) or enter it into the GUI. To connect to a remote instance from the GUI, click on the + "hardware menu" in the left of the info bar at the bottom of the screen and select the "Connect to remote Pi..:" + menu item. Then enter the `nodeid` into the field provided and hit "Connect" +- Here are two videos showing the two ways to use it, with piglet running on a RPi shown via VNC. + - Video with Dialog: https://youtu.be/aToJ1aT7NeM + - Video using CLI argument: https://youtu.be/zcEa_Oke014 You can see more gifs and videos of features [here](assets/features.md) @@ -111,41 +110,27 @@ and input on how integrate new functionalities (e.g. I2C buses, SPI, UART, etc.) Please let us know what you think, and suggestions, via [Discussions](https://github.com/andrewdavidmackenzie/pigg/discussions) or GH issues. -## Short-term Roadmap +## Roadmap We have identified a number of areas we would like to work on after this initial release, but would really appreciate your input on what could be most useful or just the coolest, many have GH issues. -- Automation of release process and publishing - packages [Issue #85](https://github.com/andrewdavidmackenzie/pigg/issues/85) - Pre-built binaries for install on Raspberry Pi [Issue #112](https://github.com/andrewdavidmackenzie/pigg/issues/112) and easier install [Issue #111](https://github.com/andrewdavidmackenzie/pigg/issues/111) - Expand support beyond Inputs and Outputs ( e.g. Clocks, PWM, I2C, UART, SPI etc.). Issue [#53](https://github.com/andrewdavidmackenzie/pigg/issues/53), [#52](https://github.com/andrewdavidmackenzie/pigg/issues/52), [#5](https://github.com/andrewdavidmackenzie/pigg/issues/5) - True logical layout, grouping pins by function [Issue #94](https://github.com/andrewdavidmackenzie/pigg/issues/94) - -## Further out ideas - - Allow connections between pins [Issue #95](https://github.com/andrewdavidmackenzie/pigg/issues/95) - Pico support for a headless hardware backend accessed over the network - Trigger a script or WebAssembly plugin on an input event (edge, level, etc.) ## Installing -We have work planned to produce pre-built binaries for supported platforms, and ways to install them -directly. - -Prior to that, to install `piggui` and `piglet` you will have to build from source, either using `cargo install`, -or `cargo build` or `make` from a clone of the repo or a download of a release source tarball/zip. - -See the section below for details. - -This is an area where we welcome ideas, input and contributions - please post your thoughts to the -[Discussions](https://github.com/andrewdavidmackenzie/pigg/discussions) +TODO -## Building Piggui and Piglet from Source +## Building from Source See [BUILDING.md](BUILDING.md) From f4c038599b1d1a9197aff1db8fd9acbaad5af278 Mon Sep 17 00:00:00 2001 From: Andrew Mackenzie Date: Thu, 8 Aug 2024 10:45:51 +0200 Subject: [PATCH 3/3] Fix broken link --- INSTALLING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/INSTALLING.md b/INSTALLING.md index 451cf5db..c5a4bda8 100644 --- a/INSTALLING.md +++ b/INSTALLING.md @@ -26,9 +26,8 @@ brew install andrewdavidmackenzie/pigg-tap/pigg ## Install pre-built binaries via "cargo binstall" -If you have installed a rust toolchain, then you can -install [`cargo-binstall`](https://crates.io/crates/cargo-binstall/1.4.3) -which you can then use to install the pre-built binaries, without building from source: +If you have installed a rust toolchain, then you can install `cargo-binstall` from [crates.io](https://crates.io) +and then use it to install the pre-built binaries, without building from source: ```sh cargo binstall pigg