Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Update CI config. #293

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
126 changes: 62 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,88 @@ workflows:
version: 2
tests:
jobs: &workflow_jobs
- node6:
filters:
tags:
only: /.*/
# - node8:
# filters:
# tags:
# only: /.*/
# - node10:
# filters:
# tags:
# only: /.*/
- lint:
requires:
- node6
# - node8
# - node10
filters:
filters: &all_commits
tags:
only: /.*/
- system_tests:
- node6:
requires:
- lint
filters:
branches:
only: master
tags:
only: '/^v[\d.]+$/'
- publish_npm:
filters: *all_commits
- node8:
requires:
- system_tests
- lint
filters: *all_commits
nightly:
triggers:
- schedule:
cron: 0 7 * * *
filters:
branches:
ignore: /.*/
tags:
only: '/^v[\d.]+$/'
only: master
jobs: *workflow_jobs
jobs:
lint:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run: &npm_install_and_link
name: Install and link the module
command: |-
mkdir -p /home/node/.npm-global
./.circleci/npm-install-retry.js
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run:
name: Run linting.
command: npm run lint
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
node6:
docker:
- image: 'node:6'
steps: &unit_tests_steps
user: node
steps: &tests_steps
- checkout
- run:
name: Decrypt credentials.
command: |
if ! [[ -z "${SERVICE_ACCOUNT_ENCRYPTION_KEY}" ]]; then
for encrypted_key in .circleci/*.json.enc; do
openssl aes-256-cbc -d -in $encrypted_key \
-out $(echo $encrypted_key | sed 's/\.enc//') \
-k "${SERVICE_ACCOUNT_ENCRYPTION_KEY}"
done
fi
- run:
name: Install and configure Cloud SDK
command: |
echo $KEYFILE > key.json
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-209.0.0-linux-x86_64.tar.gz | tar xz
mv ./google-cloud-sdk /opt
export PATH=$PATH:/opt/google-cloud-sdk/bin
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-228.0.0-linux-x86_64.tar.gz | tar xz -C /tmp
export PATH=$PATH:/tmp/google-cloud-sdk/bin
gcloud components install beta -q
gcloud components update -q
gcloud config set project cloud-functions-emulator
gcloud config set compute/region us-central1
gcloud auth activate-service-account --key-file key.json
- run: yarn
- run: yarn test
gcloud auth activate-service-account --key-file .circleci/key.json
- run: *npm_install_and_link
- run:
name: Run tests.
command: npm test
environment:
GCLOUD_PROJECT: cloud-functions-emulator
GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json
- run: node_modules/.bin/codecov
# node8:
# docker:
# - image: 'node:8'
# steps: *unit_tests_steps
# node10:
# docker:
# - image: 'node:10'
# steps: *unit_tests_steps
lint:
docker:
- image: 'node:6'
steps:
- checkout
- run: yarn install
- run: npm run lint
system_tests:
- run:
name: Remove unencrypted key.
command: |
if ! [[ -z "${SERVICE_ACCOUNT_ENCRYPTION_KEY}" ]]; then
rm .circleci/*.json
fi
when: always
node8:
docker:
- image: 'node:6'
- image: 'node:8'
user: node
steps:
- checkout
- run: yarn
- run: yarn run system-test
publish_npm:
docker:
- image: 'node:10'
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm publish
steps: *tests_steps
Binary file added .circleci/key.json.enc
Binary file not shown.
60 changes: 60 additions & 0 deletions .circleci/npm-install-retry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env node

let spawn = require('child_process').spawn;

//
//USE: ./index.js <ms npm can be idle> <number of attempts> [... NPM ARGS]
//

let timeout = process.argv[2] || 60000;
let attempts = process.argv[3] || 3;
let args = process.argv.slice(4);
if (args.length === 0) {
args = ['install'];
}

(function npm() {
let timer;
args.push('--verbose');
let proc = spawn('npm', args);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
proc.stdin.end();
proc.stdout.on('data', () => {
setTimer();
});
proc.stderr.on('data', () => {
setTimer();
});

// side effect: this also restarts when npm exits with a bad code even if it
// didnt timeout
proc.on('close', (code, signal) => {
clearTimeout(timer);
if (code || signal) {
console.log('[npm-are-you-sleeping] npm exited with code ' + code + '');

if (--attempts) {
console.log('[npm-are-you-sleeping] restarting');
npm();
} else {
console.log('[npm-are-you-sleeping] i tried lots of times. giving up.');
throw new Error("npm install fails");
}
}
});

function setTimer() {
clearTimeout(timer);
timer = setTimeout(() => {
console.log('[npm-are-you-sleeping] killing npm with SIGTERM');
proc.kill('SIGTERM');
// wait a couple seconds
timer = setTimeout(() => {
// its it's still not closed sigkill
console.log('[npm-are-you-sleeping] killing npm with SIGKILL');
proc.kill('SIGKILL');
}, 2000);
}, timeout);
}
})();
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##### 1.0.0-beta.6 - XX November 2018

###### Breaking changes
- Removed support for using the Gcloud SDK to interact with the emulator
- Removed used of googleapis library

###### Other
- Upgraded all dependencies

##### 1.0.0-beta.5 - 31 July 2018

###### Bug fixes
Expand Down
39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@google-cloud/functions-emulator",
"description": "Google Cloud Functions Emulator",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"scripts": {
"lint": "semistandard",
"fix": "semistandard --fix",
"mocha": "mocha test/_setup test/ --recursive -t 120000 -S -R spec --require intelli-espower-loader",
"mocha": "mocha test/_setup test/system/ --recursive -t 120000 -S -R spec --require intelli-espower-loader",
"unit-test": "npm run mocha -- --grep \"unit/\"",
"system-test": "npm run mocha -- --grep \"system/\"",
"mocha-debug": "mocha debug test/_setup test/ --recursive -t 120000 -S -R spec --require intelli-espower-loader",
Expand All @@ -73,17 +73,16 @@
"generate-scaffolding": "repo-tools generate contributors coc contributing license pr_template pkgjson"
},
"dependencies": {
"@google-cloud/storage": "^1.7.0",
"adm-zip": "^0.4.11",
"ajv": "^6.5.2",
"@google-cloud/storage": "1.7.0",
"adm-zip": "^0.4.13",
"ajv": "^6.5.5",
"axios": "^0.18.0",
"body-parser": "^1.18.3",
"chokidar": "^2.0.4",
"cli-table3": "^0.5.1",
"colors": "^1.3.1",
"colors": "^1.3.2",
"configstore": "^4.0.0",
"express": "^4.16.3",
"googleapis": "^35.0.0",
"got": "^9.0.0",
"express": "^4.16.4",
"http-proxy": "^1.17.0",
"lodash": "4.17.11",
"make-dir": "1.3.0",
Expand All @@ -92,23 +91,23 @@
"semver": "5.6.0",
"serializerr": "1.0.3",
"tmp": "0.0.33",
"uuid": "3.2.1",
"uuid": "3.3.2",
"winston": "3.1.0",
"xdg-basedir": "3.0.0",
"yargs": "11.0.0"
"yargs": "12.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"codecov": "^3.0.4",
"@google-cloud/nodejs-repo-tools": "2.3.5",
"codecov": "^3.1.0",
"intelli-espower-loader": "^1.0.1",
"mocha": "^5.2.0",
"nock": "^10.0.0",
"nyc": "^13.0.0",
"power-assert": "^1.6.0",
"proxyquire": "^2.0.0",
"semistandard": "^13.0.0",
"nock": "^10.0.2",
"nyc": "^13.1.0",
"power-assert": "^1.6.1",
"proxyquire": "^2.1.0",
"semistandard": "^13.0.1",
"semistandard-format": "^3.0.0",
"sinon": "^7.0.0",
"supertest": "^3.0.0"
"sinon": "^7.1.1",
"supertest": "^3.3.0"
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports.handler = (opts) => {
function poll () {
controller.write('.');
controller.client.getOperation(operation.name)
.then(([operation]) => {
.then((operation) => {
if (!operation.done) {
setTimeout(poll, 500);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ exports.handler = (opts) => {
return controller.doIfRunning()
// Deploy the function
.then(() => controller.deploy(opts.functionName, opts))
.then(([operation, response]) => {
.then(([operation]) => {
// Poll the operation
return new Promise((resolve, reject) => {
function poll () {
controller.write('.');
controller.client.getOperation(operation.name)
.then(([operation]) => {
.then((operation) => {
if (!operation.done) {
setTimeout(poll, 500);
} else {
Expand Down
Loading