survey/Makefile

96 lines
2.2 KiB
Makefile
Raw Permalink Normal View History

define deploy_dependencies
@-docker create --name ${db} \
-e POSTGRES_PASSWORD=password \
-p 5433:5432 \
postgres
docker start ${db}
endef
define run_migrations
cargo run --bin tests-migrate
endef
2021-10-04 21:21:10 +05:30
default: frontend ## Debug build
2021-10-14 14:43:22 +05:30
cargo build
2021-10-04 21:21:10 +05:30
clean: ## Clean all build artifacts and dependencies
@cargo clean
@yarn cache clean
@-rm -rf browser/pkg
@-rm ./src/cache_buster_data.json
@-rm -rf ./static/cache/bundle
@-rm -rf ./assets
2023-01-24 19:02:07 +05:30
check: ## Check for syntax errors on all workspaces
cargo check --workspace --tests --all-features
2021-10-04 21:21:10 +05:30
coverage: migrate ## Generate HTML code coverage
cargo tarpaulin -t 1200 --out Html
dev-env: ## Download development dependencies
cargo fetch
yarn install
env.db.recreate: ## Deploy dependencies
@-docker rm -f ${db}
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
env.db: ## Deploy dependencies
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
2021-10-04 21:21:10 +05:30
doc: ## Prepare documentation
cargo doc --no-deps --workspace --all-features
docker: ## Build docker images
2021-10-14 21:50:45 +05:30
docker build -t mcaptcha/survey:master -t mcaptcha/survey:latest .
2021-10-04 21:21:10 +05:30
docker-publish: docker ## Build and publish docker images
2021-10-14 21:50:45 +05:30
docker push mcaptcha/survey:master
docker push mcaptcha/survey:latest
2021-10-04 21:21:10 +05:30
frontend: ## Build frontend assets
@yarn install
@-rm -rf ./static/cache/bundle/
2021-10-14 14:43:22 +05:30
@-mkdir -p ./static/cache/bundle/css/
2021-10-13 14:11:39 +05:30
@yarn sass
@yarn build
@./scripts/bundle.sh
2021-10-04 21:21:10 +05:30
2021-10-10 19:23:48 +05:30
lint: ## Lint codebase
cargo fmt -v --all -- --emit files
cargo clippy --workspace --tests --all-features
yarn lint
2021-10-10 19:23:48 +05:30
2021-10-04 21:21:10 +05:30
migrate: ## Run database migrations
$(call run_migrations)
2021-10-04 21:21:10 +05:30
release: frontend ## Release build
cargo build --release
run: default ## Run debug build
cargo run
sqlx-offline-data: ## prepare sqlx offline data
cargo sqlx prepare \
--database-url=${DATABASE_URL} -- \
--all-features \
--bin survey
2021-10-04 21:21:10 +05:30
test: frontend ## Run tests
echo 'static/' && tree static || true
echo 'tree/' && tree assets || true
cargo test --all-features --no-fail-fast -j 1
2021-10-04 21:21:10 +05:30
xml-test-coverage: migrate ## 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}'