Skip to content

Instantly share code, notes, and snippets.

@cierzniak
Last active November 24, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cierzniak/933ca993d92d921a86bfb307339c4a31 to your computer and use it in GitHub Desktop.
Save cierzniak/933ca993d92d921a86bfb307339c4a31 to your computer and use it in GitHub Desktop.
Monorepo with separate testing suites on pre-commit hook
.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
#!/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