1 Star 0 Fork 309

fei / APITable

forked from APITable / APITable 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Makefile 16.55 KB
一键复制 编辑 原始数据 按行查看 历史
Shawn Deng 提交于 2023-05-16 16:05 . feat: upgrade liquibase version (#801)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
.DEFAULT_GOAL := help
PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash
ifndef UID
UID := $(shell id -u)
export UID
endif
ifndef GID
GID := $(shell id -g)
export GID
endif
ifndef ENV_FILE
ENV_FILE := .env
export ENV_FILE
endif
ifndef DEVENV_FILE
DEVENV_FILE := .env.devenv
export DEVENV_FILE
endif
ifndef DATA_PATH
DATA_PATH := ./
export DATA_PATH
endif
ifndef DEVENV_PROJECT_NAME
DEVENV_PROJECT_NAME := apitable-devenv
export DEVENV_PROJECT_NAME
endif
_DATAENV := docker compose --env-file $$ENV_FILE -p $$DEVENV_PROJECT_NAME -f docker-compose.yaml -f docker-compose.dataenv.yaml
_DEVENV := docker compose --env-file $$ENV_FILE -p $$DEVENV_PROJECT_NAME -f docker-compose.devenv.yaml
OS_NAME := $(shell uname -s | tr A-Z a-z)
ifeq ($(OS_NAME), darwin)
# macOS don't set user for some priviliges problem
RUNNER := $(_DEVENV) run --rm
else
# Not found
RUNNER := $(_DEVENV) run --rm --user $$UID:$$GID
endif
BUILDER := docker buildx bake
ttt:
echo $(OS_NAME)
echo $(RUNNER)
SEMVER3 := $(shell cat .version)
define ANNOUNCE_BODY
_____ _____ _______ _ _
/\ | __ \_ _|__ __| | | | |
/ \ | |__) || | | | __ _| |__ | | ___
/ /\ \ | ___/ | | | |/ _` | '_ \| |/ _ \
/ ____ \| | _| |_ | | (_| | |_) | | __/
/_/ \_\_| |_____| |_|\__,_|_.__/|_|\___|
APITable Makefile $(SEMVER3)
================================================================
endef
export ANNOUNCE_BODY
# define standard colors
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RESET := ""
endif
################################ build
build: ## build
make build-local
build-local:
make _build-java
make _build-room
make _build-web
_build-web:
yarn workspaces focus @apitable/core @apitable/i18n-lang @apitable/icons @apitable/components @apitable/widget-sdk @apitable/datasheet root
yarn build:dst
_build-java:
cd backend-server && ./gradlew build -x test --stacktrace
_build-core: ## build core
yarn workspaces focus @apitable/core @apitable/i18n-lang root
yarn build:i18n
yarn build:core
_build-room: ## build room server
yarn workspaces focus @apitable/room-server root
yarn build:sr
################################ test
test: ## do test, unit tests, integration tests and so on.
make _test-ut-core-cov
test-e2e: ## start integration tests
yarn cy:run
test-e2e-open: ## start and debug integration tests
yarn cy:open
###### 【core unit test】 ######
_test-ut-core:
make _build-core
yarn test:core
_test-ut-core-cov:
make _build-core
yarn test:core:cov
###### 【core unit test】 ######
###### 【room server unit test】 ######
SIKP_INITDB=false
_test_init_db:
@echo "${YELLOW}init-db initializing..${RESET}"
docker compose -f docker-compose.unit-test.yaml build test-init-db
docker compose -f docker-compose.unit-test.yaml run --rm test-init-db
@echo "${GREEN}initialize unit test db completed...${RESET}"
_test_clean: ## clean the docker in test step
docker rm -fv $$(docker ps -a --filter "name=test-.*" --format "{{.ID}}") || true
_test_docker_mysql: ## only run mysql container
docker compose -f docker-compose.unit-test.yaml up -d test-mysql
_test_dockers: ## run depends container in test step
docker compose -f docker-compose.unit-test.yaml up -d test-mysql ;\
docker compose -f docker-compose.unit-test.yaml up -d test-redis ;\
docker compose -f docker-compose.unit-test.yaml up -d test-rabbitmq
test-ut-room-local:
make _test_clean
docker compose -f docker-compose.unit-test.yaml up -d test-redis test-mysql test-rabbitmq
ifeq ($(SIKP_INITDB),false)
sleep 20
make _test_init_db
endif
make _build-room
MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 MYSQL_USERNAME=apitable MYSQL_PASSWORD=password MYSQL_DATABASE=apitable_test MYSQL_USE_SSL=false \
DATABASE_TABLE_PREFIX=apitable_ \
REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_DB=4 REDIS_PASSWORD= \
RABBITMQ_HOST=127.0.0.1 RABBITMQ_PORT=5672 RABBITMQ_USERNAME=apitable RABBITMQ_PASSWORD=password \
INSTANCE_COUNT=1 APPLICATION_NAME=NEST_REST_SERVER \
yarn test:ut:room
make _test_clean
test-ut-room-docker:
@echo "${LIGHTPURPLE}Working dir, $(shell pwd)${RESET}"
@echo "${LIGHTPURPLE}$$(docker compose version)${RESET}"
make _test_clean
make _test_dockers
sleep 20
make _test_init_db
docker compose -f docker-compose.unit-test.yaml build unit-test-room
docker compose -f docker-compose.unit-test.yaml run --rm \
-e MYSQL_HOST=test-mysql \
-e REDIS_HOST=test-redis \
-e RABBITMQ_HOST=test-rabbitmq \
unit-test-room yarn test:ut:room:cov
@echo "${GREEN}finished unit test, clean up images...${RESET}"
_generate_room_coverage:
cd packages/room-native-api
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
_clean_room_coverage:
if [ -d "./packages/room-server/coverage" ]; then \
sudo chown -R $(shell id -u):$(shell id -g) ./packages/room-server/coverage; \
fi
if [ -d "./packages/room-native-api/coverage" ]; then \
sudo chown -R $(shell id -u):$(shell id -g) ./packages/room-native-api/coverage; \
fi
if [ -d "./packages/room-native-api/target" ]; then \
sudo chown -R $(shell id -u):$(shell id -g) ./packages/room-native-api/target; \
fi
make _test_clean
rm -fr ./packages/room-server/coverage || true
rm -fr ./packages/room-native-api/coverage || true
rm -fr ./packages/room-native-api/target || true
###### 【backend server unit test】 ######
test-ut-backend-docker:
@echo "$$(docker compose version)"
make _test_dockers
sleep 20
make _test_init_db
make test-ut-backend-run
@echo "${GREEN}finished unit test, clean up images...${RESET}"
make _test_clean
test-ut-backend-run:
cd backend-server ;\
DATABASE_TABLE_PREFIX=apitable_ \
MYSQL_HOST=127.0.0.1 \
MYSQL_PORT=3306 \
MYSQL_USERNAME=apitable \
MYSQL_PASSWORD=password \
MYSQL_DATABASE=apitable_test \
REDIS_HOST=127.0.0.1 \
REDIS_PORT=6379 \
REDIS_PASSWORD= \
RABBITMQ_HOST=127.0.0.1 \
RABBITMQ_PORT=5672 \
RABBITMQ_USERNAME=apitable \
RABBITMQ_PASSWORD=password \
./gradlew testCodeCoverageReport --stacktrace
###### 【backend server unit test】 ######
###### 【init-db test】 ######
test-init-db-docker:
@echo "${LIGHTPURPLE}Working dir, $(shell pwd)${RESET}"
@echo "${LIGHTPURPLE}$$(docker compose version)${RESET}"
make _test_clean
make _test_docker_mysql
sleep 20
make _test_init_db
@echo "${GREEN}finished testing, clean up images...${RESET}"
buildpush-docker: ## build all and push all to hub.docker.io registry
echo $$APITABLE_DOCKER_HUB_TOKEN | docker login -u apitable --password-stdin || true;\
$(BUILDER) $(target) --push
.PHONY: build
build-docker: ## build all containers
$(BUILDER) $(target) --load
.PHONY: _build-init-db
_build-docker-init-db:
$(BUILDER) init-db
.PHONY: _build-backend-server
_build-docker-backend-server:
$(BUILDER) backend-server
###### development environtments ######
define RUN_LOCAL_TXT
Which service do you want to start run?
1) backend-server
2) room-server
3) web-server
endef
export RUN_LOCAL_TXT
define RUN_PERF_TXT
Which service do you want to start run?
1) room-server / production mode / Clinic.js flamegraph
endef
export RUN_PERF_TXT
_check_env: ## check if .env files exists
@FILE=$$ENV_FILE ;\
if [ ! -f "$$FILE" ]; then \
echo "$$FILE does not exist. Please 'make env' first" ;\
exit 1 ;\
fi
run: _check_env ## run local code to development environemnt with docker env
make run-local
.PHONY: run-local
run-local: ## run services with local programming language envinroment
@echo "$$RUN_LOCAL_TXT"
@read -p "ENTER THE NUMBER: " SERVICE ;\
if [ "$$SERVICE" = "1" ]; then make _run-local-backend-server; fi ;\
if [ "$$SERVICE" = "2" ]; then make _run-local-room-server; fi ;\
if [ "$$SERVICE" = "3" ]; then make _run-local-web-server; fi
.PHONY: run-perf
run-perf: ## run services with local programming language envinroment for performance profiling
@echo "$$RUN_PERF_TXT"
@read -p "ENTER THE NUMBER: " SERVICE ;\
if [ "$$SERVICE" = "1" ]; then make _run-perf-flame-local-room-server; fi
_run-local-backend-server:
source scripts/export-env.sh $$ENV_FILE;\
source scripts/export-env.sh $$DEVENV_FILE;\
cd backend-server ;\
./gradlew build -x test ;\
MYSQL_HOST=127.0.0.1 \
REDIS_HOST=127.0.0.1 \
RABBITMQ_HOST=127.0.0.1 \
java -jar application/build/libs/application.jar
_run-local-room-server:
source scripts/export-env.sh $$ENV_FILE;\
source scripts/export-env.sh $$DEVENV_FILE;\
yarn start:room-server
_run-perf-flame-local-room-server:
source scripts/export-env.sh $$ENV_FILE;\
source scripts/export-env.sh $$DEVENV_FILE;\
yarn start:room-server:perf:flame
_run-local-web-server:
source scripts/export-env.sh $$ENV_FILE;\
source scripts/export-env.sh $$DEVENV_FILE;\
rm -rf packages/datasheet/web_build;\
yarn sd
define DEVENV_TXT
Which devenv do you want to start run?
0) UP ALL
1) backend-server
2) room-server
3) web-server
endef
export DEVENV_TXT
.PHONY: devenv
devenv: ## debug all devenv services with docker compose up -d
@echo "$$DEVENV_TXT"
@read -p "ENTER THE NUMBER: " DEVENV_NUMBER ;\
if [ "$$DEVENV_NUMBER" = "0" ]; then make devenv-up; fi ;\
if [ "$$DEVENV_NUMBER" = "1" ]; then make devenv-backend-server; fi ;\
if [ "$$DEVENV_NUMBER" = "2" ]; then make devenv-room-server; fi ;\
if [ "$$DEVENV_NUMBER" = "3" ]; then make devenv-web-server; fi
.PHONY: devenv-up
devenv-up:
$(_DEVENV) up -d
.PHONY: devenv-down
devenv-down: ## debug all devenv services with docker compose up -d
$(_DEVENV) down -v --remove-orphans
devenv-logs: ## follow all devenv services logs
$(_DEVENV) logs -f
devenv-ps:
$(_DEVENV) ps
.PHONY: devenv-backend-server
devenv-backend-server:
$(RUNNER) backend-server java -jar application/build/libs/application.jar
.PHONY: devenv-web-server
devenv-web-server:
$(RUNNER) web-server sh -c "yarn install && yarn sd"
.PHONY: devenv-room-server
devenv-room-server:
$(RUNNER) room-server yarn start:room-server
.PHONY: install
install: install-local
@echo 'Install Finished'
.PHONY: install-local
install-local: ## install all dependencies with local programming language environment
yarn install && yarn build:pre
cd backend-server && ./gradlew build -x test --stacktrace
.PHONY: install-docker
install-docker: _install-docker-web-server _install-docker-backend-server _install-docker-room-server ## install all dependencies with docker devenv
@echo 'Install Finished'
.PHONY: _install-docker-backend-server
_install-docker-backend-server:
$(RUNNER) backend-server ./gradlew build -x test
.PHONY: _install-docker-web-server
_install-docker-web-server:
$(RUNNER) web-server sh -c "yarn install && yarn build:dst:pre"
.PHONY: _install-docker-room-server
_install-docker-room-server:
$(RUNNER) room-server sh -c "yarn install && yarn build:pre"
.PHONY:
clean: ## clean and delete git ignore and dirty files
git clean -fxd
###### buildpush ######
# bumpversion
.PHONY: patch
patch: # bump version number patch
docker run --rm -it --user $(shell id -u):$(shell id -g) -v "$(shell pwd):/app" apitable/bumpversion:latest bumpversion patch
.PHONY: minor
minor: # bump version number patch
docker run --rm -it --user $(shell id -u):$(shell id -g) -v "$(shell pwd):/app" apitable/bumpversion:latest bumpversion minor
.PHONY: major
major: # bump version number patch
docker run --rm -it --user $(shell id -u):$(shell id -g) -v "$(shell pwd):/app" apitable/bumpversion:latest bumpversion major
### data environement
.PHONY: dataenv
dataenv: _check_env
make dataenv-up
DATAENV_SERVICES := mysql minio redis rabbitmq init-db init-appdata
.PHONY: dataenv-up
dataenv-up: _dataenv-volumes
$(_DATAENV) up -d $(DATAENV_SERVICES)
_dataenv-volumes: ## create data folder with current user permissions
mkdir -p $$DATA_PATH/.data/mysql \
$$DATA_PATH/.data/minio/data \
$$DATA_PATH/.data/minio/config \
$$DATA_PATH/.data/redis \
$$DATA_PATH/.data/rabbitmq \
dataenv-down:
$(_DATAENV) down -v --remove-orphans
dataenv-ps:
$(_DATAENV) ps
dataenv-logs:
$(_DATAENV) logs -f
### production environment
.PHONY: up
up: _dataenv-volumes ## startup the application
@echo "Please execute 'make pull' first to download & upgrade all images to your machine."
docker compose up -d
.PHONY: down
down: ## shutdown the application
docker compose down -v --remove-orphans
.PHONY:ps
ps: ## docker compose ps
docker compose ps
### docker stuffs
.PHONY: pull
pull: ## pull all containers and ready to up
docker compose pull
######################################## init-db
INIT_DB_DOCKER_PATH=apitable/init-db
db-plan: ## init-db dry update
cd init-db ;\
docker build -f Dockerfile . --tag=${INIT_DB_DOCKER_PATH}
docker run --rm --env-file $$ENV_FILE -e ACTION=updateSQL ${INIT_DB_DOCKER_PATH}
db-apply: ## init-db update database structure (use .env)
cd init-db ;\
docker build -f Dockerfile . --tag=${INIT_DB_DOCKER_PATH}
docker run --rm --env-file $$ENV_FILE -e ACTION=update ${INIT_DB_DOCKER_PATH}
changelog: ## make changelog with github api
@read -p "GITHUB_TOKEN: " GITHUB_TOKEN;\
read -p "FROM[default:latest-tag]: " GIT_FROM ;\
read -p "TO[default:HEAD]: " GIT_TO ;\
if [ "$$GIT_FROM" = "" ]; then GIT_FROM=$(shell git describe --tags $$(git rev-list --tags --max-count=1)) ; fi ;\
if [ "$$GIT_TO" = "" ]; then GIT_TO=HEAD ; fi ;\
echo "" ;\
echo "FROM: $$GIT_FROM" ;\
echo "TO: $$GIT_TO" ;\
npx github-changelog-builder --token $$GITHUB_TOKEN -o apitable -r apitable -f $$GIT_FROM -t $$GIT_TO -a CHANGELOG.md
.PHONY: l10n-apitable-ce
l10n-apitable-ce: move_setting_file
bash ./scripts/language-generate.sh ./packages/i18n-lang/src ./packages/l10n/gen ./packages/l10n/base y ./packages/i18n-lang/src ./ ./packages/l10n/l10n-apitable-ce
bash ./scripts/l10n.sh ./packages/i18n-lang/src ./packages/l10n/gen ./packages/l10n/base ./packages/l10n/l10n-apitable-ce ./
move_setting_file:
@if [ -f ./packages/datasheet/.env.development ]; then \
mv -f ./packages/datasheet/.env.development ./packages/datasheet/.env.development.origin; \
fi
@if [ -f ./packages/i18n-lang/src/config/strings.json ]; then \
mv -f ./packages/i18n-lang/src/config/strings.json ./packages/i18n-lang/src/config/strings.origin.json; \
fi
@if [ -f ./packages/i18n-lang/src/config/language.manifest.json ]; then \
mv -f ./packages/i18n-lang/src/config/language.manifest.json ./packages/i18n-lang/src/config/language.manifest.origin.json; \
fi
@if [ -f ./packages/core/src/config/api_tip_config.auto.json ]; then \
mv -f ./packages/core/src/config/api_tip_config.auto.json ./packages/core/src/config/api_tip_config.auto.origin.json; \
fi
@if [ -f ./packages/core/src/config/emojis.auto.json ]; then \
mv -f ./packages/core/src/config/emojis.auto.json ./packages/core/src/config/emojis.auto.origin.json; \
fi
@if [ -f ./enterprise/core/config/billing.auto.json ]; then \
mv -f ./enterprise/core/config/billing.auto.json ./enterprise/core/config/billing.auto.origin.json; \
fi
@if [ -f ./packages/core/src/config/system_config.auto.json ]; then \
mv -f ./packages/core/src/config/system_config.auto.json ./packages/core/src/config/system_config.auto.origin.json; \
fi
@if [ -f ./backend-server/application/src/main/resources/sysconfig/i18n/exception/messages.properties ]; then \
mv -f ./backend-server/application/src/main/resources/sysconfig/i18n/exception/messages.properties ./backend-server/application/src/main/resources/sysconfig/i18n/exception/messages.properties.origin; \
fi
@if [ -f ./backend-server/application/src/main/resources/sysconfig/notification.json ]; then \
mv -f ./backend-server/application/src/main/resources/sysconfig/notification.json ./backend-server/application/src/main/resources/sysconfig/notification.origin.json; \
fi
### help
.PHONY: search
search:
@echo " "
@read -p "Search Command:" s; \
echo && grep -E "$$s.*?## .*" $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}';
@echo ' ';
@read -p "What do you want?>>" command; \
make $$command;
.PHONY: help
help:
@echo "$$ANNOUNCE_BODY"
@echo ' ';
@grep -E '^[0-9a-zA-Z-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}';
@echo ' '
@read -p "What do you want?>> " command; \
make $$command;
TypeScript
1
https://gitee.com/virtualsoul/APITable.git
git@gitee.com:virtualsoul/APITable.git
virtualsoul
APITable
APITable
develop

搜索帮助

53164aa7 5694891 3bd8fe86 5694891