From ef0fa4efb81c6dcb1a96168f78c1ae6d88932925 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Thu, 2 May 2024 16:36:11 -0700 Subject: [PATCH] CI: restore test functionality with GHA - ci: add GHA workflows, test all LTS versions of node on ubuntu & macOS - package.json: populate files, limit what get published to NPM - deps(all): bump to latest versions - fix tap syntax for v18 - chore: add tap output dirs to .gitignore - ci: run minimal eslint on PRs. Fix lint issues --- .eslintrc.yml | 11 +++++++++++ .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ .travis.yml | 15 -------------- CHANGES.md | 14 ++++++++++++++ package.json | 10 ++++++---- test/test-compat.js | 1 - test/test-core.js | 18 ++++++++--------- test/test-openlog.js | 1 - test/test-setmask.js | 13 ++++++------- test/test-stream.js | 1 - test/test-syslog.js | 1 - 12 files changed, 91 insertions(+), 39 deletions(-) create mode 100644 .eslintrc.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..8628362 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,11 @@ +env: + node: true + es2021: true + +extends: eslint:recommended + +parserOptions: + ecmaVersion: latest + +rules: + no-unused-vars: 1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d630449 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + pull_request: + push: + +env: + CI: true + +jobs: + test: + needs: [get-lts] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + node-version: ${{ fromJson(needs.get-lts.outputs.active) }} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + name: Node ${{ matrix.node-version }} on ubuntu-latest + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + + get-lts: + runs-on: ubuntu-latest + steps: + - id: get + uses: msimerson/node-lts-versions@v1 + outputs: + active: ${{ steps.get.outputs.active }} + lts: ${{ steps.get.outputs.lts }} + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - run: npm run lint \ No newline at end of file diff --git a/.gitignore b/.gitignore index e3fbd98..03130ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ build node_modules +.nyc_output +.tap +package-lock.json \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 87bcdc1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: node_js -node_js: - - '8' - - '10' - - '11' - - '12' -sudo: false -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 -env: - - "CXX=g++-4.8" diff --git a/CHANGES.md b/CHANGES.md index 259d7e0..6eb76b6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,17 @@ +2024-05-02, Version 1.2.1 +========================= + + * ci: add GHA workflows, test LTS versions of node on ubuntu & macOS #45 + + * package.json: populate files, limit what get published to NPM + + * deps(all): bump to latest versions + + * chore: add tap output dirs to .gitignore + + * ci: run minimal eslint on PRs + + 2019-05-06, Version 1.2.0 ========================= diff --git a/package.json b/package.json index 33e032f..df14d42 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,13 @@ "version": "1.2.0", "description": "modern syslog - streaming, async, uses nan", "main": "index.js", + "files": [ "binding.gyp", "CHANGES.md", "core.cc", "Makefile" ], "os": [ "!win32" ], "scripts": { - "test": "tap test/test-*.js" + "lint": "npx eslint@8 *.js", + "test": "tap --allow-incomplete-coverage test/test-*.js" }, "author": "Sam Roberts ", "homepage": "http://github.com/strongloop/modern-syslog", @@ -20,11 +22,11 @@ }, "license": "MIT", "devDependencies": { - "debug": "^4.1.1", - "tap": "^13.1.2" + "debug": "^4.3.4", + "tap": "^18.7.2" }, "dependencies": { - "nan": "^2.13.2" + "nan": "^2.19.0" }, "tags": [ "log", diff --git a/test/test-compat.js b/test/test-compat.js index 898c1b0..2a63443 100644 --- a/test/test-compat.js +++ b/test/test-compat.js @@ -4,7 +4,6 @@ // License text available at https://opensource.org/licenses/MIT var Syslog = require('../'); -var assert = require('assert'); var tap = require('tap'); tap.test(function(t) { diff --git a/test/test-core.js b/test/test-core.js index d3e1ddc..e2f1aba 100644 --- a/test/test-core.js +++ b/test/test-core.js @@ -8,14 +8,14 @@ var syslog = require('../'); var tap = require('tap'); tap.test('core properties exist', function(t) { - t.assert(syslog.core); - t.assert(syslog.core.openlog); - t.assert(syslog.core.syslog); - t.assert(syslog.core.setlogmask); - t.assert(syslog.core.closelog); - t.assert(syslog.core.option.LOG_PID); - t.assert(syslog.core.facility.LOG_LOCAL0); - t.assert(syslog.core.level.LOG_DEBUG); + t.ok(syslog.core); + t.ok(syslog.core.openlog); + t.ok(syslog.core.syslog); + t.ok(syslog.core.setlogmask); + t.ok(syslog.core.closelog); + t.ok(syslog.core.option.LOG_PID); + t.ok(syslog.core.facility.LOG_LOCAL0); + t.ok(syslog.core.level.LOG_DEBUG); t.end(); }); @@ -33,7 +33,7 @@ function accept(m) { tap.test(fmt('core syslog accepts %j', m), function(t) { t.plan(1); syslog.core.syslog(syslog.core.level.LOG_DEBUG, m, function() { - t.assert(true, 'called back'); + t.ok(true, 'called back'); }); }); } diff --git a/test/test-openlog.js b/test/test-openlog.js index dac70f2..8c17aba 100644 --- a/test/test-openlog.js +++ b/test/test-openlog.js @@ -4,7 +4,6 @@ // License text available at https://opensource.org/licenses/MIT var tap = require('tap'); -var assert = require('assert'); var syslog = require('../'); var o = syslog.option; var f = syslog.facility; diff --git a/test/test-setmask.js b/test/test-setmask.js index 222be7b..000b21a 100644 --- a/test/test-setmask.js +++ b/test/test-setmask.js @@ -5,7 +5,6 @@ 'use strict'; -var assert = require('assert'); var debug = require('debug')('modern-syslog:test'); var syslog = require('../'); var tap = require('tap'); @@ -35,26 +34,26 @@ tap.test('logUpto', function(t) { t.equal(mask, 0xff); mask = upto('LOG_INFO'); t.equal(mask, 0x7f); - t.assert((1 << l.LOG_CRIT) & mask); - t.assert((1 << l.LOG_INFO) & mask); + t.ok((1 << l.LOG_CRIT) & mask); + t.ok((1 << l.LOG_INFO) & mask); t.equal((1 << l.LOG_DEBUG) & mask, 0); mask = upto('LOG_NOTICE'); t.equal(mask, 0x3f); - t.assert((1 << l.LOG_NOTICE) & mask); + t.ok((1 << l.LOG_NOTICE) & mask); t.equal((1 << l.LOG_INFO) & mask, 0); t.equal((1 << l.LOG_DEBUG) & mask, 0); mask = upto('LOG_ALERT'); t.equal(mask, 0x03); - t.assert((1 << l.LOG_EMERG) & mask); - t.assert((1 << l.LOG_ALERT) & mask); + t.ok((1 << l.LOG_EMERG) & mask); + t.ok((1 << l.LOG_ALERT) & mask); t.equal((1 << l.LOG_CRIT) & mask, 0); t.equal((1 << l.LOG_DEBUG) & mask, 0); mask = upto('LOG_EMERG'); t.equal(mask, 0x01); - t.assert((1 << l.LOG_EMERG) & mask); + t.ok((1 << l.LOG_EMERG) & mask); t.equal((1 << l.LOG_ALERT) & mask, 0); t.equal((1 << l.LOG_CRIT) & mask, 0); t.equal((1 << l.LOG_DEBUG) & mask, 0); diff --git a/test/test-stream.js b/test/test-stream.js index a2d5d34..326dc48 100644 --- a/test/test-stream.js +++ b/test/test-stream.js @@ -3,7 +3,6 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -var assert = require('assert'); var fmt = require('util').format; var syslog = require('../'); var tap = require('tap'); diff --git a/test/test-syslog.js b/test/test-syslog.js index 4b99fa2..06d2a77 100644 --- a/test/test-syslog.js +++ b/test/test-syslog.js @@ -3,7 +3,6 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -var assert = require('assert'); var fmt = require('util').format; var syslog = require('../'); var tap = require('tap');