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

add a synth file and run it #75

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 133 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,169 @@
---
release_tags: &release_tags
tags:
only: /^v\d+(\.\d+){2}(-.*)?$/

unit_tests: &unit_tests
steps:
- checkout
- run: npm install
- run: npm run test-only
- run: npm run codecov

version: 2.0
version: 2
workflows:
version: 2
tests:
jobs:
jobs: &workflow_jobs
- node6:
filters: *release_tags
filters: &all_commits
tags:
only: /.*/
- node8:
filters: *release_tags
filters: *all_commits
- node10:
filters: *release_tags
filters: *all_commits
- lint:
filters: *release_tags
- publish_npm:
requires:
- node6
- node8
- node10
filters: *all_commits
- docs:
requires:
- node6
- node8
- node10
filters: *all_commits
- system_tests:
requires:
- lint
- docs
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: /.*/
<<: *release_tags
tags: *releases
nightly:
triggers:
- schedule:
cron: 0 7 * * *
filters:
branches:
only: master
jobs: *workflow_jobs
jobs:
node6:
docker:
- image: node:6
- image: 'node:6'
user: node
<<: *unit_tests
steps: &unit_tests_steps
- checkout
- run: &npm_install_and_link
name: Install and link the module
command: |-
mkdir -p /home/node/.npm-global
npm install
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run: npm test
- run: node_modules/.bin/codecov

node8:
docker:
- image: node:8
- image: 'node:8'
user: node
<<: *unit_tests
steps: *unit_tests_steps
node10:
docker:
- image: node:10
- image: 'node:10'
user: node
<<: *unit_tests
steps: *unit_tests_steps
lint:
docker:
- image: node:8
- image: 'node:8'
user: node
steps:
- checkout
- run: npm install
- run: npm run check
- run: *npm_install_and_link
- run: &samples_npm_install_and_link
name: Link the module being tested to the samples.
command: |
cd samples/
npm link ../
npm install
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run:
name: Run linting.
command: npm run lint
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
docs:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run: *npm_install_and_link
- run:
name: Build documentation.
command: npm run docs
sample_tests:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- 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'
user: node
steps:
- checkout
- 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:
name: Run system tests.
command: npm run system-test
environment:
GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json
- run:
name: Remove unencrypted key.
command: rm .circleci/key.json
when: always
publish_npm:
docker:
- image: node:8
- image: 'node:8'
user: node
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm install
- run: npm publish
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm publish --access=public
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gcp-metadata",
"version": "0.7.0",
"description": "Get the metadata from a Google Cloud Platform environment",
"repository": "stephenplusplus/gcp-metadata",
"repository": "GoogleCloudPlatform/gcp-metadata",
"main": "./build/src/index.js",
"types": "./build/src/index.d.ts",
"files": [
Expand All @@ -17,6 +17,8 @@
"posttest": "npm run check",
"prepare": "npm run compile",
"test": "npm run test-only",
"samples-test": "echo no samples 👻",
"system-test": "echo no system test 👻",
"test-only": "nyc mocha build/test",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json"
},
Expand Down
3 changes: 3 additions & 0 deletions samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
19 changes: 19 additions & 0 deletions samples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "Samples for the gcp-metadata npm module.",
"license": "MIT",
"author": "Google LLC",
"engines": {
"node": ">=8"
},
"repository": "GoogleCloudPlatform/gcp-metadata",
"private": true,
"scripts": {
"test": "mocha system-test"
},
"dependencies": {
"gcp-metadata": "*"
},
"devDependencies": {
"mocha": "^5.2.0"
}
}
8 changes: 8 additions & 0 deletions samples/quickstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

console.warn(`no samples available 👻`);
8 changes: 8 additions & 0 deletions samples/system-test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

console.warn(`no sample tests available 👻`);
7 changes: 7 additions & 0 deletions synth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import synthtool as s
import synthtool.gcp as gcp
import logging
logging.basicConfig(level=logging.DEBUG)
common_templates = gcp.CommonTemplates()
templates = common_templates.node_library()
s.copy(templates)
3 changes: 3 additions & 0 deletions system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-console: off
8 changes: 8 additions & 0 deletions system-test/system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

console.warn(`no system tests available 👻`);
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
},
"include": [
"src/*.ts",
"test/*.ts"
"test/*.ts",
"system-test/*.ts"
],
"exclude": [
"test/fixtures"
Expand Down