From 79deccc2f453033c7f42516a309825a64e79653f Mon Sep 17 00:00:00 2001 From: Xiaozhen Liu Date: Tue, 5 Nov 2019 16:03:59 -0800 Subject: [PATCH] feat: add docker test script (#103) * add docker test * format * typo * feedback * use tagged docker name * feedbac --- .gitignore | 1 + docker/test.sh | 23 +++++++++++++++++++++++ package.json | 1 + 3 files changed, 25 insertions(+) create mode 100644 docker/test.sh diff --git a/.gitignore b/.gitignore index acfbcffe6..6e48ec3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ pbjs-genfiles/ *test-out* docker/package.tgz *.tgz +.showcase-typescript diff --git a/docker/test.sh b/docker/test.sh new file mode 100644 index 000000000..7cc9a252d --- /dev/null +++ b/docker/test.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +### Test script pulling the docker image and use it against showcase proto. + +# Docker image tag: gapic-generator-typescript:latest. +DIR_NAME=.showcase-typescript +# Remove test directory if it already exists +rm -rf $DIR_NAME +# Create new directory showcase-typescript. +mkdir $DIR_NAME +# Use Docker Image for generating showcase client library +docker run --rm \ + --mount type=bind,source=`pwd`/typescript/test/protos/google/showcase/v1beta1,destination=/in/typescript/test/protos/google/showcase/v1beta1,readonly \ + --mount type=bind,source=`pwd`/$DIR_NAME,destination=/out \ + gapic-generator-typescript:latest +# Test generated client library +cd $DIR_NAME +npm install # install dependencies +npm run fix # format the code +npm test # run unit tests + +# Test succeed +echo 'docker test succeeded! ' diff --git a/package.json b/package.json index 09ebda403..11483e55b 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "scripts": { "test": "c8 --reporter=lcov mocha build/test/unit", + "docker-test": "sh docker/test.sh", "codecov": "c8 --reporter=lcov mocha build/test/unit && c8 report", "lint": "gts check", "clean": "gts clean",