From cf8e83d6ab07da3e37b346c124529bc89226c277 Mon Sep 17 00:00:00 2001 From: Tianzi Cai Date: Mon, 14 Jun 2021 14:33:03 -0700 Subject: [PATCH] test: presubmit against Lite samples (#713) --- .github/sync-repo-settings.yaml | 2 + .kokoro/build.sh | 35 +++++++++++++++++ .../presubmit-against-pubsublite-samples.cfg | 38 +++++++++++++++++++ synth.py | 2 + 4 files changed, 77 insertions(+) create mode 100644 .kokoro/presubmit/presubmit-against-pubsublite-samples.cfg diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 8ae7a9303..253d63e15 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -17,6 +17,7 @@ branchProtectionRules: - units (8) - units (11) - 'Kokoro - Test: Integration' + - 'Kokoro - Against Pub/Sub Lite samples' - cla/google - pattern: 1.111.0-sp isAdminEnforced: true @@ -33,6 +34,7 @@ branchProtectionRules: - units (8) - units (11) - 'Kokoro - Test: Integration' + - 'Kokoro - Against Pub/Sub Lite samples' - cla/google permissionRules: - team: yoshi-admins diff --git a/.kokoro/build.sh b/.kokoro/build.sh index e72b325e8..476785ec3 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -77,6 +77,41 @@ samples) SAMPLES_DIR=samples/snapshot fi + if [[ -f ${SAMPLES_DIR}/pom.xml ]] + then + for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do + [[ -f "$FILE" ]] || continue + source "$FILE" + done + + pushd ${SAMPLES_DIR} + mvn -B \ + -Penable-samples \ + -ntp \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify + RETURN_CODE=$? + popd + else + echo "no sample pom.xml found - skipping sample tests" + fi + ;; +presubmit-against-pubsublite-samples) + ## cd to the directory one level above the root of the repo + cd ${scriptDir}/../.. + git clone https://github.com/googleapis/java-pubsublite.git + pushd java-pubsublite/ + + SAMPLES_DIR=samples + # Only run ITs in in snippets/ on presubmit PRs. + if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]] + then + SAMPLES_DIR=samples/snippets + fi + if [[ -f ${SAMPLES_DIR}/pom.xml ]] then for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do diff --git a/.kokoro/presubmit/presubmit-against-pubsublite-samples.cfg b/.kokoro/presubmit/presubmit-against-pubsublite-samples.cfg new file mode 100644 index 000000000..7efa00b77 --- /dev/null +++ b/.kokoro/presubmit/presubmit-against-pubsublite-samples.cfg @@ -0,0 +1,38 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} + +env_vars: { + key: "JOB_TYPE" + value: "presubmit-against-pubsublite-samples" +} + +# TODO: remove this after we've migrated all tests and scripts +env_vars: { + key: "GCLOUD_PROJECT" + value: "java-docs-samples-testing" +} + +env_vars: { + key: "GOOGLE_CLOUD_PROJECT" + value: "java-docs-samples-testing" +} + +env_vars: { + key: "GOOGLE_CLOUD_PROJECT_NUMBER" + value: "779844219229" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "secret_manager/java-docs-samples-service-account" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-docs-samples-service-account" +} \ No newline at end of file diff --git a/synth.py b/synth.py index 8b63ce45a..991fba4db 100644 --- a/synth.py +++ b/synth.py @@ -524,4 +524,6 @@ java.common_templates(excludes=[ ".github/workflows/samples.yaml", + ".kokoro/build.sh", + ".github/sync-repo-settings.yaml", ])