Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: update settings for Node 10 #1019

Merged
merged 6 commits into from
Apr 15, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Apr 14, 2020

This PR updates the synth.py script to work with the new format/tooling brought by the Node 10 migration.

Manual changes are in synth.py and dev/protos/update.sh to enable namespacing and add toObject and fromObject (which is needed for the generated unit tests and unfortunately adds a lot of code - maybe we can find a way to remove this code in a follow up).

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 14, 2020
@schmidt-sebastian
Copy link
Contributor Author

Hm, this is completely busted. I will fix this later.

build/
docs/
protos/
system-test/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooling is gonna undo that. Any reason to explicitly ignore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be from the tooling. I didn't make this change manually at least :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this file and re-ran synthtool and it was recreated just like this.

@@ -98,6 +138,13 @@
1
)

os.rename("dev/.gitignore", ".gitignore")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what all goes here, but this may be missing .prettierignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back: That file doesn't exist:

FileNotFoundError: [Errno 2] No such file or directory: 'dev/.prettierignore' -> '.prettierignore'

I guess we should add this to our templates?

@codecov
Copy link

codecov bot commented Apr 15, 2020

Codecov Report

Merging #1019 into node10 will increase coverage by 98.54%.
The diff coverage is 99.01%.

Impacted file tree graph

@@             Coverage Diff             @@
##           node10    #1019       +/-   ##
===========================================
+ Coverage    0.00%   98.54%   +98.54%     
===========================================
  Files          25       25               
  Lines       16044    16614      +570     
  Branches        0     1258     +1258     
===========================================
+ Hits            0    16372    +16372     
+ Misses      16044      239    -15805     
- Partials        0        3        +3     
Impacted Files Coverage Δ
dev/src/v1/firestore_client.ts 97.64% <98.96%> (+97.64%) ⬆️
dev/src/v1beta1/firestore_client.ts 97.38% <99.01%> (+97.38%) ⬆️
dev/src/v1/firestore_admin_client.ts 97.71% <99.07%> (+97.71%) ⬆️
dev/src/transaction.ts 96.49% <0.00%> (+96.49%) ⬆️
dev/src/pool.ts 97.75% <0.00%> (+97.75%) ⬆️
dev/src/validate.ts 98.05% <0.00%> (+98.05%) ⬆️
dev/src/order.ts 98.09% <0.00%> (+98.09%) ⬆️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fbc6e6...cd88990. Read the comment docs.

@schmidt-sebastian
Copy link
Contributor Author

@alexander-fenster Can you sanity check the manual changes?

.jsdoc.js Outdated
includeDate: false,
sourceFiles: false,
systemName: '@google-cloud/firestore',
systemName: 'firestore',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, you need to add "package-name": "@google-cloud/firestore" to the generator arguments in synth.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (and this fixed the issue here)

"${PROTOS_DIR}/google/firestore/admin/v1/*.proto" \
"${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \
"${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \
"${PROTOS_DIR}/google/longrunning/*.proto"
"${PBTS}" -o firestore_admin_v1_proto_api.d.ts firestore_admin_v1_proto_api.js

"${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1beta1_proto_api.js \
-r firestore_v1beta1_v1 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not really affect anything but the name is weird. Maybe just firestore_v1beta1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listIndexesAsync(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @schmidt-sebastian: we now support this :) for await (const index of client.listIndexesAsync(request)) - feel free to use this in your manual layer! (the same for any list* paginated method)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, awesome. Thanks for pointing this out. We should probably use expose this in our APIs that currently hide all paging, since we didn't want to use Streams or Callbacks as the primary way of interacting with our APIs.

@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": "^8.13.0 || >=10.10.0"
"node": ">=10.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so breaking. The title must be chore! then :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Note that the base branch has a ! already.

@schmidt-sebastian schmidt-sebastian changed the title chore: update settings for Node 10 chore!: update settings for Node 10 Apr 15, 2020

# Fix dropping of google-cloud-resource-header
# See: https://github.com/googleapis/nodejs-firestore/pull/375
s.replace(
"dev/src/v1beta1/firestore_client.ts",
"return this\._innerApiCalls\.listen\(options\);",
"return this._innerApiCalls.listen({}, options);",
"return this\.innerApiCalls\.listen\(options\);",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I see this replacement I wonder what's wrong with the code here, why we need this replacement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think the generated code is busted here. We use options to set an additional header, but the way this gets passed down here is as the request (if I remember this correctly). If we don't modify the code, the header is dropped. This only affects bidirectional streaming APIs with additional metadata, so probably just us. I do think we should fix this upstream at some point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this sounds like a bug - filed googleapis/gapic-generator-typescript#425 and one of us will investigate.

@alexander-fenster
Copy link
Contributor

Manual changes are somewhat scary :) A lot of changes are caused by the fact that the gapic code lives in dev/src/. I'm just thinking, is the directory structure fixed in stone here? Other manual packages (spanner, pubsub) have their sources in src/, and their synth.py files are tiny and simple. Maybe not right now, but let's at least have a plan there?

(an alternative is to teach the generator how to place files into a separate location, but I can't estimate how hard it would be)

Copy link
Contributor Author

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: package structure. The main reason for our dev/ and build/ package structure is that it allows us to import the package.json in a consistent way. If I parsed the discussions on Yoshi chat correctly this also now works around a breakage in npm pack, so I am not super keen on changing this :)

.jsdoc.js Outdated
includeDate: false,
sourceFiles: false,
systemName: '@google-cloud/firestore',
systemName: 'firestore',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (and this fixed the issue here)

@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": "^8.13.0 || >=10.10.0"
"node": ">=10.10.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Note that the base branch has a ! already.

build/
docs/
protos/
system-test/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this file and re-ran synthtool and it was recreated just like this.

* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listIndexesAsync(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, awesome. Thanks for pointing this out. We should probably use expose this in our APIs that currently hide all paging, since we didn't want to use Streams or Callbacks as the primary way of interacting with our APIs.

"${PROTOS_DIR}/google/firestore/admin/v1/*.proto" \
"${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \
"${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \
"${PROTOS_DIR}/google/longrunning/*.proto"
"${PBTS}" -o firestore_admin_v1_proto_api.d.ts firestore_admin_v1_proto_api.js

"${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1beta1_proto_api.js \
-r firestore_v1beta1_v1 \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


# Fix dropping of google-cloud-resource-header
# See: https://github.com/googleapis/nodejs-firestore/pull/375
s.replace(
"dev/src/v1beta1/firestore_client.ts",
"return this\._innerApiCalls\.listen\(options\);",
"return this._innerApiCalls.listen({}, options);",
"return this\.innerApiCalls\.listen\(options\);",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think the generated code is busted here. We use options to set an additional header, but the way this gets passed down here is as the request (if I remember this correctly). If we don't modify the code, the header is dropped. This only affects bidirectional streaming APIs with additional metadata, so probably just us. I do think we should fix this upstream at some point.

@schmidt-sebastian schmidt-sebastian merged commit 7d6888d into node10 Apr 15, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/node10synthtool branch April 15, 2020 23:38
schmidt-sebastian added a commit that referenced this pull request Jun 24, 2020
* fix!: mark v1beta1 client as deprecated (#937)

* feat!: use QueryDocumentSnapshot in FirestoreDataConverter (#965)

* deps: update to gts 2.x (#1013)

* chore!: update settings for Node 10 (#1019)

* deps: drop through2 (#1014)

* feat: support BigInt (#1016)

* fix: make update.sh work on Linux (#1043)

* fix: only use BigInt in BigInt system test (#1044)

* fix: make pbjs compile admin proto again (#1045)

* Add BulkWriter (#1055)

* docs: Add documentation for FirestoreDataConverter (#1059)

* chore: enforce return types (#1065)

* fix: add generic to Firestore.getAll() (#1066)

* chore: remove internal WriteOp (#1067)

* chore: add linter checks for it|describe.only (#1068)

* fix: handle terminate in BulkWriter (#1070)

* chore: run template copying last in synthtool (#1071)

* feat: Firestore Bundles implementation (#1078)

* feat: add support for set() with SetOptions when using FirestoreDataConverter (#1087)

* feat: Add totalDocuments and totalBytes to bundle metadata. (#1085)

* feat: Add totalDocuments and totalBytes to bundle metadata.

* fix: Better comment

* fix: Better testing.

* fix: Improve metadata testing.

* fix: incomplete expect in rate-limiter test (#1092)

* Remove BatchWrite proto, fix conformance tests

* chore: use public API types internally (#1100)

* feat: add Partition and BatchWrite protos (#1110)

* fix: remove GCF transaction fallback (#1112)

* fix: add BulkWriter integration tests, java backport changes, delete fix (#1117)

* chore: merge master (#1218)

* chore: add eslint check for console.log statements (#1229)

* fix: another attempt at fixing the flaky BulkWriter test (#1228)

* Fix comment

* Renames

* Test fix

* Fix unit tests

Co-authored-by: Brian Chen <[email protected]>
Co-authored-by: wu-hui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants