Last active
November 24, 2019 18:46
-
-
Save cierzniak/933ca993d92d921a86bfb307339c4a31 to your computer and use it in GitHub Desktop.
Monorepo with separate testing suites on pre-commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: add-git-hooks test-backend test-frontend | |
add-git-hooks: | |
rm -rf .git/hooks | |
ln -sf ../_misc/hooks .git/hooks | |
test-backend: | |
docker rm back_test || true | |
docker build --file _misc/docker-test/backend/Dockerfile --tag back_test . | |
docker run --name=back_test back_test | |
test-frontend: | |
docker rm front_test || true | |
docker build --file _misc/docker-test/frontend/Dockerfile --tag front_test . | |
docker run --name=front_test front_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
BACKEND=0 | |
FRONTEND=0 | |
for FULL_PATH in $(git diff --cached --name-only --diff-filter=ACM); do | |
FOLDER=$(echo "${FULL_PATH}" | cut -d/ -f1) # Get only first folder | |
if [[ ${FOLDER} = 'backend' ]]; then BACKEND=1 | |
elif [[ ${FOLDER} = 'frontend' ]]; then FRONTEND=1 | |
fi | |
done | |
if [[ ${BACKEND} -eq 1 ]]; then make test-backend; fi | |
if [[ ${FRONTEND} -eq 1 ]]; then make test-frontend; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment