From 1bafd8dd239f84e6807cc634bd626fae62df5e80 Mon Sep 17 00:00:00 2001 From: Fabrizio Mirabito Date: Thu, 18 Jun 2020 15:02:54 +0200 Subject: [PATCH 1/2] Run tests using GitHub actions --- .github/workflows/test.yaml | 27 +++++++++++++++++++++++++++ jest.config.js | 3 ++- test/arduino-cloud.test.js | 12 ++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..73430d8 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,27 @@ +name: test + +on: + pull_request: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Disable EOL conversions + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@master + + - name: Integration tests + uses: actions/setup-node@v1 + with: + node-version: '12' + - run: npm install + - run: npm run test + env: + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 24d9b09..2e79d63 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ module.exports = { globals: { - token: process.env.TOKEN, + clientId: process.env.CLIENT_ID, + clientSecret: process.env.CLIENT_SECRET, }, verbose: true, setupFiles: [ diff --git a/test/arduino-cloud.test.js b/test/arduino-cloud.test.js index 7a2ec9c..f6578c6 100644 --- a/test/arduino-cloud.test.js +++ b/test/arduino-cloud.test.js @@ -19,8 +19,8 @@ */ const { ArduinoIoTCloud, SenML } = require('../lib/index.js'); -const deviceId = '1f4ced70-53ad-4b29-b221-1b0abbdfc757'; -const thingId = '2cea8542-d472-4464-859c-4ef4dfc7d1d3'; +const deviceId = '1e5b4cdd-57da-4c68-9dfd-439e493f7c79'; +const thingId = '82b903fe-4387-47ed-a503-201619b949fe'; const propertyIntName = 'integer'; const propertyIntValue = 22; @@ -37,7 +37,8 @@ describe('Test the library basic functionalities', () => { it('ArduinoCloud connection', (done) => { /* global token */ ArduinoIoTCloud.connect({ - token, + clientId, + clientSecret, onDisconnect: (message) => { if (message.errorCode !== 0) { throw Error(message); @@ -53,7 +54,10 @@ describe('Test the library basic functionalities', () => { describe("when connected", () => { beforeEach((done) => { - ArduinoIoTCloud.connect({ token }).then(() => done()); + ArduinoIoTCloud.connect({ + clientId, + clientSecret, + }).then(() => done()); }) it('Property name must be a string in sendProperty', (done) => { From 2367ab67a111218b7133715e21003af77f40cfc5 Mon Sep 17 00:00:00 2001 From: pirropirro Date: Thu, 18 Jun 2020 17:24:24 +0200 Subject: [PATCH 2/2] Add lint before run test --- .github/workflows/test.yaml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 73430d8..c423ba2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,7 @@ jobs: with: node-version: '12' - run: npm install + - run: npm run lint - run: npm run test env: CLIENT_ID: ${{ secrets.CLIENT_ID }} diff --git a/package.json b/package.json index 51551ae..877ffd3 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "clean": "rimraf lib es", "build:es": "rollup -c", "build:lib": "rollup -c ./rollup.config.lib.js", - "build": "npm run clean && npm run lint && npm run build:es && npm run build:lib" + "build": "npm run clean && npm run build:es && npm run build:lib" }, "repository": { "type": "git",