Exemplo n.º 1
0
def test_owlbot_main_with_staging_ignore_index(hermetic_mock, nodejs_dlp):
    original_text = open(
        FIXTURES / "nodejs-dlp-with-staging" / "src" / "index.ts",
        "rt").read()
    node.owlbot_main(TEMPLATES, templates_excludes=["src/index.ts"])
    # confirm index.ts was overwritten by staging index.ts.
    text = open("./src/index.ts", "rt").read()
    assert original_text == text
Exemplo n.º 2
0
def test_owlbot_main(hermetic_mock):
    temp_dir = Path(tempfile.mkdtemp())
    shutil.copytree(FIXTURES / "nodejs-dlp", temp_dir / "nodejs-dlp")
    cwd = os.getcwd()
    try:
        os.chdir(temp_dir / "nodejs-dlp")
        # just confirm it doesn't throw an exception.
        node.owlbot_main(
            Path(__file__).parent.parent / "synthtool" / "gcp" / "templates")
    finally:
        os.chdir(cwd)
Exemplo n.º 3
0
def test_owlbot_main_with_staging(hermetic_mock, nodejs_dlp):
    original_text = open(
        FIXTURES / "nodejs-dlp-with-staging" / "src" / "index.ts",
        "rt").read()
    node.owlbot_main(TEMPLATES)
    # confirm index.ts was overwritten by template-generated index.ts.
    staging_text = open(
        FIXTURES / "nodejs-dlp-with-staging" / "owl-bot-staging" / "v2" /
        "src" / "index.ts",
        "rt",
    ).read()
    text = open("./src/index.ts", "rt").read()
    assert staging_text != text
    assert original_text != text
Exemplo n.º 4
0
def test_owlbot_main_with_staging_index_from_staging(hermetic_mock,
                                                     nodejs_dlp):
    node.owlbot_main(
        TEMPLATES,
        staging_excludes=["README.md", "package.json"],
        templates_excludes=["src/index.ts"],
    )
    # confirm index.ts was overwritten by staging index.ts.
    staging_text = open(
        FIXTURES / "nodejs-dlp-with-staging" / "owl-bot-staging" / "v2" /
        "src" / "index.ts",
        "rt",
    ).read()
    text = open("./src/index.ts", "rt").read()
    assert staging_text == text
Exemplo n.º 5
0
def test_owlbot_main_with_staging_patch_staging(hermetic_mock, nodejs_dlp):
    def patch(library: Path):
        s.replace(library / "src" / "index.ts", "import", "export")

    node.owlbot_main(
        TEMPLATES,
        staging_excludes=["README.md", "package.json"],
        templates_excludes=["src/index.ts"],
        patch_staging=patch,
    )
    # confirm index.ts was overwritten by staging index.ts.
    staging_text = open(
        FIXTURES / "nodejs-dlp-with-staging" / "owl-bot-staging" / "v2" /
        "src" / "index.ts",
        "rt",
    ).read()
    text = open("./src/index.ts", "rt").read()
    assert "import * as v2" in staging_text
    assert "export * as v2" not in staging_text
    assert "export * as v2" in text
Exemplo n.º 6
0
# See the License for the specific language governing permissions and
# limitations under the License.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node
import logging

logging.basicConfig(level=logging.DEBUG)

# List of excludes for the enhanced library
node.owlbot_main(
    staging_excludes=[
        ".kokoro/presubmit/node12/samples-test.cfg",
        "package.json",
        "README.md",
        "src/decorator.ts",
        "src/enhanced-types.json",
        "src/helpers.ts",
        "src/index.ts",
        "src/value-converter.ts",
        "test/helpers.test.ts",
        "test/index.test.ts",
        "tsconfig.json",
    ],
    templates_excludes=[
        ".kokoro/continuous/node12/samples-test.cfg",
        ".kokoro/presubmit/node12/samples-test.cfg",
        "src/index.ts",
    ],
)
Exemplo n.º 7
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=["README.md", ".github/workflows/ci.yaml"])
Exemplo n.º 8
0
# limitations under the License.
"""This script is used to synthesize generated parts of this library."""

import os
import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.node as node
import json
import logging
from pathlib import Path


def patch(library: Path):
    version = library.parts[len(library.parts) - 1]
    name = 'speech'
    # Manual helper methods override the streaming API so that it
    # accepts streamingConfig when calling streamingRecognize.
    # Rename the generated methods to avoid confusion.
    s.replace(f'owl-bot-staging/{version}/src/{version}/{name}_client.ts',
              r'( +)streamingRecognize\(', '\\1_streamingRecognize(')
    s.replace(f'owl-bot-staging/{version}/test/gapic_{name}_{version}.ts',
              r'client\.streamingRecognize\(', 'client._streamingRecognize(')
    s.replace(
        f'owl-bot-staging/{version}/src/{version}/{name}_client.ts', r'\Z',
        '\n' + "import {ImprovedStreamingClient} from '../helpers';\n" +
        '// eslint-disable-next-line @typescript-eslint/no-empty-interface\n' +
        'export interface SpeechClient extends ImprovedStreamingClient {}\n')


node.owlbot_main(templates_excludes=["src/index.ts"], patch_staging=patch)
Exemplo n.º 9
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=[
    'README.md',
    '.github/CODEOWNERS',
    '.github/release-please.yml',
    'renovate.json',
    '.eslintignore',
    '.prettierignore',
])
Exemplo n.º 10
0
# 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.

"""This script is used to synthesize generated parts of this library."""

import synthtool as s
import synthtool.languages.node as node

node.owlbot_main(
    staging_excludes=[
        ".eslintignore", ".prettierignore", "src/index.ts", "README.md", "package.json",
        "system-test/fixtures/sample/src/index.js",
        "system-test/fixtures/sample/src/index.ts"],
    templates_excludes=[
        "src/index.ts",
        ".eslintignore",
        ".prettierignore",
        "CONTRIBUTING.md"
    ]
)

# adjust .trampolinerc for environment tests
s.replace(
    ".trampolinerc",
    "required_envvars[^\)]*\)",
    "required_envvars+=()"
)
s.replace(
    ".trampolinerc",
    "pass_down_envvars\+\=\(",
Exemplo n.º 11
0
# Copyright 2019 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node

node.owlbot_main(staging_excludes=['README.md', 'package.json'],
                 templates_excludes=['.github/release-please.yml'])
Exemplo n.º 12
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=["README.md"])
Exemplo n.º 13
0
# Copyright 2021 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.
import synthtool.languages.node as node

node.owlbot_main(templates_excludes=[
    ".kokoro/continuous/node12/common.cfg",
    ".kokoro/presubmit/node12/common.cfg"
])
Exemplo n.º 14
0
# Copyright 2021 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.

import synthtool.languages.node as node

# Remove sync-repo-settings once we add tests
node.owlbot_main(templates_excludes=[
    "README.md", ".kokoro/**", ".github/workflows/**", ".trampolinerc",
    ".mocharc.js", ".github/release-trigger.yml", ".github/release-please.yml",
    ".github/sync-repo-settings.yaml"
])
Exemplo n.º 15
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=[
    'README.md', '.github/CODEOWNERS', '.github/release-please.yml',
    'renovate.json'
])
Exemplo n.º 16
0
#
#     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.


import synthtool.languages.node as node

node.owlbot_main(templates_excludes=[
  'README.md',
  'CONTRIBUTING.md',
  '.eslintignore',
  '.eslintrc.json',
  '.mocharc.js',
  '.prettierignore',
  '.prettierrc',
  '.nycrc',
  '.kokoro/presubmit/node10/system-test.cfg',
  '.kokoro/continuous/node10/system-test.cfg',
  '.kokoro/system-test.sh',
  '.mocharc.js',
  '.github/generated-files-bot.yml',
  '.github/release-please.yml',
  '.github/sync-repo-settings.yaml',
  '.github/workflows/ci.yaml',
])
Exemplo n.º 17
0
# 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.
"""This script is used to synthesize generated parts of this library."""

import synthtool as s
import synthtool.languages.node as node

node.owlbot_main(staging_excludes=[
    'README.md', 'linkinator.config.json', '.mocharc.json', 'package.json'
])

# TODO: Remove the following replace once Datacatalog is ready to release a break change
# Users should use beta Client with explicitly specify the beta version
# Add beta version PolicyTagManagerClient, PolicyTagManagerSerializationClient to export
s.replace(
    'src/index.ts',
    '\nexport \{v1\, v1beta1\, DataCatalogClient\}\;\nexport default \{v1\, v1beta1\, DataCatalogClient\}\;',
    """const PolicyTagManagerClient = v1beta1.PolicyTagManagerClient;
type PolicyTagManagerClient = v1beta1.PolicyTagManagerClient;
const PolicyTagManagerSerializationClient = v1beta1.PolicyTagManagerSerializationClient;
type PolicyTagManagerSerializationClient = v1beta1.PolicyTagManagerSerializationClient;
export {v1, v1beta1, DataCatalogClient, PolicyTagManagerClient, PolicyTagManagerSerializationClient};
export default {v1, v1beta1, DataCatalogClient, PolicyTagManagerClient, PolicyTagManagerSerializationClient};"""
)
Exemplo n.º 18
0
# Copyright 2021 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
#
#     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.

import synthtool as s
import synthtool.languages.node as node
import pathlib


def patch(library: pathlib.Path):
    # fix for broken link in docs
    s.replace(library / 'src/v*/*_client.ts', '/compute/docs/',
              'https://cloud.google.com/compute/docs/')


node.owlbot_main(staging_excludes=['package.json', 'README.md'],
                 patch_staging=patch)
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=[
    ".github/CONTRIBUTING.md", "README.md", ".eslintignore", ".prettierignore",
    ".github/release-please.yml", '.kokoro/publish.sh',
    '.kokoro/release/publish.cfg', '.github/workflows/ci.yaml'
])
Exemplo n.º 20
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=['LICENSE', 'README.md'])
Exemplo n.º 21
0
# Copyright 2020 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node

node.owlbot_main(
  staging_excludes=["package.json", "README.md"],
  templates_excludes=[".github/CODEOWNERS"])
Exemplo n.º 22
0
# 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node

node.owlbot_main(staging_excludes=["README.md", "package.json"])
Exemplo n.º 23
0
# 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
#
#     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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=['.eslintignore', '.mocharc.js', '.github/workflows/ci.yaml'])
Exemplo n.º 24
0
# Copyright 2020 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""
import synthtool.languages.node as node

node.owlbot_main(templates_excludes=['.github/auto-approve.yml'])
Exemplo n.º 25
0
def test_owlbot_main(hermetic_mock):
    with util.copied_fixtures_dir(FIXTURES / "nodejs-dlp"):
        # just confirm it doesn't throw an exception.
        node.owlbot_main(TEMPLATES)
Exemplo n.º 26
0
# 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node

node.owlbot_main(staging_excludes=['package.json', 'README.md'],
                 templates_excludes=['.nycrc'])
Exemplo n.º 27
0
# Copyright 2020 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool.languages.node as node

node.owlbot_main(staging_excludes=["package.json"])
Exemplo n.º 28
0
# Copyright 2021 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.

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=["LICENSE"])
Exemplo n.º 29
0
# 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""

import synthtool as s
import synthtool.languages.node as node
import pathlib


def patch(library: pathlib.Path):
    s.replace(library / 'src/*/cloud_tasks_client_config.json',
              '"initial_rpc_timeout_millis": 60000',
              '"initial_rpc_timeout_millis": 20000')
    s.replace(library / 'src/*/cloud_tasks_client_config.json',
              '"max_rpc_timeout_millis": 60000',
              '"max_rpc_timeout_millis": 20000')


node.owlbot_main(staging_excludes=["README.md", "package.json"],
                 patch_staging=patch)
Exemplo n.º 30
0
# Copyright 2020 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
#
#     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.
"""This script is used to synthesize generated parts of this library."""
import synthtool.languages.node as node

node.owlbot_main(templates_excludes=['.github/CODEOWNERS'])