ux-survey/Makefile

95 lines
2.4 KiB
Makefile

default: ## Debug build
cargo build
check: ## Check for syntax errors on all workspaces
cargo check --workspace --tests --all-features
#cd utils/cache-bust && cargo check --tests --all-features
clean: ## Clean all build artifacts and dependencies
@cargo clean
coverage: ## Generate HTML code coverage
cargo tarpaulin -t 1200 --out Html
dev-env: ## Download development dependencies
cargo fetch
doc: ## Prepare documentation
cargo doc --no-deps --workspace --all-features
docker: ## Build docker images
docker buildx build \
-t mcaptcha/showcase:master \
-t mcaptcha/showcase:latest \
-t mcaptcha/showcase:0.1.0 .
docker-publish: docker ## Build and publish docker images
docker push mcaptcha/showcase:master
docker push mcaptcha/showcase:latest
docker push mcaptcha/showcase:0.1.0
lint: ## Lint codebase
cargo fmt -v --all -- --emit files
cargo clippy --workspace --tests --all-features
release: ## Release build
cargo build --release
run: default ## Run debug build
cargo run
test: ## Run tests
cargo test --all-features --no-fail-fast
xml-test-coverage: ## Generate cobertura.xml test coverage
cargo tarpaulin -t 1200 --out Xml
help: ## Prints help for targets with comments
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define deploy_dependencies ## deploy dependencies
@-docker create --name ${db} \
-e POSTGRES_PASSWORD=password \
-p 5432:5432 \
postgres
docker start ${db}
endef
define run_migrations ## run database migrations
cd db-migrations/ && cargo run
endef
define run_dev_migrations ## run database migrations
cd db/db-sqlx-maria/ && \
DATABASE_URL=${POSTGRES_DATABASE_URL} sqlx migrate run
endef
check: ## Check for syntax errors on all workspaces
cargo check --workspace --tests --all-features
cd db-migrations && cargo check --tests --all-features
env.db: ## Deploy dependencies
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
env.db.recreate: ## Deploy dependencies from scratch
@-docker rm -f ${db}
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
migrate: ## Run database migrations
$(call run_migrations)
migrate.dev: ## Run database migrations during development
$(call run_dev_migrations)
db.sqlx.offline: ## prepare sqlx offline data
cargo sqlx prepare \
--database-url=${DATABASE_URL} -- \
--all-features