Skip to content

Commit fad8ad6

Browse files
authoredFeb 15, 2022
chores: update CI (#1421)
* update CI * Delete syncToDevOps.yml * update yaml * allow package lock updates * add package lock * updates * fixes for testing * fix typo * remove eslint * updates to testing * update yaml * continue on error * remove eslint * fixing ci issues
1 parent 28c4040 commit fad8ad6

14 files changed

+18054
-187
lines changed
 

‎.airtaprc.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
sauce_connect: true
1+
providers:
2+
- airtap-system
3+
- airtap-playwright
24
ui: mocha-bdd
35
browsers:
4-
- name: chrome
6+
- name: chromium
57
version: latest
68
- name: firefox
79
version: latest
810
- name: opera
911
version: latest
10-
- name: internet explorer
11-
version: latest
12-
- name: microsoftedge
13-
version: latest

‎.github/workflows/mqttjs-test.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: MQTT.js Tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
logLevel:
7+
description: 'Debug Filter'
8+
required: true
9+
default: 'mqttjs*'
10+
push:
11+
branches: [ main ]
12+
pull_request:
13+
branches: [ main ]
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
node-version: [12.x, 14.x, 16.x]
21+
fail-fast: false
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
- run: npm ci
31+
- name: Node Tests
32+
run: npm run test:node
33+
continue-on-error: true
34+
env:
35+
CI: true
36+
DEBUG: "mqttjs"
37+
- name: Test Typescript
38+
run: npm run test:typescript
39+
env:
40+
CI: true
41+
DEBUG: "mqttjs"
42+

‎.github/workflows/nodejs.yml

-32
This file was deleted.

‎.github/workflows/syncToDevOps.yml

-23
This file was deleted.

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ coverage
1515
test/typescript/.idea/*
1616
test/typescript/*.js
1717
test/typescript/*.map
18-
package-lock.json
1918
# VS Code stuff
2019
**/typings/**
2120
**/.vscode/**

‎.npmrc

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
package-lock = false

‎CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Individuals making significant and valuable contributions are given commit-acces
1111
There are a few basic ground-rules for contributors:
1212

1313
1. **No `--force` pushes** or modifying the Git history in any way.
14-
1. **Non-master branches** ought to be used for ongoing work.
14+
1. **Non-main branches** ought to be used for ongoing work.
1515
1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors.
1616
1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor.
1717
1. Contributors should attempt to adhere to the prevailing code-style.

‎README.md

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
MQTT.js is a client library for the [MQTT](http://mqtt.org/) protocol, written
77
in JavaScript for node.js and the browser.
88

9-
| :warning: WARNING |
10-
|:---------------------------|
11-
| our default branch has been moved from *master* to *main* |
12-
139
| :boom: MQTT.js vNext |
1410
|:---------------------------|
1511
| Want to contribute to the next generation of **MQTT.js**? Join the discussion [here](https://github.com/mqttjs/MQTT.js/discussions/1324). |

‎package-lock.json

+17,950
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+14-23
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@
2222
"main": "mqtt.js",
2323
"types": "types/index.d.ts",
2424
"scripts": {
25-
"test": "node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha --exit",
2625
"pretest": "standard | snazzy",
27-
"tslint": "tslint types/**/*.d.ts",
2826
"typescript-compile-test": "tsc -p test/typescript/tsconfig.json",
29-
"typescript-compile-execute": "node test/typescript/*.js",
30-
"typescript-test": "npm run typescript-compile-test && npm run typescript-compile-execute",
27+
"typescript-compile-execute": "node test/typescript/broker-connect-subscribe-and-publish.js",
3128
"browser-build": "rimraf dist/ && mkdirp dist/ && browserify mqtt.js --standalone mqtt > dist/mqtt.js && uglifyjs dist/mqtt.js --compress --mangle --output dist/mqtt.min.js",
3229
"prepare": "npm run browser-build",
33-
"browser-test": "airtap --server test/browser/server.js --local --open test/browser/test.js",
34-
"sauce-test": "airtap --server test/browser/server.js -- test/browser/test.js",
35-
"ci": "npm run tslint && npm run typescript-compile-test && npm run test && codecov"
30+
"unit-test:node": "node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha --exit",
31+
"unit-test:browser": "airtap --server test/browser/server.js test/browser/test.js",
32+
"test:node": "npm run unit-test:node && codecov",
33+
"test:browser": "npm run browser-build && npm run unit-test:browser",
34+
"test:typescript": "npm run typescript-compile-test && npm run typescript-compile-execute",
35+
"test": "npm run test:node && npm run test:typescript"
3636
},
3737
"pre-commit": [
38-
"pretest",
39-
"tslint"
38+
"pretest"
4039
],
4140
"bin": {
4241
"mqtt_pub": "./bin/pub.js",
@@ -82,16 +81,18 @@
8281
},
8382
"devDependencies": {
8483
"@types/node": "^10.0.0",
84+
"@types/tape": "^4.13.2",
8585
"@types/ws": "^7.4.7",
86-
"aedes": "^0.42.5",
86+
"aedes": "^0.46.2",
8787
"airtap": "^4.0.4",
8888
"browserify": "^16.5.0",
8989
"chai": "^4.2.0",
90+
"chokidar": "^3.5.3",
9091
"codecov": "^3.0.4",
9192
"end-of-stream": "^1.4.1",
9293
"global": "^4.3.2",
9394
"mkdirp": "^0.5.1",
94-
"mocha": "^9.1.3",
95+
"mocha": "^9.2.0",
9596
"mqtt-connection": "^4.0.0",
9697
"nyc": "^15.0.1",
9798
"pre-commit": "^1.2.2",
@@ -100,23 +101,13 @@
100101
"sinon": "^9.0.0",
101102
"snazzy": "^9.0.0",
102103
"standard": "^16.0.4",
103-
"tslint": "^5.11.0",
104-
"tslint-config-standard": "^8.0.1",
105-
"typescript": "^3.2.2",
104+
"tape": "^5.5.2",
105+
"typescript": "^4.5.5",
106106
"uglify-es": "^3.3.9"
107107
},
108108
"standard": {
109109
"env": [
110110
"mocha"
111-
],
112-
"globals": [
113-
"expect",
114-
"test",
115-
"describe",
116-
"it",
117-
"beforeEach",
118-
"beforeAll",
119-
"afterAll"
120111
]
121112
}
122113
}

‎test/browser/test.js

+21-79
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

3+
const test = require('tape')
34
const mqtt = require('../../lib/connect')
4-
const xtend = require('xtend')
55
const _URL = require('url')
66
// eslint-disable-next-line
77
const parsed = _URL.parse(document.URL)
@@ -10,85 +10,27 @@ const port = parsed.port || (isHttps ? 443 : 80)
1010
const host = parsed.hostname
1111
const protocol = isHttps ? 'wss' : 'ws'
1212

13-
function clientTests (buildClient) {
14-
let client
15-
16-
// eslint-disable-next-line
17-
beforeEach(function () {
18-
client = buildClient()
19-
client.on('offline', function () {
20-
console.log('client offline')
21-
})
22-
client.on('connect', function () {
23-
console.log('client connect')
24-
})
25-
client.on('reconnect', function () {
26-
console.log('client reconnect')
27-
})
28-
})
29-
30-
afterEach(function (done) {
31-
client.once('close', function () {
32-
done()
13+
const client = mqtt.connect({ protocolId: 'MQIsdp', protocolVersion: 3, protocol: protocol, port: port, host: host })
14+
client.on('offline', function () {
15+
console.log('client offline')
16+
})
17+
client.on('connect', function () {
18+
console.log('client connect')
19+
})
20+
client.on('reconnect', function () {
21+
console.log('client reconnect')
22+
})
23+
24+
test('MQTT.js browser test', function (t) {
25+
t.plan(2)
26+
client.on('connect', function () {
27+
client.on('message', function (msg) {
28+
t.equal(msg, 'Hello World!')
3329
})
34-
client.end()
35-
})
36-
37-
it('should connect', function (done) {
38-
client.on('connect', function () {
39-
done()
40-
})
41-
})
42-
43-
it('should publish and subscribe', function (done) {
4430
client.subscribe('hello', function () {
45-
done()
46-
}).publish('hello', 'world')
31+
}).publish('hello', 'Hello World!')
4732
})
48-
}
49-
50-
function suiteFactory (configName, opts) {
51-
function setVersion (base) {
52-
return xtend(base || {}, opts)
53-
}
54-
55-
const suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
56-
describe(suiteName, function () {
57-
this.timeout(10000)
58-
59-
describe('specifying nothing', function () {
60-
clientTests(function () {
61-
return mqtt.connect(setVersion())
62-
})
63-
})
64-
65-
if (parsed.hostname === 'localhost') {
66-
describe('specifying a port', function () {
67-
clientTests(function () {
68-
return mqtt.connect(setVersion({ protocol: protocol, port: port }))
69-
})
70-
})
71-
}
72-
73-
describe('specifying a port and host', function () {
74-
clientTests(function () {
75-
return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
76-
})
77-
})
78-
79-
describe('specifying a URL', function () {
80-
clientTests(function () {
81-
return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
82-
})
83-
})
84-
85-
describe('specifying a URL with a path', function () {
86-
clientTests(function () {
87-
return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
88-
})
89-
})
33+
client.once('close', function () {
34+
t.true(true)
9035
})
91-
}
92-
93-
suiteFactory('v3', { protocolId: 'MQIsdp', protocolVersion: 3 })
94-
suiteFactory('default', {})
36+
})
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// relative path uses package.json {"types":"types/index.d.ts", ...}
2+
import test from 'tape'
23
import {IClientOptions, Client, connect, IConnackPacket, UniqueMessageIdProvider} from '../..'
34
const BROKER = 'test.mosquitto.org'
45

@@ -9,18 +10,24 @@ const TOPIC = 'typescript-test-' + Math.random().toString(16).substr(2)
910
const opts: IClientOptions = {will: {topic: TOPIC, payload: PAYLOAD_WILL, qos: 0, retain: false},
1011
messageIdProvider: new UniqueMessageIdProvider()}
1112

12-
console.log(`connect(${JSON.stringify(BROKER)})`)
13-
const client:Client = connect(`mqtt://${BROKER}`, opts)
14-
15-
client.subscribe({[TOPIC]: {qos: 2}}, (err, granted) => {
16-
granted.forEach(({topic, qos}) => {
17-
console.log(`subscribed to ${topic} with qos=${qos}`)
13+
test('client test', function (t) {
14+
t.plan(1)
15+
console.log(`connect(${JSON.stringify(BROKER)})`)
16+
const client:Client = connect(`mqtt://${BROKER}`, opts)
17+
client.subscribe({[TOPIC]: {qos: 2}}, (err, granted) => {
18+
granted.forEach(({topic, qos}) => {
19+
console.log(`subscribed to ${topic} with qos=${qos}`)
20+
})
21+
client.publish(TOPIC, PAYLOAD_QOS, {qos: 2})
22+
client.publish(TOPIC, PAYLOAD_RETAIN, {retain: true})
23+
}).on('message', (topic: string, payload: Buffer) => {
24+
t.ok(payload)
25+
console.log(`message from ${topic}: ${payload}`)
26+
client.end(true, () => {
27+
console.log('client closed')
28+
t.end()
29+
})
30+
}).on('connect', (packet: IConnackPacket) => {
31+
console.log('connected!', JSON.stringify(packet))
1832
})
19-
client.publish(TOPIC, PAYLOAD_QOS, {qos: 2})
20-
client.publish(TOPIC, PAYLOAD_RETAIN, {retain: true})
21-
}).on('message', (topic: string, payload: Buffer) => {
22-
console.log(`message from ${topic}: ${payload}`)
23-
client.end()
24-
}).on('connect', (packet: IConnackPacket) => {
25-
console.log('connected!', JSON.stringify(packet))
2633
})

‎test/typescript/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"strictNullChecks": true,
1010
"noImplicitReturns": true,
1111
"noImplicitThis": true,
12-
"sourceMap": true
12+
"sourceMap": true,
13+
"esModuleInterop": true
1314
}
1415
}

‎tslint.json

-3
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.