Skip to content

Commit

Permalink
[ggj][engx] build: run pre-commit when goldens have changed (#439)
Browse files Browse the repository at this point in the history
* fix: support non-name fields with res-refs in resname def parsing

* fix: add workaround for missing default_host and oauth_scopes annotation

* fix: clarify LRO parsing error messages

* feat: support deeply-nested types in AST and proto message parsing

* fix: prevent resname tokens from matching subcomponents

* fix: use TypeParser for proto message parsing

* fix: use generic types in field instantiation in ServiceClientTest

* fix: prevent descension into map types in nested message parsing

* fix: merge master

* fix: use both map generics in ServiceClientTest codegen

* fix: dir structure of generated files

* test: add asset API gradle pkg rules

* fix: remove unused dep

* test: add logging integration target and goldens, consolidate rules

* fix: fix asset_java_gapic build

* fix: fix test src packaging, update integration goldens

* fix: pass all tokens to instansiate in resname 1-pattern case

* fix: update goldens

* fix: update goldens

* build: add all integration tests to pre-commit hook

* build: run pre-commit when goldens have changed
  • Loading branch information
miraleung authored Oct 31, 2020
1 parent 2899c40 commit 5247a6b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ fi
# Check only the staged files.
NUM_TOTAL_FILES_CHANGED=$(git diff --cached --name-only | wc -l)
NUM_JAVA_FILES_CHANGED=$(git diff --cached --name-only "*.java" | wc -l)
NUM_UNIT_GOLDEN_FILES_CHANGED=$(git diff --cached --name-only "src/test/*/*.golden" | wc -l)
NUM_INTEGRATION_GOLDEN_FILES_CHANGED=$(git diff --cached --name-only "test/integration/goldens/*/*.golden" | wc -l)
NUM_INTEGRATION_BAZEL_FILES_CHANGED=$(git diff --cached --name-only "test/integration/*/BUILD.bazel" | wc -l)
NUM_BAZEL_FILES_CHANGED=$(git diff --cached --name-only "*BUILD.bazel" | wc -l)

if [ $NUM_TOTAL_FILES_CHANGED -le 0 ]
Expand Down Expand Up @@ -102,27 +105,29 @@ then
fi

# Check unit tests.
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ]
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ]
then
echo_status "Checking unit tests..."
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //src/test/...
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
echo_error "Tests failed." "Please fix them and try again."
echo_error "Unit tests failed." "Please fix them and try again."
exit 1
fi
fi

# Check integration tests.
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ]
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \
|| [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \
|| [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ]
then
echo_status "Checking integration tests..."
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/...
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
echo_error "Tests failed." "Please fix them and try again."
echo_error "Integration tests failed." "Please fix them and try again."
exit 1
fi
fi
Expand Down

0 comments on commit 5247a6b

Please sign in to comment.