Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

add synth file and standardize config #64

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
167 changes: 133 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,70 +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:
requires:
- node6
- node8
- node10
filters: *release_tags
- publish_npm:
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_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: npm install
- run: npm run check
- 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: node8
- image: 'node:8'
user: node
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm install
- run: npm publish
- npm install
- run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
- run: npm publish --access=public
Binary file added .circleci/key.json.enc
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"prepare": "npm run compile",
"pretest-only": "npm run compile",
"posttest": "npm run check",
"license-check": "jsgl --local ."
"license-check": "jsgl --local .",
"samples-test": "mocha samples/system-test",
"system-test": "mocha build/system-test"
},
"files": [
"LICENSE",
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 google-p12-pem npm module.",
"license": "MIT",
"author": "Google LLC",
"engines": {
"node": ">=8"
},
"repository": "google/google-p12-pem",
"private": true,
"scripts": {
"test": "mocha system-test"
},
"dependencies": {
"google-p12-pem": "*"
},
"devDependencies": {
"mocha": "^5.2.0"
}
}
8 changes: 8 additions & 0 deletions src/bin/gp12-pem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/usr/bin/env node

/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

import * as gp12 from '../index';

const argv = process.argv;
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

import * as fs from 'fs';
import * as forge from 'node-forge';
import * as pify from 'pify';
Expand Down
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 👻`);
7 changes: 7 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

import * as assert from 'assert';
import * as fs from 'fs';
import {getPem} from '../src/index';
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"src/*.ts",
"src/**/*.ts",
"test/*.ts",
"test/**/*.ts"
"system-test/*.ts"
],
"exclude": [
"node_modules"
Expand Down