mCaptcha/Makefile

129 lines
3.5 KiB
Makefile
Raw Normal View History

BUNDLE = static/cache/bundle
OPENAPI = docs/openapi
CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
2021-12-16 10:25:46 +00:00
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
2021-11-29 12:02:33 +00:00
default: frontend ## Build app in debug mode
2022-05-27 13:22:41 +00:00
$(call cache_bust)
2021-11-29 12:02:33 +00:00
cargo build
2021-04-08 10:19:55 +00:00
2022-05-08 14:32:48 +00:00
check: ## Check for syntax errors on all workspaces
cargo check --workspace --tests --all-features
cd utils/cache-bust && cargo check --tests --all-features
2022-05-08 14:32:48 +00:00
cd db/db-migrations && cargo check --tests --all-features
cd db/db-sqlx-postgres &&\
DATABASE_URL=${POSTGRES_DATABASE_URL}\
cargo check
cd db/db-core/ && cargo check
cache-bust: ## Run cache buster on static assets
$(call cache_bust)
clean: ## Delete build artifacts
2021-07-15 09:57:01 +00:00
@cargo clean
@yarn cache clean
@-rm $(CLEAN_UP)
2021-07-07 15:40:15 +00:00
coverage: migrate ## Generate code coverage report in HTML format
$(call cache_bust)
2021-07-07 15:40:15 +00:00
cargo tarpaulin -t 1200 --out Html
2021-04-08 10:19:55 +00:00
doc: ## Generate documentation
#yarn doc
2021-04-08 10:19:55 +00:00
cargo doc --no-deps --workspace --all-features
2021-04-09 09:33:50 +00:00
docker: ## Build Docker image
2021-07-07 15:40:15 +00:00
docker build -t mcaptcha/mcaptcha:master -t mcaptcha/mcaptcha:latest .
docker-publish: docker ## Build and publish Docker image
2021-07-07 15:40:15 +00:00
docker push mcaptcha/mcaptcha:master
docker push mcaptcha/mcaptcha:latest
env: ## Setup development environtment
cargo fetch
2021-12-16 10:25:46 +00:00
$(call frontend_env)
frontend-env: ## Install frontend deps
$(call frontend_env)
2021-12-16 10:25:46 +00:00
frontend: ## Build frontend
$(call frontend_env)
cd $(OPENAPI) && yarn build
yarn install
@-rm -rf $(BUNDLE)
@-mkdir $(BUNDLE)
2021-04-09 08:51:43 +00:00
yarn build
2022-05-07 14:12:49 +00:00
@yarn run sass -s \
compressed templates/main.scss \
./static/cache/bundle/css/main.css
2022-05-07 14:12:49 +00:00
@yarn run sass -s \
compressed templates/mobile.scss \
./static/cache/bundle/css/mobile.css
2022-05-07 14:12:49 +00:00
@yarn run sass -s \
compressed templates/widget/main.scss \
./static/cache/bundle/css/widget.css
2021-11-30 13:15:02 +00:00
@./scripts/librejs.sh
@./scripts/cachebust.sh
2021-04-08 10:19:55 +00:00
frontend-test: ## Run frontend tests
cd $(OPENAPI)&& yarn test
yarn test
2021-04-08 10:19:55 +00:00
lint: ## Lint codebase
2021-10-08 10:25:53 +00:00
cargo fmt -v --all -- --emit files
cargo clippy --workspace --tests --all-features
yarn lint
cd $(OPENAPI)&& yarn test
2021-10-08 10:25:53 +00:00
migrate: ## Run database migrations
cd db/db-migrations/ && \
DATABASE_URL=${POSTGRES_DATABASE_URL} cargo run
2021-04-08 10:19:55 +00:00
release: frontend ## Build app with release optimizations
$(call cache_bust)
2021-04-08 10:19:55 +00:00
cargo build --release
2021-11-29 12:02:33 +00:00
run: frontend ## Run app in debug mode
$(call cache_bust)
2021-11-29 12:02:33 +00:00
cargo run
2022-05-11 07:57:42 +00:00
sqlx-offline-data: ## prepare sqlx offline data
cargo sqlx prepare --database-url=${POSTGRES_DATABASE_URL} -- --bin mcaptcha \
--all-features
cd db/db-migrations && cargo sqlx prepare \
--database-url=${POSTGRES_DATABASE_URL} -- --bin db-migrations \
--all-features
2022-05-27 13:22:41 +00:00
cd db/db-sqlx-postgres && cargo sqlx prepare \
--database-url=${POSTGRES_DATABASE_URL} -- \
--all-features
2022-05-11 07:57:42 +00:00
# cd db/db-sqlx-sqlite/ \
# && DATABASE_URL=${SQLITE_DATABASE_URL} cargo sqlx prepare
2022-05-27 11:37:05 +00:00
test-db: ## run tests on database
cd db/db-sqlx-postgres &&\
DATABASE_URL=${POSTGRES_DATABASE_URL}\
cargo test --no-fail-fast
test: frontend-test frontend ## Run all available tests
$(call cache_bust)
2022-05-11 07:38:11 +00:00
cd db/db-sqlx-postgres &&\
DATABASE_URL=${POSTGRES_DATABASE_URL}\
cargo test --no-fail-fast
cargo test --all-features --no-fail-fast
# ./scripts/tests.sh
xml-test-coverage: migrate ## Generate code coverage report in XML format
$(call cache_bust)
2021-07-07 15:40:15 +00:00
cargo tarpaulin -t 1200 --out Xml
2021-04-08 10:19:55 +00:00
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}'