From 7c75d32671e1805ebab35c1da2847a63e025ab96 Mon Sep 17 00:00:00 2001 From: Wadjih Bencheikh Date: Wed, 2 Mar 2022 14:05:49 +0100 Subject: [PATCH] refactor: cleanup (#43) Refs: https://github.com/mljs/ml/issues/174#issuecomment-1055785803 --- .babelrc => .babelrc.json | 0 .github/workflows/documentationjs.yml | 11 ++++---- .github/workflows/nodejs.yml | 36 ++++++--------------------- .github/workflows/release.yml | 32 ++++++------------------ .prettierrc.json | 7 ++++++ package.json | 32 ++++++++++-------------- 6 files changed, 41 insertions(+), 77 deletions(-) rename .babelrc => .babelrc.json (100%) create mode 100644 .prettierrc.json diff --git a/.babelrc b/.babelrc.json similarity index 100% rename from .babelrc rename to .babelrc.json diff --git a/.github/workflows/documentationjs.yml b/.github/workflows/documentationjs.yml index 62a3273..0ae90e1 100644 --- a/.github/workflows/documentationjs.yml +++ b/.github/workflows/documentationjs.yml @@ -1,6 +1,7 @@ name: Deploy documentation.js on GitHub pages on: + workflow_dispatch: release: types: [published] @@ -12,9 +13,9 @@ jobs: - name: Build documentation uses: zakodium/documentationjs-action@v1 - name: Deploy to GitHub pages - uses: JamesIves/github-pages-deploy-action@releases/v3 + uses: JamesIves/github-pages-deploy-action@releases/v4 with: - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} - BRANCH: gh-pages - FOLDER: docs - CLEAN: true + token: ${{ secrets.BOT_TOKEN }} + branch: gh-pages + folder: docs + clean: true diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7e6c695..0ea7496 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -2,35 +2,13 @@ name: Node.js CI on: push: - branches: master + branches: + - master pull_request: jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2-beta - with: - node-version: 16.x - - name: Install dependencies - run: npm install - - name: Run ESLint - run: npm run eslint - test: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [10.x, 12.x, 14.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2-beta - with: - node-version: ${{ matrix.node-version }} - - name: Install dependencies - run: npm install - - name: Run tests - run: npm run test-coverage - - name: Send coverage report to Codecov - uses: codecov/codecov-action@v1 + nodejs: + # Documentation: https://github.com/zakodium/workflows#nodejs-ci + uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1 + with: + node-version-matrix: '[12, 14, 16]' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87dbeb8..29735ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,27 +6,11 @@ on: - master jobs: - release-please: - runs-on: ubuntu-latest - steps: - - uses: GoogleCloudPlatform/release-please-action@v2.5.3 - id: release - with: - token: ${{ secrets.BOT_TOKEN }} - release-type: node - package-name: 'ml-random-forest' - bump-minor-pre-major: Yes - - uses: actions/checkout@v2 - # These if statements ensure that a publication only occurs when a new release is created - if: ${{ steps.release.outputs.release_created }} - - uses: actions/setup-node@v2-beta - with: - node-version: 14 - registry-url: 'https://registry.npmjs.org' - if: ${{ steps.release.outputs.release_created }} - - run: npm install - if: ${{ steps.release.outputs.release_created }} - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_BOT_TOKEN }} - if: ${{ steps.release.outputs.release_created }} + release: + # Documentation: https://github.com/zakodium/workflows#release + uses: zakodium/workflows/.github/workflows/release.yml@release-v1 + with: + npm: true + secrets: + github-token: ${{ secrets.BOT_TOKEN }} + npm-token: ${{ secrets.NPM_BOT_TOKEN }} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..f4d3ba4 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all" +} \ No newline at end of file diff --git a/package.json b/package.json index 0dbb3f3..4d528cb 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,11 @@ "compile": "rollup -c", "eslint": "eslint src", "eslint-fix": "npm run eslint -- --fix", - "prepublishOnly": "npm run compile", - "test": "npm run test-coverage && npm run eslint", - "test-only": "jest", - "test-coverage": "jest --coverage" + "prepack": "npm run compile", + "prettier": "prettier --check src", + "prettier-write": "prettier --write src", + "test": "npm run test-only && npm run eslint && npm run prettier", + "test-only": "jest --coverage" }, "repository": { "type": "git", @@ -42,27 +43,20 @@ "devDependencies": { "@babel/plugin-transform-modules-commonjs": "^7.16.8", "benchmark": "^2.1.4", - "eslint": "^8.7.0", - "eslint-config-cheminfo": "^7.2.1", - "jest": "^27.4.7", + "eslint": "^8.10.0", + "eslint-config-cheminfo": "^7.2.2", + "jest": "^27.5.1", "ml-dataset-iris": "^1.2.1", "npm-run-all": "^4.1.5", "prettier": "^2.5.1", - "rollup": "^2.64.0" + "rollup": "^2.68.0" }, "dependencies": { - "ml-array-mean": "^1.1.5", - "ml-array-median": "^1.1.5", - "ml-array-mode": "^1.1.4", + "ml-array-mean": "^1.1.6", + "ml-array-median": "^1.1.6", + "ml-array-mode": "^1.1.5", "ml-cart": "^2.1.1", - "ml-matrix": "^6.8.2", + "ml-matrix": "^6.9.0", "random-js": "^2.1.0" - }, - "prettier": { - "arrowParens": "always", - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "all" } }