diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9a0fcf3 --- /dev/null +++ b/Makefile @@ -0,0 +1,70 @@ +.DEFAULT_GOAL := help + +# Public Navidrome demo server, used by test-live and shots. +DEMO_URL ?= https://demo.navidrome.org +DEMO_USER ?= demo +DEMO_PASS ?= demo + +# Scratch config and cache for scripted runs, so they never touch your own. +SHOTS_DIR := target/shots +SCRATCH := target/scratch + +.PHONY: help +help: ## List the targets + @grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' + +.PHONY: build +build: ## Debug build + cargo build + +.PHONY: release +release: ## Optimised build, binary in target/release/remus + cargo build --release + +.PHONY: run +run: ## Run fullscreen + cargo run --release + +.PHONY: run-windowed +run-windowed: ## Run in a window + cargo run --release -- --windowed + +.PHONY: fmt +fmt: ## Format the code + cargo fmt + +.PHONY: fmt-check +fmt-check: ## Fail if the code is not formatted + cargo fmt --check + +.PHONY: lint +lint: ## Clippy, warnings as errors + cargo clippy --all-targets -- -D warnings + +.PHONY: test +test: ## Unit tests + cargo test + +.PHONY: check +check: fmt-check lint test ## Formatting, lint and tests: run before committing + +.PHONY: test-live +test-live: ## Every Subsonic call against a real server (DEMO_URL, DEMO_USER, DEMO_PASS) + REMUS_TEST_URL=$(DEMO_URL) REMUS_TEST_USER=$(DEMO_USER) REMUS_TEST_PASS=$(DEMO_PASS) \ + cargo test live_server -- --ignored --nocapture + +.PHONY: shots +shots: ## Screenshot the main screens against the demo server into target/shots + @mkdir -p $(SHOTS_DIR) $(SCRATCH)/config/remus $(SCRATCH)/cache + @salt=$$(head -c 8 /dev/urandom | od -An -tx1 | tr -d ' \n'); \ + token=$$(printf '%s%s' '$(DEMO_PASS)' "$$salt" | md5sum | cut -d' ' -f1); \ + printf 'url = "%s"\nusername = "%s"\nsalt = "%s"\ntoken = "%s"\n' \ + '$(DEMO_URL)' '$(DEMO_USER)' "$$salt" "$$token" > $(SCRATCH)/config/remus/config.toml + cargo build + XDG_CONFIG_HOME=$(CURDIR)/$(SCRATCH)/config XDG_CACHE_HOME=$(CURDIR)/$(SCRATCH)/cache \ + REMUS_DEV_SCRIPT="wait:4000,shot:$(SHOTS_DIR)/home.png,right,activate,wait:3000,shot:$(SHOTS_DIR)/album.png,down,activate,wait:3000,now-playing,wait:2500,shot:$(SHOTS_DIR)/now-playing.png,play-pause,back,section-next,section-next,section-next,wait:3000,shot:$(SHOTS_DIR)/artists.png,quit" \ + ./target/debug/remus + +.PHONY: clean +clean: ## Remove build output, screenshots and scratch config + cargo clean diff --git a/README.md b/README.md index eade3f1..b80f370 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,20 @@ With Steam running, remus listens only to Steam's virtual controller, so a pad S ## Development -``` -cargo test -REMUS_TEST_URL=https://demo.navidrome.org REMUS_TEST_USER=demo REMUS_TEST_PASS=demo \ - cargo test -- --ignored # every API call against a real server -``` - -`REMUS_DEV_SCRIPT` replays actions and saves screenshots, which is how layouts are checked at different sizes without a controller: +`make` lists the targets. The ones you will use most: ``` -REMUS_DEV_SCRIPT="size:full,wait:3000,shot:home.png,right,activate,wait:2000,shot:album.png,quit" cargo run +make check # formatting, clippy with warnings as errors, unit tests +make test-live # every Subsonic call against the Navidrome demo server +make shots # fullscreen screenshots of the main screens into target/shots ``` -Steps: `size:WxH`, `size:full`, `wait:MS`, `shot:PATH`, and action names (`up`, `down`, `left`, `right`, `activate`, `back`, `queue`, `next`, `play-pause`, `section-next`, `now-playing`, `search`, `quit`). Point `XDG_CONFIG_HOME` and `XDG_CACHE_HOME` at a scratch directory to keep test runs away from your own config. +`test-live` and `shots` take `DEMO_URL`, `DEMO_USER` and `DEMO_PASS` to point at another server. `shots` runs against a scratch config in `target/scratch`, never your own. + +`make shots` is built on `REMUS_DEV_SCRIPT`, which replays actions and saves screenshots so layouts can be checked without a controller: + +``` +REMUS_DEV_SCRIPT="wait:3000,shot:home.png,right,activate,wait:2000,shot:album.png,quit" cargo run +``` + +A scripted run starts fullscreen like a normal one, so it also checks that startup reaches fullscreen. Add `--windowed` to capture a window instead. Steps: `size:WxH`, `size:full`, `wait:MS`, `shot:PATH`, and action names (`up`, `down`, `left`, `right`, `activate`, `back`, `queue`, `next`, `play-pause`, `section-next`, `now-playing`, `search`, `quit`). Point `XDG_CONFIG_HOME` and `XDG_CACHE_HOME` at a scratch directory to keep test runs away from your own config.