diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b67c353 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI + +on: + push: + pull_request: + +env: + CI: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + - uses: actions/checkout@v4 + - run: npm install + - run: npm install eslint@^8 + - run: npm run lint + + coverage: + if: false + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + - uses: actions/checkout@v4 + - run: npm install + - name: run coverage + run: | + npm install --no-save c8 + npx c8 --reporter=lcov npm test + env: + NODE_ENV: cov + + - name: codecov + uses: codecov/codecov-action@v4 + + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + + ubuntu: + needs: [get-lts] + runs-on: ubuntu-latest + strategy: + matrix: + node: ${{ fromJson(needs.get-lts.outputs.active) }} + include: + - node: 10 + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + name: Node ${{ matrix.node }} on ubuntu-latest + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run test + + windows: + needs: [lint, get-lts] + runs-on: windows-latest + strategy: + matrix: + node: ${{ fromJson(needs.get-lts.outputs.active) }} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + name: Node.js ${{ matrix.node }} on windows-latest + with: + node-version: ${{ matrix.node }} + - run: npm install + - run: npm run 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 }} + min: ${{ steps.get.outputs.min }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06a8d58..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: node_js - -node_js: - - "node" - - "10" - - "8" - - "6" - -script: - - npm run lint - - npm test diff --git a/CHANGELOG.md b/CHANGELOG.md index 195f484..c613899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + +## Unreleased + +* ci: replace travis (dead) with Github Actions GHA) +* ci: automatically test on ubuntu & windows +* ci: automatically test on the LTS versions of node.js +* deps: remove mocha & eslint, they get auto-installed by npx when needed +* doc(README): update CI badge URL, remove broken badges + ## 1.1.3 * fix LICENSE name diff --git a/README.md b/README.md index 8ef74f5..01e1848 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,13 @@ # sprintf-js -[![Build Status][travisci-image]][travisci-url] [![NPM Version][npm-image]][npm-url] [![Dependency Status][dependencies-image]][dependencies-url] [![devDependency Status][dev-dependencies-image]][dev-dependencies-url] +[![Build Status][ci-image]][ci-url] [![NPM Version][npm-image]][npm-url] -[travisci-image]: https://travis-ci.org/alexei/sprintf.js.svg?branch=master -[travisci-url]: https://travis-ci.org/alexei/sprintf.js +[ci-image]: https://github.com/alexei/sprintf.js/actions/workflows/ci.yml/badge.svg +[ci-url]: https://github.com/alexei/sprintf.js/actions/workflows/ci.yml [npm-image]: https://badge.fury.io/js/sprintf-js.svg [npm-url]: https://badge.fury.io/js/sprintf-js -[dependencies-image]: https://david-dm.org/alexei/sprintf.js.svg -[dependencies-url]: https://david-dm.org/alexei/sprintf.js - -[dev-dependencies-image]: https://david-dm.org/alexei/sprintf.js/dev-status.svg -[dev-dependencies-url]: https://david-dm.org/alexei/sprintf.js#info=devDependencies - **sprintf-js** is a complete open source JavaScript `sprintf` implementation for the **browser** and **Node.js**. **Note: as of v1.1.1 you might need some polyfills for older environments. See [Support](#support) section below.** diff --git a/package-lock.json b/package-lock.json index 21b17ed..bdb018b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "BSD-3-Clause", "devDependencies": { "benchmark": "^2.1.4", - "eslint": "^5.10.0", "gulp": "^3.9.1", "gulp-benchmark": "^1.1.1", "gulp-eslint": "^5.0.0", @@ -18,8 +17,7 @@ "gulp-mocha": "^6.0.0", "gulp-rename": "^1.4.0", "gulp-sourcemaps": "^2.6.4", - "gulp-uglify": "^3.0.1", - "mocha": "^5.2.0" + "gulp-uglify": "^3.0.1" } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index 1d3dcf3..099a082 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "author": "Alexandru Mărășteanu ", "main": "src/sprintf.js", "scripts": { - "test": "mocha test/*.js", + "test": "npx mocha test/*.js", "pretest": "npm run lint", - "lint": "eslint .", - "lint:fix": "eslint --fix ." + "lint": "npx eslint@^7 .", + "lint:fix": "npx eslint@^7 --fix ." }, "repository": { "type": "git", @@ -18,7 +18,6 @@ "readmeFilename": "README.md", "devDependencies": { "benchmark": "^2.1.4", - "eslint": "^5.10.0", "gulp": "^3.9.1", "gulp-benchmark": "^1.1.1", "gulp-eslint": "^5.0.0", @@ -26,8 +25,7 @@ "gulp-mocha": "^6.0.0", "gulp-rename": "^1.4.0", "gulp-sourcemaps": "^2.6.4", - "gulp-uglify": "^3.0.1", - "mocha": "^5.2.0" + "gulp-uglify": "^3.0.1" }, "overrides": { "graceful-fs": "^4.2.11" diff --git a/src/sprintf.js b/src/sprintf.js index 65d6324..c15e382 100644 --- a/src/sprintf.js +++ b/src/sprintf.js @@ -210,6 +210,7 @@ * export to either browser or node.js */ /* eslint-disable quote-props */ + /* eslint no-redeclare: [ "warn" ] */ if (typeof exports !== 'undefined') { exports['sprintf'] = sprintf exports['vsprintf'] = vsprintf