From 1ba25f0aed309772c4820bf807f970b284db95a9 Mon Sep 17 00:00:00 2001 From: Tobiah Date: Fri, 19 Feb 2021 09:30:38 -0600 Subject: [PATCH] chore(ci): reduce config spread --- .eslintignore | 1 - .eslintrc | 32 ------------ .github/workflows/ci.yaml | 65 +++++++++++++++++++++++ .github/workflows/release.yaml | 84 ++++++++++++++++++++++++++++++ .gitignore | 2 + .npmignore | 2 + .nvmrc | 2 +- .travis.yml | 35 ------------- package.json | 66 ++++++++++++++++++++++- test/unit/rss-feed-emitter.spec.js | 7 +-- 10 files changed, 222 insertions(+), 74 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 .travis.yml diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 96212a3..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/*{.,-}min.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f15eef1..0000000 --- a/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": "airbnb-base", - "parserOptions": { - "sourceType": "script" - }, - "rules": { - "valid-jsdoc": ["error", { - "requireReturn": false, - "requireReturnDescription": false, - "preferType": { - "String": "string", - "Number": "number", - "Boolean": "boolean", - "Function": "function", - "object": "Object", - "date": "Date", - "error": "Error" - }, - "prefer": { - "return": "returns" - } - }], - "strict": ["error", "safe"], - "linebreak-style": "off", - "no-restricted-syntax": ["off"], - "no-await-in-loop": "off", - "import/no-unresolved": 0, - "no-param-reassign": 0, - "complexity": ["error", 10], - "arrow-parens": ["error", "always"] - } -} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b353498 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,65 @@ +name: Actions +on: + pull_request: + branches: + - master + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x] + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: npm install + - name: Run linters + run: npm run lint + test: + name: Test + runs-on: ubuntu-latest + needs: lint + strategy: + max-parallel: 1 + matrix: + node-version: [8.x, 12.x, 14.x, 16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + env: + CI: true + parallel: true + coverage: + name: Coverage + runs-on: ubuntu-latest + needs: lint + strategy: + matrix: + node-version: [16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + env: + CI: true + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..37ea0da --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,84 @@ +name: Release +on: + push: + branches: + - master + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x] + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: npm install + - name: Run linters + run: npm run lint + test: + name: Test + runs-on: ubuntu-latest + needs: lint + strategy: + matrix: + node-version: [8.x, 12.x, 14.x, 16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + env: + CI: true + parallel: true + coverage: + name: Coverage + runs-on: ubuntu-latest + needs: lint + strategy: + matrix: + node-version: [16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test + env: + CI: true + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + release: + name: Release + if: ${{ github.ref == 'refs/heads/master' }} + runs-on: ubuntu-latest + needs: [lint, test, coverage] + strategy: + matrix: + node-version: [16.x] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v2.7.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + with: + semantic_version: 17 + branches: | + ['master'] diff --git a/.gitignore b/.gitignore index 382d469..c8b681f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ node_modules # Distribution files dist + +.idea/ diff --git a/.npmignore b/.npmignore index 6224927..f1e501f 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,5 @@ .nvmrc content test +.idea/ +.github/ diff --git a/.nvmrc b/.nvmrc index dfda3e0..53d838a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -6.1.0 +lts/gallium diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8a3a542..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: node_js -os: linux -dist: bionic -cache: npm -node_js: - - node - - lts/* - - stable - - 13 - - 12 - - 11 - - 10 - - 9 - - 8 - -stages: - - lint - - test - - coverage - - name: release - if: branch = master && type NOT IN (pull_request) - -jobs: - include: - - stage: lint - script: npm run lint - - stage: coverage - script: npm run coverage - - stage: release - node_js: node - deploy: - provider: script - cleanup: false - skip_cleanup: true - script: npx semantic-release diff --git a/package.json b/package.json index aec2a9c..70937a1 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "test": "test/**/*.spec.js" }, "scripts": { - "test": "nyc mocha \"test/**/*.spec.js\" --exit", - "coverage": "npm test && nyc report --reporter=text-lcov | npx coveralls", + "test": "nyc mocha", + "coverage": "npm test && npm run cov:gen | npx coveralls", + "cov:gen": "nyc report --reporter=text-lcov", "lint": "eslint src/ test/", "lint:fix": "eslint src/ test/ --fix", "prepublishOnly": "npm run build:types", @@ -52,8 +53,13 @@ "request": "^2.88.2" }, "nyc": { + "skip-full": true, "all": true, "instrument": true, + "reporter": [ + "lcov", + "text" + ], "include": [ "src/**/*" ] @@ -63,5 +69,61 @@ }, "release": { "branch": "master" + }, + "eslintIgnore": [ + "**/*{.,-}min.js" + ], + "eslintConfig": { + "extends": "airbnb-base", + "parserOptions": { + "sourceType": "script" + }, + "rules": { + "valid-jsdoc": [ + "error", + { + "requireReturn": false, + "requireReturnDescription": false, + "preferType": { + "String": "string", + "Number": "number", + "Boolean": "boolean", + "Function": "function", + "object": "Object", + "date": "Date", + "error": "Error" + }, + "prefer": { + "return": "returns" + } + } + ], + "strict": [ + "error", + "safe" + ], + "linebreak-style": "off", + "no-restricted-syntax": [ + "off" + ], + "no-await-in-loop": "off", + "import/no-unresolved": 0, + "no-param-reassign": 0, + "complexity": [ + "error", + 10 + ], + "arrow-parens": [ + "error", + "always" + ] + } + }, + "mocha": { + "spec": "test/**/*.spec.js", + "exit": true, + "slow": 1000, + "normal": 400, + "reporter": "min" } } diff --git a/test/unit/rss-feed-emitter.spec.js b/test/unit/rss-feed-emitter.spec.js index 2ae9c22..37d852d 100644 --- a/test/unit/rss-feed-emitter.spec.js +++ b/test/unit/rss-feed-emitter.spec.js @@ -15,7 +15,9 @@ const { expect } = chai; let feeder; const defaultUserAgent = 'Node/RssFeedEmitter (https://github.com/filipedeschamps/rss-feed-emitter)'; -describe('RssFeedEmitter (unit)', () => { +describe('RssFeedEmitter (unit)', function unit() { + this.retries(8); + beforeEach(() => { feeder = new RssFeedEmitter(); }); @@ -813,12 +815,11 @@ describe('RssFeedEmitter (unit)', () => { const feed = new Feed({ url: 'https://www.nintendolife.com/feeds/latest', refresh: 100 }); let numHandled = 0; - const handler = { + feed.handler = { handle: () => { numHandled += 1; }, }; - feed.handler = handler; await feed.fetchData(); expect(numHandled).to.eq(2); });