Skip to content

Commit

Permalink
synth: use common templating for .circleci/config.yml (#6)
Browse files Browse the repository at this point in the history
* synth: use common templating for .circleci/config.yml

* fix: add a samples/package.json
  • Loading branch information
jkwlui authored Jul 18, 2018
1 parent bb2cd49 commit b1e05b3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 11 deletions.
60 changes: 50 additions & 10 deletions packages/google-cloud-automl/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,35 @@ workflows:
- node10:
filters: *all_commits
- lint:
requires:
- node6
- node8
- node10
filters: *all_commits
- docs:
requires:
- node6
- node8
- node10
filters: *all_commits
- system_tests:
requires:
- lint
- docs
- node6
- node8
- node10
filters:
filters: &master_and_releases
branches:
only: master
tags: &releases
only: '/^v[\d.]+$/'
- sample_tests:
requires:
- lint
- docs
filters: *master_and_releases
- publish_npm:
requires:
- system_tests
- sample_tests
filters:
branches:
ignore: /.*/
Expand All @@ -55,7 +66,7 @@ jobs:
WORKFLOW_NAME=`python .circleci/get_workflow_name.py`
echo "Workflow name: $WORKFLOW_NAME"
if [ "$WORKFLOW_NAME" = "nightly" ]; then
echo "Nightly build detected, removing package-lock.json"
echo "Nightly build detected, removing package-lock.json."
rm -f package-lock.json samples/package-lock.json
else
echo "Not a nightly build, skipping this step."
Expand All @@ -69,6 +80,7 @@ jobs:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run: npm test
- run: node_modules/.bin/codecov

node8:
docker:
- image: 'node:8'
Expand All @@ -91,8 +103,8 @@ jobs:
name: Link the module being tested to the samples.
command: |
cd samples/
npm install
npm link ../
npm install
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run:
Expand All @@ -108,7 +120,36 @@ jobs:
- checkout
- run: *remove_package_lock
- run: *npm_install_and_link
- run: npm run docs
- run:
name: Build documentation.
command: npm run docs
sample_tests:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run: *remove_package_lock
- run:
name: Decrypt credentials.
command: |
openssl aes-256-cbc -d -in .circleci/key.json.enc \
-out .circleci/key.json \
-k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
- run: *npm_install_and_link
- run: *samples_npm_install_and_link
- run:
name: Run sample tests.
command: npm run samples-test
environment:
GCLOUD_PROJECT: long-door-651
GOOGLE_APPLICATION_CREDENTIALS: /home/node/samples/.circleci/key.json
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run:
name: Remove unencrypted key.
command: rm .circleci/key.json
when: always
working_directory: /home/node/samples/
system_tests:
docker:
- image: 'node:8'
Expand All @@ -127,7 +168,6 @@ jobs:
name: Run system tests.
command: npm run system-test
environment:
GCLOUD_PROJECT: long-door-651
GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json
- run:
name: Remove unencrypted key.
Expand All @@ -139,5 +179,5 @@ jobs:
user: node
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm publish --access=public
- run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
- run: npm publish
24 changes: 24 additions & 0 deletions packages/google-cloud-automl/samples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@google-cloud/automl-samples",
"description": "Samples for the Cloud AutoML Client Library for Node.js.",
"version": "0.0.1",
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": ">=6"
},
"repository": "googleapis/nodejs-automl",
"private": true,
"nyc": {
"exclude": [
"**/*.test.js"
]
},
"scripts": {
},
"dependencies": {
"@google-cloud/automl": "^0.1.0"
},
"devDependencies": {
}
}
5 changes: 4 additions & 1 deletion packages/google-cloud-automl/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator(private=True)
gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

versions = ['v1beta1']

for version in versions:
library = gapic.node_library('automl', version)
s.copy(library, excludes=['src/index.js', 'README.md', 'package.json'])

templates = common_templates.node_library(package_name="@google-cloud/automl")
s.copy(templates)

# Node.js specific cleanup
subprocess.run(['npm', 'ci'])
Expand Down

0 comments on commit b1e05b3

Please sign in to comment.