私は次のMakefileを持っています:
#runs the working directory unit tests
test:
@NODE_ENV=test; \
mocha --ignore-leaks $(shell find ./test -name \*test.js);
#deploys working directory
deploy:
@make test; \
make deploy-git; \
make deploy-servers;
#deploys working to git deployment branch
deploy-git:
@status=$$(git status --porcelain); \
if test "x$${status}" = x; then \
git branch -f deployment; \
git push origin deployment; \
echo "Done deploying to git deployment branch."; \
else \
git status; \
echo "Error: cannot deploy. Working directory is dirty."; \
fi
deploy-servers:
# for each server
# @DEPLOY_SERVER_IP = "127.0.0.1"; \
# make deploy-server
#deploy-server:
# connect to this server with ssh
# check if app is already running
# stop the app on the server if already running
# set working directory to app folder
# update deployment git branch
# use git to move head to deployment branch
# start app again
deploy-servers
とdeploy-server
は今のところ単なるダミーであることに注意してください。これは、deploy
コマンドが実行する必要があることです。
- テストを実行し(
make test
)、失敗したら終了します - 現在のヘッドをデプロイメントブランチにプッシュし(
make deploy-git
)、失敗したら終了します - サーバー上のデプロイメントブランチをプルする(
make deploy-servers
)
これは、Makefileで次のように確認できます。
deploy:
@make test; \
make deploy-git; \
make deploy-servers;
問題は、失敗したときに実行されないようにする方法と、テストが失敗したときまたは失敗したときにmake deploy-git
実行されないようにする方法がわからないことです。make test
make deploy-servers
make deploy-git
これを行う明確な方法はありますか、それともシェルファイルを使用するか、通常のプログラミング言語でこれらのツールを作成する必要がありますか?