Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- master

permissions:
contents: read

# Cancel in progress workflows
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
concurrency:
group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
performance:
name: Run performance test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install dependencies
run: npm install

- name: Run performance test
run: npm run test:performance

test:
name: Run tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version:
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
- "16"
- "17"
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
# Use supported versions of our testing tools under older versions of Node
# Install npm in some specific cases where we need to
include:
- node-version: "0.10"
npm-i: "mocha@3.5.3 nyc@10.3.2 supertest@2.0.0"
# Npm isn't being installed on windows w/ setup-node for
# 0.10 and 0.12, which will end up choking when npm uses es6
npm-version: "npm@2.15.1"
npm-rm: 'iconv'

- node-version: "0.12"
npm-i: "mocha@3.5.3 nyc@10.3.2"
npm-version: "npm@2.15.11"
npm-rm: 'iconv'

- node-version: "4"
npm-i: "mocha@5.2.0 nyc@11.9.0"
npm-rm: 'iconv'

- node-version: "5"
npm-i: "mocha@5.2.0 nyc@11.9.0"
# fixes https://github.com/npm/cli/issues/681
npm-version: "npm@3.10.10"
npm-rm: 'iconv'

- node-version: "6"
npm-i: "mocha@6.2.2 nyc@14.1.1"
npm-rm: 'iconv'

- node-version: "7"
npm-i: "mocha@6.2.2 nyc@14.1.1"
npm-rm: 'iconv'

- node-version: "8"
npm-i: "mocha@7.2.0 nyc@14.1.1"
npm-rm: 'iconv'

- node-version: "9"
npm-i: "mocha@7.2.0 nyc@14.1.1"
npm-rm: 'iconv'

- node-version: "10"
npm-i: "mocha@8.4.0"
npm-rm: 'iconv'

- node-version: "11"
npm-i: "mocha@8.4.0"
npm-rm: 'iconv'

- node-version: "12"
npm-i: "mocha@9.2.2"
npm-rm: 'iconv'

- node-version: "13"
npm-i: "mocha@9.2.2"
npm-rm: 'iconv'

- node-version: "14"
npm-rm: 'iconv'

- node-version: "15"
npm-rm: 'iconv'

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Npm version fixes
if: ${{matrix.npm-version != ''}}
run: npm install -g ${{ matrix.npm-version }}

- name: Configure npm loglevel
run: |
npm config set loglevel error
shell: bash

- name: Remove npm module(s) ${{ matrix.npm-rm }}
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
if: matrix.npm-rm != ''

- name: Install Node version specific dev deps
if: ${{ matrix.npm-i != '' }}
run: npm install --save-dev ${{ matrix.npm-i }}

- name: Install dependencies
run: npm install

- name: Output Node and NPM versions
run: |
echo "Node.js version: $(node -v)"
echo "NPM version: $(npm -v)"

- name: Run tests
shell: bash
run: npm run test:ci

- name: Upload code coverage
uses: actions/upload-artifact@v4
with:
name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }}
path: ./coverage/lcov.info
retention-days: 1

coverage:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@v4

- name: Install lcov
shell: bash
run: sudo apt-get -y install lcov

- name: Collect coverage reports
uses: actions/download-artifact@v4
with:
path: ./coverage
pattern: coverage-node-*

- name: Merge coverage reports
shell: bash
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info

- name: Upload coverage report
uses: coverallsapp/github-action@v2
with:
file: ./lcov.info

test_webpack:
name: Run tests webpack
strategy:
fail-fast: false
matrix:
node-version: ["12", "*"]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Webpack test
shell: bash
run: |
npm run test:webpack
72 changes: 72 additions & 0 deletions .github/workflows/iojs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: iojs-ci

on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: "${{ github.workflow }} iojs ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ["1.8", "2.5", "3.3"]
include:
- node-version: "1.8"
npm-i: "mocha@3.5.3 nyc@10.3.2"
npm-rm: 'iconv'
- node-version: "2.5"
npm-i: "mocha@3.5.3 nyc@10.3.2"
npm-rm: 'iconv'
- node-version: "3.3"
npm-i: "mocha@3.5.3 nyc@10.3.2"
npm-rm: 'iconv'

steps:
- uses: actions/checkout@v4

- name: Install iojs ${{ matrix.node-version }}
shell: bash -eo pipefail -l {0}
run: |
nvm install --default ${{ matrix.node-version }}
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"

- name: Configure npm
run: |
npm config set loglevel error
npm config set shrinkwrap false
- name: Remove npm module(s) ${{ matrix.npm-rm }}
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
if: matrix.npm-rm != ''

- name: Install npm module(s) ${{ matrix.npm-i }}
run: npm install --save-dev ${{ matrix.npm-i }}
if: matrix.npm-i != ''

- name: Remove non-test dependencies
run: npm rm --silent --save-dev connect-redis

- name: Install Node.js dependencies
run: npm install

- name: List environment
id: list_env
shell: bash
run: |
echo "node@$(node -v)"
echo "npm@$(npm -v)"
npm -s ls ||:
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"

- name: Run tests
shell: bash
run: npm run test

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ package-lock.json
/coverage
/benchmarks/node_envs
/generation/source-data

.nyc_output
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ wiki
coverage
.github
.idea
.travis.yml
performance
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@
"node": ">=0.10.0"
},
"scripts": {
"coverage": "c8 _mocha --grep .",
"test": "mocha --reporter spec --grep ."
"test": "mocha --reporter spec --check-leaks --grep .",
"test:ci": "nyc --exclude test --reporter=lcovonly --reporter=text npm test",
"test:cov": "nyc --exclude test --reporter=html --reporter=text npm test",
"test:performance": "node performance/index.js",
"test:tap": "mocha --reporter tap --check-leaks --grep .",
"test:webpack": "npm pack && mv iconv-lite-*.tgz test/webpack/iconv-lite.tgz && cd test/webpack && npm install && npm run test && rm iconv-lite.tgz"
},
"browser": {
"stream": false
},
"devDependencies": {
"async": "^3.2.0",
"c8": "^7.2.0",
"errto": "^0.2.1",
"iconv": "^2.3.5",
"mocha": "^3.5.3",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"request": "^2.88.2",
"semver": "^6.3.0",
"unorm": "^1.6.0"
Expand Down
7 changes: 2 additions & 5 deletions test/performance.js → performance/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

if (module.parent) // Skip this file from testing.
return;

var iconv = require('iconv');
var iconv_lite = require("../");
var iconv_lite = require("../lib");

var encoding = process.argv[2] || "windows-1251";
var convertTimes = 10000;
Expand All @@ -30,6 +26,7 @@ var converter = new iconv.Iconv("utf8", encoding);
for (var i = 0; i < convertTimes; i++) {
var b = converter.convert(str);
}

var duration = Date.now() - start;
var mbs = convertTimes*b.length/duration/1024;

Expand Down
Loading
Loading