Skip to content

Commit

Permalink
chore: migrate to owl bot (googleapis#834)
Browse files Browse the repository at this point in the history
* chore: migrate to owl bot

* chore: copy files from googleapis-gen fb91803ccef5d7c695139b22788b309e2197856b

* chore: run the post processor

* 🦉 Updates from OwlBot

* chore: update post processor docker image

* 🦉 Updates from OwlBot

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
SurferJeffAtGoogle and gcf-owl-bot[bot] authored May 27, 2021
1 parent 0dee08a commit c27bc98
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 309 deletions.
4 changes: 4 additions & 0 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker:
digest: sha256:f556e6e7be625deb1b2429fe608df27be57185c3e6b7d39ee0059f1609f17530
image: gcr.io/repo-automation-bots/owlbot-nodejs:latest

28 changes: 28 additions & 0 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.
docker:
image: gcr.io/repo-automation-bots/owlbot-nodejs:latest


deep-remove-regex:
- /owl-bot-staging

deep-copy-regex:
- source: /google/datastore/(v.*)/.*-nodejs/(.*)
dest: /owl-bot-staging/$1/$2
- source: /google/datastore/(admin/v.*)/.*-nodejs/(.*)
dest: /owl-bot-staging/$1/$2

begin-after-commit-hash: fb91803ccef5d7c695139b22788b309e2197856b

16 changes: 16 additions & 0 deletions .github/generated-files-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
generatedFiles:
- path: '.kokoro/**'
message: '`.kokoro` files are templated and should be updated in [`synthtool`](https://github.com/googleapis/synthtool)'
- path: '.github/CODEOWNERS'
message: 'CODEOWNERS should instead be modified via the `codeowner_team` property in .repo-metadata.json'
- path: '.github/workflows/**'
message: '`.github/workflows` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)'
- path: '.github/generated-files-bot.+(yml|yaml)'
message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)'
- path: 'README.md'
message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml'
- path: 'samples/README.md'
message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml'
ignoreAuthors:
- 'gcf-owl-bot[bot]'
- 'yoshi-automation'
10 changes: 0 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
- run: rm -rf node_modules
- run: npm install
- run: npm test
- name: coverage
uses: codecov/codecov-action@v1
with:
name: actions ${{ matrix.node }}
fail_ci_if_error: false
windows:
runs-on: windows-latest
steps:
Expand All @@ -38,11 +33,6 @@ jobs:
node-version: 14
- run: npm install
- run: npm test
- name: coverage
uses: codecov/codecov-action@v1
with:
name: actions windows
fail_ci_if_error: false
lint:
runs-on: ubuntu-latest
steps:
Expand Down
40 changes: 0 additions & 40 deletions .kokoro/release/publish.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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 as s
import synthtool.gcp as gcp
import synthtool.languages.node as node
import logging
from pathlib import Path
from synthtool import _tracked_paths
import shutil

logging.basicConfig(level=logging.DEBUG)

staging = Path("owl-bot-staging")

if staging.is_dir():
logging.info(f"Copying files from staging directory ${staging}.")

# Copy the datastore library.
for version in ['v1']:
library = staging / version
_tracked_paths.add(library)
s.copy([library],excludes=[
'package.json', 'README.md', 'src/index.ts', 'src/v1/index.ts'])

# Copy the admin library.
for version in ['v1']:
library = staging / 'admin' / version
_tracked_paths.add(library)
s.copy([library],excludes=[
'package.json', 'README.md', 'src/index.ts', 'src/v1/index.ts', 'tsconfig.json', 'tslint.json',
'system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js',
'.jsdoc.js', 'webpack.config.js'])

# Patch the code.
system_test_files = ['system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js']
for file in system_test_files:
s.replace(file, 'DatastoreClient', 'Datastore')
s.replace(file, 'client.close', '// client.close'); # does not work with the manual layer

# The staging directory should never be merged into the main branch.
shutil.rmtree(staging)

common_templates = gcp.CommonTemplates()
templates = common_templates.node_library(source_location="build/src")
s.copy(templates)

node.postprocess_gapic_library_hermetic()
2 changes: 1 addition & 1 deletion src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export namespace entity {
isDsInt(identifier) ||
isDsIntLike(identifier)
) {
this.id = (((identifier as {}) as Int).value || identifier) as string;
this.id = ((identifier as {} as Int).value || identifier) as string;
} else if (is.string(identifier)) {
this.name = identifier as string;
}
Expand Down
5 changes: 2 additions & 3 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,8 @@ class DatastoreRequest {
try {
await Promise.all(
arrify(entities).map(async (objEntity: Entity) => {
const obj: Entity = DatastoreRequest.prepareEntityObject_(
objEntity
);
const obj: Entity =
DatastoreRequest.prepareEntityObject_(objEntity);
const [data] = await transaction.get(obj.key);
obj.method = 'upsert';
obj.data = Object.assign({}, data, obj.data);
Expand Down
89 changes: 41 additions & 48 deletions src/v1/datastore_admin_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,14 @@ export class DatastoreAdminClient {
];
for (const methodName of datastoreAdminStubMethods) {
const callPromise = this.datastoreAdminStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
stub =>
(...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
Expand Down Expand Up @@ -515,11 +516,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.getIndex(request, options, callback);
}
Expand Down Expand Up @@ -651,11 +651,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.exportEntities(request, options, callback);
}
Expand Down Expand Up @@ -818,11 +817,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.importEntities(request, options, callback);
}
Expand Down Expand Up @@ -976,11 +974,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.createIndex(request, options, callback);
}
Expand Down Expand Up @@ -1129,11 +1126,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.deleteIndex(request, options, callback);
}
Expand Down Expand Up @@ -1263,11 +1259,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
this.initialize();
return this.innerApiCalls.listIndexes(request, options, callback);
}
Expand Down Expand Up @@ -1304,11 +1299,10 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listIndexes.createStream(
Expand Down Expand Up @@ -1356,17 +1350,16 @@ export class DatastoreAdminClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
project_id: request.projectId || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listIndexes.asyncIterate(
this.innerApiCalls['listIndexes'] as GaxCall,
(request as unknown) as RequestType,
request as unknown as RequestType,
callSettings
) as AsyncIterable<protos.google.datastore.admin.v1.IIndex>;
}
Expand Down
Loading

0 comments on commit c27bc98

Please sign in to comment.