ftest/Makefile
Aravinth Manivannan 5b8b9c4440
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
fix: use offline sqlx compilation while building migrator
2023-10-05 01:39:10 +05:30

151 lines
3.6 KiB
Makefile

# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#BUNDLE = static/cache/bundle
#OPENAPI = docs/openapi
#CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
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
unset DATABASE_URL && cd db/migrations/ && cargo build
cd db/migrations/ && cargo run
endef
define run_dev_migrations ## run database migrations
sqlx migrate run
endef
#define frontend_env ## install frontend deps
# yarn install
# cd docs/openapi && yarn install
#endef
#
#define cache_bust ## run cache_busting program
# cd utils/cache-bust && cargo run
#endef
#
#
#define test_frontend ## run frontend tests
# yarn test
## cd $(OPENAPI)&& yarn test
#endef
define test_core
cargo test --no-fail-fast -j 1
endef
default: ## Build app in debug mode
cargo build
check: ## Check for syntax errors on all workspaces
cargo check --workspace --tests --all-features
cd db/migrations && cargo check --tests --all-features
#cache-bust: ## Run cache buster on static assets
# $(call cache_bust)
clean: ## Delete build artifacts
@cargo clean
#@yarn cache clean
#@-rm $(CLEAN_UP)
doc: ## Generate documentation
#yarn doc
cargo doc --no-deps --workspace --all-features
docker.build: ## Build Docker image
docker buildx build -t forgeflux/ftest:latest --load .
docker.publish: docker ## Build and publish Docker image
docker push forgeflux/ftest:master
docker push forgeflux/ftest:latest
env: ## Setup development environtment
cargo fetch
$(call frontend_env)
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)
#frontend-env: ## Install frontend deps
# $(call frontend_env)
#
#frontend: ## Build frontend
# $(call frontend_env)
# cd $(OPENAPI) && yarn build
# yarn install
# @-rm -rf $(BUNDLE)
# @-mkdir $(BUNDLE)
# yarn build
# @yarn run sass -s \
# compressed templates/main.scss \
# ./static/cache/bundle/css/main.css
# @yarn run sass -s \
# compressed templates/mobile.scss \
# ./static/cache/bundle/css/mobile.css
# @yarn run sass -s \
# compressed templates/widget/main.scss \
# ./static/cache/bundle/css/widget.css
# @./scripts/librejs.sh
# @./scripts/cachebust.sh
lint: ## Lint codebase
cargo fmt -v --all -- --emit files
cargo clippy --workspace --tests --all-features
#yarn lint
#cd $(OPENAPI)&& yarn test
migrate: ## Run database migrations
$(call run_migrations)
migrate.dev: ## Run database migrations during development
$(call run_dev_migrations)
release: ## Build app with release optimizations
cargo build --release
run: ## Run app in debug mode
cargo run
db.sqlx.offline: ## prepare sqlx offline data
cargo sqlx prepare \
--database-url=${DATABASE_URL} -- \
--all-features
test: ## Run all available tests
$(call test_core)
# ./scripts/tests.sh
test.cov.html: migrate ## Generate code coverage report in HTML format
cargo tarpaulin -t 1200 --out Html
test.cov.xml: migrate ## Generate code coverage report in XML format
cargo tarpaulin -t 1200 --out Xml
test.core: ## Run all core tests
$(call test_core)
#test.frontend: ## Run frontend tests
# $(call test_frontend)
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}'