init: setup all
all: validate package
validate: build security lint test
stack: stack-up stack-down

setup:
	curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
	rustup toolchain install nightly-2021-09-20
	rustup component add clippy --toolchain nightly-2021-09-20
	rustup component add rustfmt --toolchain nightly-2021-09-20
	cargo +nightly-2021-09-20 install cargo-audit --force
	cargo +nightly-2021-09-20 install cargo-deny --force
	cargo +nightly-2021-09-20 install mdbook --force

build:
	cargo +nightly-2021-09-20 build

clean:
	rm -rf target

lint:
	cargo +nightly-2021-09-20 check
	cargo +nightly-2021-09-20 fmt --all
	cargo +nightly-2021-09-20 clippy --all --tests --all-targets --all-features

test:
	cargo +nightly-2021-09-20 test --all --verbose

coverage:
	@echo Not implemented
	exit 1

security:
	cargo +nightly-2021-09-20 audit

documentation:
	cargo +nightly-2021-09-20 doc --workspace --all-features
	mdbook build

package:
	cargo +nightly-2021-09-20 build --release
	cp ./target/release/gloom /usr/local/bin/gloom

stack-up:
	docker-compose up --build --detach

stack-down:
	docker-compose down --remove-orphans
