#Makefile target for running tests and git add/commit/push

Here is a makefile target for running tests (in this example pytest), and if the tests pass also running git add/commit/push

I created this makefile target as an alternative to running tests on CI or using git-hooks. I'd appreciate any #feedback you can give on this, as the idea of running tests in this way is new to me (and also i'm pretty new to makefiles)

.PHONY: git-push
git-push:
    test -n "$(MESSAGE)" || (echo "MESSAGE not set, exiting"; exit 1)
    git status
    pytest || (echo "Test failed before running git add/commit/push" && exit 1)
    git add --all
    git commit -m "$(MESSAGE)"
    git push

PS: Thank you to @Miloslav Číž for inspiring me to simplify my way of working like this

#programming

4