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