From c761a4c97ced00b82e2c6c28de033dd220e2609f Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Mon, 6 Jun 2022 00:44:17 -0700 Subject: [PATCH] Release v1.1.7 (#26) - ci: replace travis & appveyor with GitHub actions - test: replace nodeunit with mocha - test: update header checks against lower cased header names --- .codeclimate.yml | 6 ++--- .eslintrc.yaml | 1 + .github/PULL_REQUEST_TEMPLATE.md | 2 -- .github/dependabot.yml | 10 ++++++++ .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 13 ++++++++++ .github/workflows/publish.yml | 14 +++++++++++ .gitignore | 3 ++- .gitmodules | 3 +++ .release | 1 + .travis.yml | 28 ---------------------- Changes.md | 7 ++++-- appveyor.yml | 20 ---------------- index.js | 10 ++++---- package.json | 15 ++++++------ test/index.js | 14 +++++------ 16 files changed, 112 insertions(+), 76 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .gitmodules create mode 160000 .release delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.codeclimate.yml b/.codeclimate.yml index 75cf8a1..0e443ca 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,9 +1,9 @@ -engines: +engines: eslint: enabled: true - channel: "eslint-3" + channel: "eslint-8" config: - config: ".eslintrc.json" + config: ".eslintrc.yaml" ratings: paths: diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b76f332..12725db 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -2,6 +2,7 @@ env: node: true es6: true mocha: true + es2020: true plugins: - haraka diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a3b4db0..957ccf3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,5 +8,3 @@ Checklist: - [ ] docs updated - [ ] tests updated - [ ] Changes.md updated -- [ ] package.json.version bumped -- [ ] published to NPM (will be done by @core) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0449e4a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + allow: + - dependency-type: production diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d768329 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: [ push ] + +env: + CI: true + +jobs: + + lint: + uses: haraka/.github/.github/workflows/lint.yml@master + + # coverage: + # uses: haraka/.github/.github/workflows/coverage.yml@master + # secrets: inherit + + test: + needs: [ lint, get-lts ] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + node-version: ${{ fromJson(needs.get-lts.outputs.active) }} + fail-fast: false + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + name: Node ${{ matrix.node-version }} on ${{ matrix.os }} + 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 }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..383aca2 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,13 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: '18 7 * * 4' + +jobs: + codeql: + uses: haraka/.github/.github/workflows/codeql.yml@master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..42a9bb9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,14 @@ +name: publish + +on: + push: + branches: + - master + +env: + CI: true + +jobs: + publish: + uses: haraka/.github/.github/workflows/publish.yml@master + secrets: inherit \ No newline at end of file diff --git a/.gitignore b/.gitignore index eba3cc2..924a4ab 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,5 @@ jspm_packages # Optional REPL history .node_repl_history -package-lock.json \ No newline at end of file +package-lock.json +haraka-update.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a8e94cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".release"] + path = .release + url = git@github.com:msimerson/.release.git diff --git a/.release b/.release new file mode 160000 index 0000000..9be2b27 --- /dev/null +++ b/.release @@ -0,0 +1 @@ +Subproject commit 9be2b270ef836bcfefda085674bf62e2a91defe8 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 12abae8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: node_js -node_js: - - "8" - - "10" - - "12" - -services: -# https://docs.travis-ci.com/user/database-setup/ -# - mongodb -# - elasticsearch -# - redis-server - -before_script: - -script: - - npm run lint - - npm test - -after_success: - -# enable codecov, which doesn't currently work for plugins because -# plugins are run in vm.runInNewContext() -# -# - npm install istanbul codecov -# - npm run cover -# - ./node_modules/.bin/codecov - -sudo: false diff --git a/Changes.md b/Changes.md index 6cdf95b..8762075 100644 --- a/Changes.md +++ b/Changes.md @@ -1,7 +1,10 @@ +### Unreleased -## 1.1.N - 2020-MM-DD +## 1.1.7 - 2022-06-05 -- replace nodeunit with mocha +- ci: replace travis & appveyor with GitHub actions +- test: replace nodeunit with mocha +- test: update header checks against lower cased header names ## 1.1.6 - 2020-02-29 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4910e60..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,20 +0,0 @@ -environment: - nodejs_version: "10" - -install: - - ps: Install-Product node $env:nodejs_version - - npm install - -before_build: -build: off -after_build: - -before_test: - - node --version - - npm --version - -test_script: - - npm test - -after_test: - diff --git a/index.js b/index.js index dc7259a..e9a5713 100644 --- a/index.js +++ b/index.js @@ -357,7 +357,7 @@ exports.get_clean = function (data, connection) { clean[key] = data[key]; break; default: - connection.loginfo(plugin, "skipping unhandled: " + typeof data[key]); + connection.loginfo(plugin, `skipping unhandled: ${ typeof data[key]}`); } }); @@ -393,7 +393,7 @@ exports.parse_response = function (rawData, connection) { } catch (err) { connection.transaction.results.add(plugin, { - err: 'parse failure: ' + err.message + err: `parse failure: ${ err.message}` }); return; } @@ -408,7 +408,7 @@ exports.parse_response = function (rawData, connection) { } return { - 'data' : data, + data, 'log' : plugin.get_clean(data, connection), }; } @@ -442,7 +442,7 @@ exports.add_headers = function (connection, data) { const prettySymbols = []; for (const k in data.symbols) { if (data.symbols[k].score) { - prettySymbols.push(data.symbols[k].name + '(' + data.symbols[k].score + ')'); + prettySymbols.push(`${data.symbols[k].name }(${ data.symbols[k].score })`); } } connection.transaction.remove_header(cfg.header.report); @@ -452,6 +452,6 @@ exports.add_headers = function (connection, data) { if (cfg.header && cfg.header.score) { connection.transaction.remove_header(cfg.header.score); - connection.transaction.add_header(cfg.header.score, '' + data.score); + connection.transaction.add_header(cfg.header.score, `${ data.score}`); } } diff --git a/package.json b/package.json index 6cd2cb5..810ed25 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "haraka-plugin-rspamd", - "version": "1.1.6", + "version": "1.1.7", "description": "Haraka plugin for rspamd", "main": "index.js", "scripts": { - "lint": "npx eslint *.js test/**/*.js", - "lintfix": "./node_modules/.bin/eslint --fix *.js test/**/*.js", - "cover": "npx istanbul cover npm run test", - "test": "npx mocha" + "lint": "npx eslint *.js test", + "lintfix": "npx eslint --fix *.js test", + "test": "npx _mocha" }, "repository": { "type": "git", @@ -25,10 +24,10 @@ }, "homepage": "https://github.com/haraka/haraka-plugin-rspamd#readme", "devDependencies": { - "eslint": ">=4", + "eslint": ">=8", "eslint-plugin-haraka": "*", - "haraka-test-fixtures": "*", - "mocha": "*" + "haraka-test-fixtures": "^1.0.35", + "mocha": ">=9" }, "dependencies": { "haraka-dsn": "*" diff --git a/test/index.js b/test/index.js index ca266eb..74d996d 100644 --- a/test/index.js +++ b/test/index.js @@ -9,7 +9,8 @@ function _set_up (done) { this.plugin = new fixtures.plugin('rspamd'); this.plugin.register(); this.connection = connection.createConnection(); - this.connection.init_transaction(); + this.connection.transaction = fixtures.transaction.createTransaction() + // this.connection.init_transaction(); done(); } @@ -39,7 +40,6 @@ describe('add_headers', function () { it('add_headers exists as function', function (done) { // console.log(this.plugin.cfg); assert.equal('function', typeof this.plugin.add_headers); - // assert.ok(!this.plugin.score_too_high(this.connection, {score: 5})); done(); }) @@ -62,9 +62,9 @@ describe('add_headers', function () { }; this.plugin.cfg.main.add_headers = 'always'; this.plugin.add_headers(this.connection, test_data); - assert.equal(this.connection.transaction.header.headers['X-Rspamd-Score'], '1.1'); - assert.equal(this.connection.transaction.header.headers['X-Rspamd-Bar'], '+'); - assert.equal(this.connection.transaction.header.headers['X-Rspamd-Report'], 'FOO(0.1) BAR(1)'); + assert.deepEqual(this.connection.transaction.header.headers['x-rspamd-score'], [ '1.1' ]); + assert.deepEqual(this.connection.transaction.header.headers['x-rspamd-bar'], ['+']); + assert.deepEqual(this.connection.transaction.header.headers['x-rspamd-report'], ['FOO(0.1) BAR(1)']); done(); }) @@ -75,8 +75,8 @@ describe('add_headers', function () { this.plugin.cfg.main.add_headers = 'always'; this.plugin.add_headers(this.connection, test_data); // console.log(this.connection.transaction.header); - assert.equal(this.connection.transaction.header.headers['X-Rspamd-Score'], '-1'); - assert.equal(this.connection.transaction.header.headers['X-Rspamd-Bar'], '-'); + assert.deepEqual(this.connection.transaction.header.headers['x-rspamd-score'], ['-1']); + assert.deepEqual(this.connection.transaction.header.headers['x-rspamd-bar'], ['-']); done(); }) })