mCaptcha/Makefile

214 lines
5.2 KiB
Makefile
Raw Normal View History

BUNDLE = static/cache/bundle
OPENAPI = docs/openapi
CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
2023-06-27 15:14:08 +05:30
define deploy_dependencies ## deploy dependencies
@-docker create --name ${db} \
2023-06-27 15:14:08 +05:30
-e POSTGRES_PASSWORD=password \
-p 5432:5432 \
postgres
@-docker create \
2023-06-27 15:14:08 +05:30
-p 3306:3306 \
--name ${mdb} \
--env MARIADB_USER=maria \
--env MARIADB_PASSWORD=password \
--env MARIADB_ROOT_PASSWORD=password \
--env MARIADB_DATABASE=maria \
mariadb:latest
@-docker create \
2023-06-27 15:14:08 +05:30
-p 6379:6379 \
--name mcaptcha-cache \
mcaptcha/cache:latest
docker start ${db}
docker start ${mdb}
docker start mcaptcha-cache
endef
define run_migrations ## run database migrations
cd db/db-migrations/ && cargo run
endef
2023-06-27 19:46:54 +05:30
define run_dev_migrations ## run database migrations
cd db/db-sqlx-maria/ && \
DATABASE_URL=${MARIA_DATABASE_URL} sqlx migrate run
cd db/db-sqlx-postgres/ && \
DATABASE_URL=${POSTGRES_DATABASE_URL} sqlx migrate run
endef
2021-12-16 15:55:46 +05:30
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
cd $(OPENAPI)&& yarn test
yarn test
endef
define test_db_sqlx_postgres
cd db/db-sqlx-postgres &&\
DATABASE_URL=${POSTGRES_DATABASE_URL}\
cargo test --no-fail-fast
endef
define test_db_sqlx_maria
cd db/db-sqlx-maria &&\
DATABASE_URL=${MARIA_DATABASE_URL}\
cargo test --no-fail-fast
endef
define test_core
cargo test --no-fail-fast
endef
2021-11-29 17:32:33 +05:30
default: frontend ## Build app in debug mode
2022-05-27 18:52:41 +05:30
$(call cache_bust)
2021-11-29 17:32:33 +05:30
cargo build
2021-04-08 15:49:55 +05:30
2022-05-08 20:02:48 +05:30
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 20:02:48 +05:30
cd db/db-migrations && cargo check --tests --all-features
cd db/db-sqlx-postgres &&\
DATABASE_URL=${POSTGRES_DATABASE_URL}\
cargo check
cd db/db-sqlx-maria &&\
DATABASE_URL=${MARIA_DATABASE_URL}\
cargo check
2022-05-08 20:02:48 +05:30
cd db/db-core/ && cargo check
cache-bust: ## Run cache buster on static assets
$(call cache_bust)
clean: ## Delete build artifacts
2021-07-15 15:27:01 +05:30
@cargo clean
@yarn cache clean
@-rm $(CLEAN_UP)
2021-07-07 21:10:15 +05:30
coverage: migrate ## Generate code coverage report in HTML format
$(call cache_bust)
2021-07-07 21:10:15 +05:30
cargo tarpaulin -t 1200 --out Html
2021-04-08 15:49:55 +05:30
doc: ## Generate documentation
#yarn doc
2021-04-08 15:49:55 +05:30
cargo doc --no-deps --workspace --all-features
2021-04-09 15:03:50 +05:30
docker: ## Build Docker image
2021-07-07 21:10:15 +05:30
docker build -t mcaptcha/mcaptcha:master -t mcaptcha/mcaptcha:latest .
docker-publish: docker ## Build and publish Docker image
2021-07-07 21:10:15 +05:30
docker push mcaptcha/mcaptcha:master
docker push mcaptcha/mcaptcha:latest
env: ## Setup development environtment
cargo fetch
2021-12-16 15:55:46 +05:30
$(call frontend_env)
2023-06-27 15:14:08 +05:30
env.db: ## Deploy dependencies
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
env.db.recreate: ## Deploy dependencies from scratch
@-docker rm -f ${db}
@-docker rm -f ${mdb}
@-docker rm -f mcaptcha-cache
$(call deploy_dependencies)
sleep 5
$(call run_migrations)
2021-12-16 15:55:46 +05:30
frontend-env: ## Install frontend deps
$(call frontend_env)
2021-12-16 15:55:46 +05:30
frontend: ## Build frontend
$(call frontend_env)
cd $(OPENAPI) && yarn build
yarn install
@-rm -rf $(BUNDLE)
@-mkdir $(BUNDLE)
2021-04-09 14:21:43 +05:30
yarn build
2022-05-07 19:42:49 +05:30
@yarn run sass -s \
compressed templates/main.scss \
./static/cache/bundle/css/main.css
2022-05-07 19:42:49 +05:30
@yarn run sass -s \
compressed templates/mobile.scss \
./static/cache/bundle/css/mobile.css
2022-05-07 19:42:49 +05:30
@yarn run sass -s \
compressed templates/widget/main.scss \
./static/cache/bundle/css/widget.css
2021-11-30 18:45:02 +05:30
@./scripts/librejs.sh
@./scripts/cachebust.sh
2021-04-08 15:49:55 +05:30
lint: ## Lint codebase
2021-10-08 15:55:53 +05:30
cargo fmt -v --all -- --emit files
cargo clippy --workspace --tests --all-features
yarn lint
cd $(OPENAPI)&& yarn test
2021-10-08 15:55:53 +05:30
migrate: ## Run database migrations
2023-06-27 15:14:08 +05:30
$(call run_migrations)
2021-04-08 15:49:55 +05:30
2023-06-27 19:46:54 +05:30
migrate.dev: ## Run database migrations during development
$(call run_dev_migrations)
release: frontend ## Build app with release optimizations
$(call cache_bust)
2021-04-08 15:49:55 +05:30
cargo build --release
2021-11-29 17:32:33 +05:30
run: frontend ## Run app in debug mode
$(call cache_bust)
2021-11-29 17:32:33 +05:30
cargo run
2022-05-11 13:27:42 +05:30
db.sqlx.offline: ## prepare sqlx offline data
2022-05-27 18:52:41 +05:30
cd db/db-sqlx-postgres && cargo sqlx prepare \
--database-url=${POSTGRES_DATABASE_URL} -- \
--all-features
cd db/db-sqlx-maria && cargo sqlx prepare \
--database-url=${MARIA_DATABASE_URL} -- \
--all-features
2022-05-11 13:27:42 +05:30
test.frontend: ## Run frontend tests
$(call test_frontend)
test: frontend ## Run all available tests
$(call test_frontend)
$(call cache_bust)
$(call test_db_sqlx_postgres)
$(call test_db_sqlx_maria)
$(call test_core)
cargo test --no-fail-fast
# ./scripts/tests.sh
test.core: ## Run all core tests
$(call test_core)
test.db: ## Run all database driver tests
$(call test_db_sqlx_postgres)
$(call test_db_sqlx_maria)
test.db.pg: ## Run Postgres database driver tests
$(call test_db_sqlx_postgres)
test.db.maria: ## Run Maria database driver tests
$(call test_db_sqlx_maria)
test.integration: ## run integration tests with nightwatch.js
./scripts/integration.sh
xml-test-coverage: migrate ## Generate code coverage report in XML format
$(call cache_bust)
2021-07-07 21:10:15 +05:30
cargo tarpaulin -t 1200 --out Xml
2021-04-08 15:49:55 +05:30
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}'