Skip to content

Commit

Permalink
feat(deps): update gts dependency for generate client library (#343)
Browse files Browse the repository at this point in the history
* update package.json

* add templates

* lint

* fix gts lint

* prefer-spread

* remove global rules

* remove pagination import

* template change for new gts

* remove tslint no-any

* test

* use paginationCallback & response, remove empty-function check

* update gts to latest

* test

* test

* test

* change back

* test

* test

* test

* test

* test

* test

* try this

* and finally

* work!

Co-authored-by: Alexander Fenster <fenster@google.com>
  • Loading branch information
xiaozhenliu-gg5 and alexander-fenster committed Mar 26, 2020
1 parent 26933fe commit a63f235
Show file tree
Hide file tree
Showing 83 changed files with 343 additions and 551 deletions.
39 changes: 23 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,37 @@ jobs:
command: |
npm run lint
- run:
name: copy protos to generated client library
name: copy protos to generated client library & move .test-out-* to project/out/
command: |
for dir in .test-out-* ; do
cp -r test-fixtures/protos $dir
done
- run:
name: move test out folders to a separate folder
command: |
mkdir /home/circleci/project/baselines
cp -r .test-out-* /home/circleci/project/baselines
- persist_to_workspace:
root: /home/circleci/project
paths:
- gapic-generator-typescript
- baselines
showcaseTestApplications:
docker:
- image: circleci/node:10-browsers
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run showcase test for Typescript users
working_directory: /home/circleci/project/workspace/gapic-generator-typescript
working_directory: /home/circleci/workspace/gapic-generator-typescript
command: npm run ts-test-application
environment:
NPM_CONFIG_PREFIX: /tmp/.npm-global
- run:
name: Run showcase test for JavaScript users
working_directory: /home/circleci/project/workspace/gapic-generator-typescript
working_directory: /home/circleci/workspace/gapic-generator-typescript
command: npm run js-test-application
environment:
NPM_CONFIG_PREFIX: /tmp/.npm-global
Expand All @@ -63,11 +69,12 @@ jobs:
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Showcase library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-showcase
working_directory: /home/circleci/workspace/baselines/.test-out-showcase
command: &alltests |
pwd
npm install
npm test
npm run fix
Expand All @@ -80,54 +87,54 @@ jobs:
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated KMS library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-kms
working_directory: /home/circleci/workspace/baselines/.test-out-kms
command: *alltests
translateLibTest:
docker:
- image: circleci/node:10-browsers
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Translate library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-translate
working_directory: /home/circleci/workspace/baselines/.test-out-translate
command: *alltests
monitoringLibTest:
docker:
- image: circleci/node:10-browsers
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Monitoring library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-monitoring
working_directory: /home/circleci/workspace/baselines/.test-out-monitoring
command: *alltests
dlpLibTest:
docker:
- image: circleci/node:10-browsers
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated DLP library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-dlp
working_directory: /home/circleci/workspace/baselines/.test-out-dlp
command: *alltests
ttsLibTest:
docker:
- image: circleci/node:10-browsers
steps:
- checkout
- attach_workspace:
at: workspace
at: /home/circleci/workspace
- run:
name: Run unit tests, system tests, jsdoc generation, and gts fix of the generated Text-to-Speech library
working_directory: /home/circleci/project/workspace/gapic-generator-typescript/.test-out-texttospeech
working_directory: /home/circleci/workspace/baselines/.test-out-texttospeech
command: *alltests
workflows:
version: 2
Expand Down
6 changes: 6 additions & 0 deletions baselines/bigquery-storage/.eslintignore.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/.coverage
build/
docs/
protos/
system-test/
3 changes: 3 additions & 0 deletions baselines/bigquery-storage/.eslintrc.json.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
2 changes: 1 addition & 1 deletion baselines/bigquery-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.30",
"c8": "^7.1.0",
"gts": "^1.1.2",
"gts": "2.0.0-alpha.6",
"jsdoc": "^3.6.3",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class BigQueryStorageClient {
this.bigQueryStorageStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.cloud.bigquery.storage.v1beta1.BigQueryStorage') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.cloud.bigquery.storage.v1beta1.BigQueryStorage,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import * as protosTypes from '../protos/protos';
import * as assert from 'assert';
import { describe, it } from 'mocha';
/* eslint-disable @typescript-eslint/no-var-requires */
const bigquerystorageModule = require('../src');

import {PassThrough} from 'stream';
Expand Down Expand Up @@ -155,8 +156,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
request.tableReference.projectId = '';
request.tableReference = {};
request.tableReference.datasetId = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.createReadSession = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -209,8 +208,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest = {};
request.session = {};
request.session.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.batchCreateReadSessionStreams = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -263,8 +260,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest = {};
request.stream = {};
request.stream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.finalizeStream = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -317,8 +312,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
const request: protosTypes.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest = {};
request.originalStream = {};
request.originalStream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.splitReadStream = mockSimpleGrpcMethod(
request,
Expand Down Expand Up @@ -372,8 +365,6 @@ describe('v1beta1.BigQueryStorageClient', () => {
request.readPosition = {};
request.readPosition.stream = {};
request.readPosition.stream.name = '';
// Mock response
const expectedResponse = {};
// Mock gRPC layer
client._innerApiCalls.readRows = mockServerStreamingGrpcMethod(request, null, error);
const stream = client.readRows(request);
Expand Down
6 changes: 6 additions & 0 deletions baselines/disable-packing-test/.eslintignore.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/.coverage
build/
docs/
protos/
system-test/
3 changes: 3 additions & 0 deletions baselines/disable-packing-test/.eslintrc.json.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
2 changes: 1 addition & 1 deletion baselines/disable-packing-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.30",
"c8": "^7.1.0",
"gts": "^1.1.2",
"gts": "2.0.0-alpha.6",
"jsdoc": "^3.6.3",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -185,6 +185,7 @@ export class EchoClient {
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback?
/* eslint-disable @typescript-eslint/no-var-requires */
this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

Expand Down Expand Up @@ -237,7 +238,7 @@ export class EchoClient {
this.echoStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Echo') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Echo,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down Expand Up @@ -596,7 +597,7 @@ export class EchoClient {
pagedExpand(
request: protosTypes.google.showcase.v1beta1.IPagedExpandRequest,
options: gax.CallOptions,
callback: Callback<
callback: PaginationCallback<
protosTypes.google.showcase.v1beta1.IEchoResponse[],
protosTypes.google.showcase.v1beta1.IPagedExpandRequest|null,
protosTypes.google.showcase.v1beta1.IPagedExpandResponse>): void;
Expand Down Expand Up @@ -632,11 +633,11 @@ export class EchoClient {
*/
pagedExpand(
request: protosTypes.google.showcase.v1beta1.IPagedExpandRequest,
optionsOrCallback?: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|PaginationCallback<
protosTypes.google.showcase.v1beta1.IEchoResponse[],
protosTypes.google.showcase.v1beta1.IPagedExpandRequest|null,
protosTypes.google.showcase.v1beta1.IPagedExpandResponse>,
callback?: Callback<
callback?: PaginationCallback<
protosTypes.google.showcase.v1beta1.IEchoResponse[],
protosTypes.google.showcase.v1beta1.IPagedExpandRequest|null,
protosTypes.google.showcase.v1beta1.IPagedExpandResponse>):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -201,7 +201,7 @@ export class IdentityClient {
this.identityStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Identity') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Identity,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down Expand Up @@ -540,7 +540,7 @@ export class IdentityClient {
listUsers(
request: protosTypes.google.showcase.v1beta1.IListUsersRequest,
options: gax.CallOptions,
callback: Callback<
callback: PaginationCallback<
protosTypes.google.showcase.v1beta1.IUser[],
protosTypes.google.showcase.v1beta1.IListUsersRequest|null,
protosTypes.google.showcase.v1beta1.IListUsersResponse>): void;
Expand Down Expand Up @@ -576,11 +576,11 @@ export class IdentityClient {
*/
listUsers(
request: protosTypes.google.showcase.v1beta1.IListUsersRequest,
optionsOrCallback?: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|PaginationCallback<
protosTypes.google.showcase.v1beta1.IUser[],
protosTypes.google.showcase.v1beta1.IListUsersRequest|null,
protosTypes.google.showcase.v1beta1.IListUsersResponse>,
callback?: Callback<
callback?: PaginationCallback<
protosTypes.google.showcase.v1beta1.IUser[],
protosTypes.google.showcase.v1beta1.IListUsersRequest|null,
protosTypes.google.showcase.v1beta1.IListUsersResponse>):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, PaginationResponse} from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -186,6 +186,7 @@ export class MessagingClient {
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.
const protoFilesRoot = opts.fallback?
/* eslint-disable @typescript-eslint/no-var-requires */
this._gaxModule.protobuf.Root.fromJSON(require("../../protos/protos.json")) :
this._gaxModule.protobuf.loadSync(nodejsProtoPath);

Expand Down Expand Up @@ -238,7 +239,7 @@ export class MessagingClient {
this.messagingStub = this._gaxGrpc.createStub(
this._opts.fallback ?
(this._protos as protobuf.Root).lookupService('google.showcase.v1beta1.Messaging') :
// tslint:disable-next-line no-any
/* eslint-disable @typescript-eslint/no-explicit-any */
(this._protos as any).google.showcase.v1beta1.Messaging,
this._opts) as Promise<{[method: string]: Function}>;

Expand Down Expand Up @@ -989,7 +990,7 @@ export class MessagingClient {
listRooms(
request: protosTypes.google.showcase.v1beta1.IListRoomsRequest,
options: gax.CallOptions,
callback: Callback<
callback: PaginationCallback<
protosTypes.google.showcase.v1beta1.IRoom[],
protosTypes.google.showcase.v1beta1.IListRoomsRequest|null,
protosTypes.google.showcase.v1beta1.IListRoomsResponse>): void;
Expand Down Expand Up @@ -1025,11 +1026,11 @@ export class MessagingClient {
*/
listRooms(
request: protosTypes.google.showcase.v1beta1.IListRoomsRequest,
optionsOrCallback?: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|PaginationCallback<
protosTypes.google.showcase.v1beta1.IRoom[],
protosTypes.google.showcase.v1beta1.IListRoomsRequest|null,
protosTypes.google.showcase.v1beta1.IListRoomsResponse>,
callback?: Callback<
callback?: PaginationCallback<
protosTypes.google.showcase.v1beta1.IRoom[],
protosTypes.google.showcase.v1beta1.IListRoomsRequest|null,
protosTypes.google.showcase.v1beta1.IListRoomsResponse>):
Expand Down Expand Up @@ -1104,7 +1105,7 @@ export class MessagingClient {
listBlurbs(
request: protosTypes.google.showcase.v1beta1.IListBlurbsRequest,
options: gax.CallOptions,
callback: Callback<
callback: PaginationCallback<
protosTypes.google.showcase.v1beta1.IBlurb[],
protosTypes.google.showcase.v1beta1.IListBlurbsRequest|null,
protosTypes.google.showcase.v1beta1.IListBlurbsResponse>): void;
Expand Down Expand Up @@ -1144,11 +1145,11 @@ export class MessagingClient {
*/
listBlurbs(
request: protosTypes.google.showcase.v1beta1.IListBlurbsRequest,
optionsOrCallback?: gax.CallOptions|Callback<
optionsOrCallback?: gax.CallOptions|PaginationCallback<
protosTypes.google.showcase.v1beta1.IBlurb[],
protosTypes.google.showcase.v1beta1.IListBlurbsRequest|null,
protosTypes.google.showcase.v1beta1.IListBlurbsResponse>,
callback?: Callback<
callback?: PaginationCallback<
protosTypes.google.showcase.v1beta1.IBlurb[],
protosTypes.google.showcase.v1beta1.IListBlurbsRequest|null,
protosTypes.google.showcase.v1beta1.IListBlurbsResponse>):
Expand Down

0 comments on commit a63f235

Please sign in to comment.