Skip to content

Commit

Permalink
Merge branch 'master' into 1.106.1
Browse files Browse the repository at this point in the history
  • Loading branch information
krdlab authored Mar 23, 2020
2 parents 955b939 + cd819df commit 68d4916
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: testing

on:
push:
paths:
- 'lib/**.js'

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install

- name: Run smoke tests
timeout-minutes: 2
run: |
touch .credential
echo ${{ secrets.DIRECT_TESTING_USER }} >> .credential
echo ${{ secrets.DIRECT_TESTING_PASSWORD }} >> .credential
node test/login.js < .credential
node test/smoke.js
- name: Remove credentials
run: rm -f .credential .env
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ lib/*.map
lib/sample.*
lib/example.*
example/
test/
.github/
bower.json
25 changes: 25 additions & 0 deletions test/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2020 L is B Corp.
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

const direct = require("../lib/direct-node.min.js").DirectAPI;
const fs = require("fs");
const url = require("url");

const endpoint = "wss://api.direct4b.com/albero-app-server/api";

const client = direct.getInstance();

client.setOptions({
host: url.parse(endpoint).host,
endpoint: endpoint
});

client.on("access_token_changed", token => {
fs.writeFileSync(".env", `HUBOT_DIRECT_TOKEN=${token}`);
console.log("logged in.");
process.exit();
});

client.listen();
35 changes: 35 additions & 0 deletions test/smoke.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2020 L is B Corp.
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

const direct = require("../lib/direct-node.min.js").DirectAPI;
const fs = require("fs");
const url = require("url");

const endpoint = "wss://api.direct4b.com/albero-app-server/api";
const accessToken = fs
.readFileSync(".env")
.toString()
.replace("HUBOT_DIRECT_TOKEN=", "");

const client = direct.getInstance();

client.setOptions({
host: url.parse(endpoint).host,
endpoint: endpoint,
access_token: accessToken
});

client.on("data_recovered", () => {
console.log("Good");
process.exit();
});

client.on("error_occurred", (err, data) => {
console.error(`Bad: ${err}`);
console.log(data);
process.exit(1);
});

client.listen();

0 comments on commit 68d4916

Please sign in to comment.