Run tests via github actions

This commit is contained in:
Lars Strojny 2022-11-08 22:15:44 +01:00
parent 9c9e0e4871
commit 25b9afa1d2
5 changed files with 96 additions and 249 deletions

View file

@ -11,10 +11,14 @@ jobs:
matrix: matrix:
# the Node.js versions to build on # the Node.js versions to build on
node-version: [14.x, 16.x, 17.x, 18.x] node-version: [14.x, 16.x, 17.x, 18.x]
fail-on-lint: [true] allow-lint-failure: [false]
allow-test-failure: [false]
include: include:
- { node-version: 13.x, fail-on-lint: false } - { node-version: 10.x, allow-lint-failure: true, allow-test-failure: true }
- { node-version: 15.x, fail-on-lint: false } - { node-version: 11.x, allow-lint-failure: true, allow-test-failure: true }
- { node-version: 12.x, allow-lint-failure: true, allow-test-failure: true }
- { node-version: 13.x, allow-lint-failure: true, allow-test-failure: true }
- { node-version: 15.x, allow-lint-failure: true, allow-test-failure: false }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -29,9 +33,11 @@ jobs:
- name: Lint the project - name: Lint the project
run: npm run lint run: npm run lint
continue-on-error: ${{ ! matrix.fail-on-lint }} continue-on-error: ${{ matrix.allow-lint-failure }}
- name: Run tests
run: npm test
continue-on-error: ${{ matrix.allow-test-failure }}
- name: Build the project - name: Build the project
run: npm run build run: npm run build
env:
CI: true

View file

@ -1,7 +1,6 @@
{ {
"watch": ["src"], "watch": ["./"],
"ext": "ts", "ignore": ["dist/*", "tests/*"],
"ignore": [],
"exec": "tsc && homebridge -D -U dot-homebridge", "exec": "tsc && homebridge -D -U dot-homebridge",
"signal": "SIGTERM", "signal": "SIGTERM",
"env": { "env": {

307
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -17,13 +17,11 @@
}, },
"main": "dist/src/index.js", "main": "dist/src/index.js",
"scripts": { "scripts": {
"lint": "npm run format && eslint --ignore-path=.gitignore '**/**.{ts,js,json}'", "lint": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; `npm bin`/prettier --ignore-path=.gitignore `ifNotCi --write --check` '**/**.{ts,js,json}' && `npm bin`/eslint `ifNotCi --fix` --ignore-path=.gitignore '**/**.{ts,js,json}'",
"watch": "npm run build && npm run link && nodemon", "start": "npm run build && npm run link && nodemon",
"watch-tests": "jest --watch", "test": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; `npm bin`/jest `ifNotCi --watchAll`",
"tests": "jest",
"link": "npm install --no-save file:///$PWD/", "link": "npm install --no-save file:///$PWD/",
"build": "rimraf ./dist && tsc", "build": "rimraf ./dist && tsc",
"format": "prettier --ignore-path=.gitignore --write '**/**.{ts,js,json}'",
"prepublishOnly": "npm run lint && npm run build" "prepublishOnly": "npm run lint && npm run build"
}, },
"keywords": [ "keywords": [
@ -40,6 +38,8 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"homebridge": "^1.3.5", "homebridge": "^1.3.5",
"homebridge-cmdswitch2": "^0.2.10", "homebridge-cmdswitch2": "^0.2.10",
"jest": "^29.3.0",
"json-schema-to-zod": "^0.2.0",
"nodemon": "^2.0.13", "nodemon": "^2.0.13",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
@ -51,7 +51,6 @@
"fastify": "^4.9.2", "fastify": "^4.9.2",
"hap-node-client": "git+https://github.com/NorthernMan54/Hap-Node-Client.git#fe200ba", "hap-node-client": "git+https://github.com/NorthernMan54/Hap-Node-Client.git#fe200ba",
"hap-nodejs": "^0.10.4", "hap-nodejs": "^0.10.4",
"json-schema-to-zod": "^0.2.0",
"zod": "^3.19.1" "zod": "^3.19.1"
}, },
"overrides": { "overrides": {

View file

@ -26,7 +26,7 @@ export class PrometheusExporterPlatform implements IndependentPlatformPlugin {
} }
}) })
this.log.debug('Starting probe HTTP server on port %d', this.config.port) this.log.debug('Starting Prometheus HTTP server on port %d', this.config.port)
this.httpServer = new PrometheusServer(this.config.port, this.log, this.config.debug, this.config.prefix) this.httpServer = new PrometheusServer(this.config.port, this.log, this.config.debug, this.config.prefix)
serve(this.httpServer) serve(this.httpServer)
@ -35,7 +35,7 @@ export class PrometheusExporterPlatform implements IndependentPlatformPlugin {
this.httpServerController = httpServerController this.httpServerController = httpServerController
}) })
.catch((e) => { .catch((e) => {
this.log.error('Failed to start probe HTTP server on port %d: %o', this.config.port, e) this.log.error('Failed to start Prometheus HTTP server on port %d: %o', this.config.port, e)
}) })
this.api.on('didFinishLaunching', () => { this.api.on('didFinishLaunching', () => {