Skip to content

Commit

Permalink
fix: UT
Browse files Browse the repository at this point in the history
  • Loading branch information
htdangkhoa committed Jun 19, 2024
1 parent 6cb0588 commit 5e6100c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
google-ads-api-version: ${{ needs.export-google-ads-api-version.outputs.google-ads-api-version }}
test: false
build: true
import-suffix: .js

publish:
name: Publish
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
required: false
type: boolean
default: false
import-suffix:
description: 'ts-proto will emit file imports using the specified suffix'
required: false
type: string
default: ''

jobs:
generate:
Expand All @@ -44,7 +49,7 @@ jobs:
run: yarn install --prefer-offline

- name: Generate google ads api from protos
run: yarn generate ${{ inputs.google-ads-api-version }}
run: yarn generate ${{ inputs.google-ads-api-version }} ${{ inputs.import-suffix }}

- name: Test
if: ${{ inputs.test }}
Expand Down
21 changes: 12 additions & 9 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

version=$1

importSuffix=$2

if [ -z "$version" ]; then
echo "Version is required! Usage: generate.sh v13"
echo "Version is required! Usage: generate.sh v17"
exit 1
fi

Expand All @@ -27,18 +29,19 @@ mkdir -p $outdir

echo 'Generating Protobuf files'

ts_proto_opts="forceLong=string,snakeToCamel=false,useOptionals=all,useAbortSignal=true,useExactTypes=false,esModuleInterop=true"

if [ -n "$importSuffix" ]; then
ts_proto_opts="$ts_proto_opts,importStyle=commonjs,importSuffix=$importSuffix"
fi

ts_proto_opts="$ts_proto_opts,outputServices=generic-definitions,outputServices=grpc-js"

protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto \
--experimental_allow_proto3_optional \
--proto_path $path \
--ts_proto_out=$outdir \
--ts_proto_opt=forceLong=string \
--ts_proto_opt=snakeToCamel=false \
--ts_proto_opt=useOptionals=all \
--ts_proto_opt=useAbortSignal=true \
--ts_proto_opt=useExactTypes=false \
--ts_proto_opt=esModuleInterop=true \
--ts_proto_opt=importSuffix=.js \
--ts_proto_opt=outputServices=generic-definitions,outputServices=grpc-js \
--ts_proto_opt=$ts_proto_opts \
$path/google/ads/googleads/$version/**/*.proto

node scripts/export-client.js $outdir/google/ads/googleads/$version
Expand Down

0 comments on commit 5e6100c

Please sign in to comment.