Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix system tests failing on Jenkins

* Add ava

* Add Ava WIP

* Update google-cloud datastore npm dependency

* More AVA WIP

* Add nyc for code coverage

* Install yarn-breaking packages via npm instead

* Try disabling Yarn, since it's failing on Travis

* Revert "Try disabling Yarn, since it's failing on Travis"

This reverts commit 430f73e6e6d58630244fee58ef8fc812b53e0fc3.

* TODO REVERT Switch to debug fork of nodejs-repo-tools

* More travis debugging

* Finish upgrades (GoogleCloudPlatform#99)

* Done with steps 1-3

* Finish upgrades.

* Update dependencies

* Remove config.json from 7-gce

* Fix lint

* Update package.json

* Add missing return statement

* Update dependencies
  • Loading branch information
Ace Nassri authored and jmdobry committed Apr 17, 2017
1 parent 307a85e commit 2e717eb
Show file tree
Hide file tree
Showing 218 changed files with 8,134 additions and 7,209 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test/encrypted/nodejs-docs-samples.json
*.iml
.idea/
key.json
*/yarn.lock
*/yarn.lock
.nyc_output
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ cache:
directories:
- $HOME/gcloud/
- node_modules/
- 1-hello-world/node_modules/
- 2-structured-data/node_modules/
- 3-binary-data/node_modules/
- 4-auth/node_modules/
- 5-logging/node_modules/
- 6-pubsub/node_modules/
- 7-gce/node_modules/
- optional-container-engine/node_modules/

env:
global:
Expand All @@ -39,9 +31,10 @@ env:
before_install:
- openssl aes-256-cbc -K $encrypted_06352980ac5c_key -iv $encrypted_06352980ac5c_iv -in key.json.enc -out key.json -d
- npm set progress=false
- npm install -g nyc codecov

before_script:
- npm run unify
script:
- npm run cover

after_success:
- npm run codecov
- nyc report --reporter=lcov > coverage.lcov && codecov
52 changes: 52 additions & 0 deletions 1-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,55 @@ tutorial. Please refer to the tutorial for instructions on configuring, running,
and deploying this sample.

[step-1]: https://cloud.google.com/nodejs/getting-started/hello-world

# Simple instructions

1. Install [Node.js](https://nodejs.org/en/).

* Optional: Install [Yarn](https://yarnpkg.com/).

1. Install [git](https://git-scm.com/).
1. Create a [Google Cloud Platform project](https://console.cloud.google.com).
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).

* After downloading the SDK, initialize it:

gcloud init

1. Clone the repository:

git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git

1. Change directory:

cd nodejs-getting-started/1-hello-world

1. Install dependencies using NPM or Yarn:

* Using NPM:

npm install

* Using Yarn:

yarn install

1. Start the app using NPM or Yarn:

* Using NPM:

npm start

* Using Yarn:

yarn start

1. View the app at [http://localhost:8080](http://localhost:8080).

1. Stop the app by pressing `Ctrl+C`.

1. Deploy the app:

gcloud app deploy

1. View the deployed app at [https://YOUR_PROJECT_ID.appspot.com](https://YOUR_PROJECT_ID.appspot.com).
4 changes: 2 additions & 2 deletions 1-hello-world/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2016, Google, Inc.
// Copyright 2017, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -27,7 +27,7 @@ app.get('/', (req, res) => {
if (module === require.main) {
// [START server]
// Start the server
const server = app.listen(process.env.PORT || 8080, () => {
const server = app.listen(process.env.PORT || 8081, () => {
const port = server.address().port;
console.log(`App listening on port ${port}`);
});
Expand Down
6 changes: 1 addition & 5 deletions 1-hello-world/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015-2016, Google, Inc.
# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -15,7 +15,3 @@
runtime: nodejs
env: flex
# [END runtime]

# Temporary setting to keep gcloud from uploading node_modules
skip_files:
- ^node_modules$
20 changes: 12 additions & 8 deletions 1-hello-world/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "nodejs-getting-started",
"version": "1.0.0",
"description": "End to end sample for running Node.JS applications on Google Cloud Platform",
"description": "End to end sample for running Node.js applications on Google Cloud Platform",
"repository": "https://github.com/GoogleCloudPlatform/nodejs-getting-started",
"private": true,
"scripts": {
"start": "node app.js",
"monitor": "nodemon app.js",
"deploy": "gcloud app deploy app.yaml",
"test": "mocha test/index.js -t 30000"
"test": "ava -t 30s test/*.test.js | tap-dot",
"cover": "nyc --cache npm test; nyc report --reporter=html"
},
"author": "Google Inc.",
"contributors": [
Expand All @@ -23,9 +22,13 @@
{
"name": "Jason Dobry",
"email": "[email protected]"
},
{
"name": "Ace Nassri",
"email": "[email protected]"
}
],
"license": "Apache Version 2.0",
"license": "Apache-2.0",
"semistandard": {
"globals": [
"after",
Expand All @@ -37,12 +40,13 @@
]
},
"dependencies": {
"express": "^4.14.0"
"express": "~4.15.2"
},
"devDependencies": {
"mocha": "^3.0.2",
"ava": "~0.19.1",
"nodejs-repo-tools": "git+https://[email protected]/GoogleCloudPlatform/nodejs-repo-tools.git",
"supertest": "^2.0.0"
"supertest": "~3.0.0",
"tap-dot": "~1.0.5"
},
"engines": {
"node": ">=4.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2016, Google, Inc.
// Copyright 2017, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -15,11 +15,17 @@

const path = require(`path`);

const PORT = 8081;

module.exports = {
test: `1-hello-world`,
cwd: path.resolve(path.join(__dirname, '../')),
cmd: `node`,
args: [`app.js`],
port: 8081,
port: PORT,
env: {
PORT: PORT
},
url: `http://localhost:${PORT}`,
msg: `Hello, world!`
};
34 changes: 16 additions & 18 deletions 1-hello-world/test/app.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2016, Google, Inc.
// Copyright 2017, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -13,24 +13,22 @@

'use strict';

const assert = require(`assert`);
const config = require(`./config`);
const testConfig = require(`./_test-config`);
const utils = require(`nodejs-repo-tools`);
const test = require(`ava`);

describe(`app.js`, () => {
if (!process.env.E2E_TESTS) {
it(`should run`, (done) => {
utils.testLocalApp(config, done);
});
}

it(`should create an express app`, (done) => {
utils.getRequest(config)
.get(`/`)
.expect(200)
.expect((response) => {
assert.equal(response.text, config.msg);
})
.end(done);
if (!process.env.E2E_TESTS) {
test.cb(`should run`, t => {
utils.testLocalApp(testConfig, t.end);
});
}

test.cb(`should create an express app`, t => {
utils.getRequest(testConfig)
.get(`/`)
.expect(200)
.expect((response) => {
t.is(response.text, testConfig.msg);
})
.end(t.end);
});
26 changes: 0 additions & 26 deletions 1-hello-world/test/index.js

This file was deleted.

91 changes: 91 additions & 0 deletions 2-structured-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,94 @@ tutorial. Please refer to the tutorial for instructions on configuring, running,
and deploying this sample.

[step-2]: https://cloud.google.com/nodejs/getting-started/using-structured-data

# Simple instructions

1. Install [Node.js](https://nodejs.org/en/).

* Optional: Install [Yarn](https://yarnpkg.com/).

1. Install [git](https://git-scm.com/).
1. Create a [Google Cloud Platform project](https://console.cloud.google.com).
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).

* After downloading the SDK, initialize it:

gcloud init

1. Acquire local credentials for authenticating with Google Cloud Platform
services:

gcloud beta auth application-default login

1. Clone the repository:

git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git

1. Change directory:

cd nodejs-getting-started/2-structured-data

1. Create a `config.json` file (copied from the `config-default.json` file):

cp config-default.json config.json

* Set `GCLOUD_PROJECT` in `config.json` to your Google Cloud Platform
project ID.
* Set `DATA_BACKEND` in `config.json` to one of `"datastore"`, `"cloudsql"`,
or `"mongodb"`.

1. Install dependencies using NPM or Yarn:

* Using NPM:

npm install

* Using Yarn:

yarn install

1. Configure the backing store:

* If `DATA_BACKEND` is set to `"cloudsql"`:

1. Create a Cloud SQL instance, and download and start the Cloud SQL
proxy:

Instructions for doing so: https://cloud.google.com/nodejs/getting-started/using-cloud-sql#creating_a_cloud_sql_instance
1. Set `MYSQL_USER` in `config.json`, e.g. `"my-cloudsql-username"`.
1. Set `MYSQL_PASSWORD` in `config.json`, e.g. `"my-cloudsql-password"`.
1. Set `INSTANCE_CONNECTION_NAME` in `config.json`, e.g. `"YOUR_PROJECT_ID:YOUR_REGION:YOUR_INSTANCE_ID"`.
1. Run the script to setup the table:

* Using NPM:

npm run init-cloudsql

* Using Yarn:

yarn run init-cloudsql

* If `DATA_BACKEND` is set to `"mongodb"`:

1. Set `MONGO_URL` in `config.json`, e.g. `"mongodb://username:[email protected]:27017"`.

1. Start the app using NPM or Yarn:

* Using NPM:

npm start

* Using Yarn:

yarn start

1. View the app at [http://localhost:8080](http://localhost:8080).

1. Stop the app by pressing `Ctrl+C`.

1. Deploy the app:

gcloud app deploy

1. View the deployed app at [https://YOUR_PROJECT_ID.appspot.com](https://YOUR_PROJECT_ID.appspot.com).
2 changes: 1 addition & 1 deletion 2-structured-data/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2016, Google, Inc.
// Copyright 2017, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down
6 changes: 1 addition & 5 deletions 2-structured-data/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015-2016, Google, Inc.
# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -13,7 +13,3 @@
#
runtime: nodejs
env: flex

# Temporary setting to keep gcloud from uploading node_modules
skip_files:
- ^node_modules$
Loading

0 comments on commit 2e717eb

Please sign in to comment.