From 62438c607e9ddfc5d7f69e9c19365c94c14daf8d Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 19 Jul 2022 22:55:22 +0530 Subject: [PATCH] feat: setup CI --- .woodpecker.yml | 9 ++++ Makefile | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .woodpecker.yml create mode 100644 Makefile diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..6856410 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,9 @@ +pipeline: + backend: + image: rust + # environment: + # - DATABSE_URL=postgres://postgres:password@database:5432/postgres + commands: + - make test + - make coverage + # - make integration-test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4f9a569 --- /dev/null +++ b/Makefile @@ -0,0 +1,128 @@ +#BUNDLE = static/cache/bundle +#OPENAPI = docs/openapi +#CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets +# +#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 + +default: #frontend ## Build app in debug mode +# $(call cache_bust) + cargo build + +check: ## Check for syntax errors on all workspaces + cargo check --workspace --tests --all-features +# cd utils/cache-bust && cargo check --tests --all-features +# 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 + @cargo clean + #@yarn cache clean + #@-rm $(CLEAN_UP) + +coverage: #migrate ## Generate code coverage report in HTML format +# $(call cache_bust) + cargo tarpaulin -t 1200 --out Html + +doc: ## Generate documentation + #yarn doc + cargo doc --no-deps --workspace --all-features + +docker: ## Build Docker image + docker build -t realaravinth/split:master -t realaravinth/split:latest . + +docker-publish: docker ## Build and publish Docker image + docker push realaravinth/split:master + docker push realaravinth/split:latest + +env: ## Setup development environtment + cargo fetch + #$(call frontend_env) + +#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 + +#frontend-test: ## Run frontend tests +# cd $(OPENAPI)&& yarn test +# yarn test + +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 +# cd db/db-migrations/ && \ +# DATABASE_URL=${POSTGRES_DATABASE_URL} cargo run + +release: #frontend ## Build app with release optimizations + #$(call cache_bust) + cargo build --release + +run: #frontend ## Run app in debug mode + cargo run + + +#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-postgres && cargo sqlx prepare \ +# --database-url=${POSTGRES_DATABASE_URL} -- \ +# --all-features +## cd db/db-sqlx-sqlite/ \ +## && DATABASE_URL=${SQLITE_DATABASE_URL} cargo sqlx prepare +# +#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 + cargo test --all-features --no-fail-fast +# $(call cache_bust) +# 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) + 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}'