Skip to content

Commit

Permalink
ci: re-enable node example (#219)
Browse files Browse the repository at this point in the history
* Revert "ci: remove run-node-example"

This reverts commit fced937.

* Revert "github/workflows/ci: disable node example"

This reverts commit bf01313.

* github/workflows: node 12 please

* ci: exit on failure

wat

* examples/node: simplify & reformat code

Co-authored-by: francisco souza <[email protected]>
  • Loading branch information
fsouza and fsouza authored Apr 20, 2020
1 parent 3ad4145 commit 27773eb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ jobs:
entrypoint: sh
args: ci/run-python-example.sh

- name: test-node-example
uses: docker://node:12-alpine
with:
entrypoint: sh
args: ci/run-node-example.sh

- name: test-go-example
uses: docker://golang:1.14-alpine
env:
Expand Down
2 changes: 2 additions & 0 deletions ci/run-go-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

set -e

./fake-gcs-server -backend memory -data $PWD/examples/data -public-host storage.gcs.127.0.0.1.nip.io:4443 &

(
Expand Down
13 changes: 13 additions & 0 deletions ci/run-node-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 Francisco Souza. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

set -e

./fake-gcs-server -backend memory -data $PWD/examples/data &

(
cd examples/node
npm ci
node index.js
)
2 changes: 2 additions & 0 deletions ci/run-python-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

set -e

./fake-gcs-server -backend memory -data $PWD/examples/data &

pip install -r examples/python/requirements.txt
Expand Down
10 changes: 6 additions & 4 deletions examples/node/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
process.on("unhandledRejection", err => {throw err});

async function listBuckets() {
// [START storage_list_buckets]
// Imports the Google Cloud client library
const {Storage} = require("@google-cloud/storage");
const { Storage } = require("@google-cloud/storage");

// Creates a client
const storage = new Storage({
Expand All @@ -15,10 +14,13 @@ async function listBuckets() {
// Lists all buckets in the current project
const [buckets] = await storage.getBuckets();
console.log("Buckets:");
buckets.forEach(bucket => {
buckets.forEach((bucket) => {
console.log(bucket.id);
});
// [END storage_list_buckets]
}

listBuckets().then(console.log);
listBuckets().catch((err) => {
console.error(err);
process.exit(1);
});

0 comments on commit 27773eb

Please sign in to comment.