From 5247a6b2f6a66c730106eb4bddb990e79038a499 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Fri, 30 Oct 2020 23:06:45 -0700 Subject: [PATCH] [ggj][engx] build: run pre-commit when goldens have changed (#439) * 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 --- .githooks/pre-commit | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 14cc39fa11..efcd7f499c 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -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 ] @@ -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