diff --git a/.circleci/config.yml b/.circleci/config.yml index 80dcf7e67..8af6a4d04 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -149,21 +149,24 @@ jobs: name: Decrypt credentials. command: | if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then - openssl aes-256-cbc -d -in .circleci/key.json.enc \ - -out .circleci/key.json \ - -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" + for encrypted_key in .circleci/*.json.enc; do + openssl aes-256-cbc -d -in $encrypted_key \ + -out $(echo $encrypted_key | sed 's/\.enc//') \ + -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" + done fi - run: *npm_install_and_link - run: name: Run system tests. command: npm run system-test environment: + GCLOUD_PROJECT: long-door-651 GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json - run: name: Remove unencrypted key. command: | if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then - rm .circleci/key.json + rm .circleci/*.json fi when: always publish_npm: diff --git a/.jsdoc.js b/.jsdoc.js index c4d03a646..9f229fda8 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,5 +1,5 @@ /*! - * Copyright 2017 Google Inc. All Rights Reserved. + * Copyright 2018 Google LLC. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2017 Google, Inc.', + copyright: 'Copyright 2018 Google, LLC.', includeDate: false, sourceFiles: false, systemName: '@google-cloud/spanner', diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg new file mode 100644 index 000000000..db454be4b --- /dev/null +++ b/.kokoro/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node10/common.cfg b/.kokoro/continuous/node10/common.cfg new file mode 100644 index 000000000..db454be4b --- /dev/null +++ b/.kokoro/continuous/node10/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node10/test.cfg b/.kokoro/continuous/node10/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/continuous/node6/common.cfg b/.kokoro/continuous/node6/common.cfg new file mode 100644 index 000000000..f0ad1bc23 --- /dev/null +++ b/.kokoro/continuous/node6/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:6-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node6/test.cfg b/.kokoro/continuous/node6/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/continuous/node8/common.cfg b/.kokoro/continuous/node8/common.cfg new file mode 100644 index 000000000..3f4eb316b --- /dev/null +++ b/.kokoro/continuous/node8/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node8/docs.cfg b/.kokoro/continuous/node8/docs.cfg new file mode 100644 index 000000000..e722d2748 --- /dev/null +++ b/.kokoro/continuous/node8/docs.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/docs.sh" +} diff --git a/.kokoro/continuous/node8/lint.cfg b/.kokoro/continuous/node8/lint.cfg new file mode 100644 index 000000000..629ea4ddf --- /dev/null +++ b/.kokoro/continuous/node8/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/lint.sh" +} diff --git a/.kokoro/continuous/node8/samples-test.cfg b/.kokoro/continuous/node8/samples-test.cfg new file mode 100644 index 000000000..a2c803457 --- /dev/null +++ b/.kokoro/continuous/node8/samples-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/samples-test.sh" +} diff --git a/.kokoro/continuous/node8/system-test.cfg b/.kokoro/continuous/node8/system-test.cfg new file mode 100644 index 000000000..8beea6587 --- /dev/null +++ b/.kokoro/continuous/node8/system-test.cfg @@ -0,0 +1,7 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/system-test.sh" +} diff --git a/.kokoro/continuous/node8/test.cfg b/.kokoro/continuous/node8/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/docs.sh b/.kokoro/docs.sh new file mode 100755 index 000000000..3af319341 --- /dev/null +++ b/.kokoro/docs.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install + +npm run docs diff --git a/.kokoro/lint.sh b/.kokoro/lint.sh new file mode 100755 index 000000000..7c2ea2a28 --- /dev/null +++ b/.kokoro/lint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install + +# Install and link samples +cd samples/ +npm link ../ +npm install +cd .. + +npm run lint diff --git a/.kokoro/presubmit/node10/common.cfg b/.kokoro/presubmit/node10/common.cfg new file mode 100644 index 000000000..db454be4b --- /dev/null +++ b/.kokoro/presubmit/node10/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node10/test.cfg b/.kokoro/presubmit/node10/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/node6/common.cfg b/.kokoro/presubmit/node6/common.cfg new file mode 100644 index 000000000..f0ad1bc23 --- /dev/null +++ b/.kokoro/presubmit/node6/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:6-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node6/test.cfg b/.kokoro/presubmit/node6/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/node8/common.cfg b/.kokoro/presubmit/node8/common.cfg new file mode 100644 index 000000000..3f4eb316b --- /dev/null +++ b/.kokoro/presubmit/node8/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node8/docs.cfg b/.kokoro/presubmit/node8/docs.cfg new file mode 100644 index 000000000..e722d2748 --- /dev/null +++ b/.kokoro/presubmit/node8/docs.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/docs.sh" +} diff --git a/.kokoro/presubmit/node8/lint.cfg b/.kokoro/presubmit/node8/lint.cfg new file mode 100644 index 000000000..629ea4ddf --- /dev/null +++ b/.kokoro/presubmit/node8/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-spanner/.kokoro/lint.sh" +} diff --git a/.kokoro/presubmit/node8/test.cfg b/.kokoro/presubmit/node8/test.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/.kokoro/presubmit/windows/common.cfg b/.kokoro/presubmit/windows/common.cfg new file mode 100644 index 000000000..7320db792 --- /dev/null +++ b/.kokoro/presubmit/windows/common.cfg @@ -0,0 +1,9 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + diff --git a/.kokoro/presubmit/windows/test.cfg b/.kokoro/presubmit/windows/test.cfg new file mode 100644 index 000000000..f89856d9c --- /dev/null +++ b/.kokoro/presubmit/windows/test.cfg @@ -0,0 +1,2 @@ +# Use the test file directly +build_file: "nodejs-spanner/.kokoro/test.bat" diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh new file mode 100755 index 000000000..76edbbbb2 --- /dev/null +++ b/.kokoro/samples-test.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +# Setup service account credentials. +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GCLOUD_PROJECT=long-door-651 + +cd $(dirname $0)/.. + +npm install + +# Install and link samples +cd samples/ +npm link ../ +npm install +cd .. + +npm run samples-test diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh new file mode 100755 index 000000000..a954b7942 --- /dev/null +++ b/.kokoro/system-test.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +# Setup service account credentials. +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json +export GCLOUD_PROJECT=long-door-651 + +cd $(dirname $0)/.. + +# Run a pre-test hook, if a pre-system-test.sh is in the project +if [ -f .kokoro/pre-system-test.sh ]; then + . .kokoro/pre-system-test.sh +fi + +npm install + +npm run system-test diff --git a/.kokoro/test.bat b/.kokoro/test.bat new file mode 100644 index 000000000..a8534ba80 --- /dev/null +++ b/.kokoro/test.bat @@ -0,0 +1,26 @@ +@rem Copyright 2018 gRPC authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +@echo "Starting Windows build" + +cd /d %~dp0 +cd .. + +call npm install || goto :error +call npm run test || goto :error + +goto :EOF + +:error +exit /b 1 diff --git a/.kokoro/test.sh b/.kokoro/test.sh new file mode 100755 index 000000000..51f29589b --- /dev/null +++ b/.kokoro/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +cd $(dirname $0)/.. + +npm install +npm test +node_modules/.bin/codecov diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100755 index 000000000..87ffd2ca9 --- /dev/null +++ b/.kokoro/trampoline.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xeo pipefail + +# Always run the cleanup script, regardless of the success of bouncing into +# the container. +function cleanup() { + chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + echo "cleanup"; +} +trap cleanup EXIT + +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/synth.py b/synth.py index 7c06459f9..23c2b7204 100644 --- a/synth.py +++ b/synth.py @@ -25,6 +25,10 @@ s.copy(spanner_admin_database, excludes=["src/v1/index.js", "src/index.js", "README.md", "package.json"]) s.copy(spanner_admin_instance, excludes=["src/v1/index.js", "src/index.js", "README.md", "package.json"]) +common_templates = gcp.CommonTemplates() +templates = common_templates.node_library() +s.copy(templates) + # nodejs-spanner is composed of 3 APIs: SpannerClient, SpannerAdminDatabase and # SpannerAdminInstance, export all 3 in src/v1/index.js s.replace(