From c19f11b1e0b0c0d66d2212607b88bfe51d14d57e Mon Sep 17 00:00:00 2001 From: Vladyslav Zubko <42296182+what1s1ove@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:42:12 +0200 Subject: [PATCH] ci: add CI action fp-52 (#71) * ci: add ci action fp-52 * ci: remove lint and tests action fp-52 * ci: improve lint script fp-52 --- .github/workflows/ci.yml | 83 +++++++++++++++++++ .github/workflows/lint.yml | 31 ------- .github/workflows/test.yml | 31 ------- .lintstagedrc.yml | 4 +- package.json | 8 +- .../create-form-element.helper.js | 10 ++- 6 files changed, 96 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fde5090 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: Continuous Integration + +on: + pull_request: + branches: + - main + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + dependencies: + name: Install Dependencies + runs-on: ubuntu-latest + steps: + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Install NodeJS + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Cache Dependencies + id: cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ci-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ci- + + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + npm install + + lint: + name: Code Linting + needs: dependencies + runs-on: ubuntu-latest + steps: + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Install NodeJS + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Restore Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ci-${{ hashFiles('**/package-lock.json') }} + + - name: Code Linting + run: | + npm run lint + + test: + name: Code Testing + needs: dependencies + runs-on: ubuntu-latest + steps: + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Install NodeJS + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Restore Dependencies + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ci-${{ hashFiles('**/package-lock.json') }} + + - name: Code Testing + run: | + npm run test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6b6ddba..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Lint - -env: - NODE_VERSION: 14 - -on: - pull_request: - branches: - - development - - production - -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Install NodeJS v${{ env.NODE_VERSION }} - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Code Checkout - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - npm ci - - - name: Code Linting - run: | - npm run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 38cc396..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test - -env: - NODE_VERSION: 14 - -on: - pull_request: - branches: - - development - - production - -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Install NodeJS v${{ env.NODE_VERSION }} - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Code Checkout - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - npm ci - - - name: Code Testing - run: | - npm run test diff --git a/.lintstagedrc.yml b/.lintstagedrc.yml index 9fecc96..e3f2cea 100644 --- a/.lintstagedrc.yml +++ b/.lintstagedrc.yml @@ -1,3 +1,3 @@ '*': npm run lint:fs && npm run lint:editorconfig -'*.{json,md,yml,js,ts,d.ts}': prettier --write, -'*.ts': npm run lint:ts +'*.{json,md,yml,js}': prettier --write, +'*.js': npm run lint:js && npm run lint:type diff --git a/package.json b/package.json index 61d663a..fe71762 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,13 @@ }, "scripts": { "postinstall": "npx simple-git-hooks", - "format": "prettier --write \"**/*.{json,md,yml,js,ts,d.ts}\"", + "format": "prettier --write \"**/*.{json,md,yml,js}\"", "lint:fs": "ls-lint", - "lint:editorconfig": "editorconfig-checker", - "lint:format": "prettier --check \"**/*.{json,md,yml,js,ts,d.ts}\"", + "lint:editor": "editorconfig-checker", + "lint:format": "prettier --check \"**/*.{json,md,yml,js}\"", "lint:js": "eslint \"**/*.js\"", "lint:type": "tsc --noEmit", - "lint": "npm run lint:fs && npm run lint:editorconfig && npm run lint:format && npm run lint:ts", + "lint": "npm run lint:fs && npm run lint:editor && npm run lint:format && npm run lint:js && npm run lint:type", "test": "NODE_OPTIONS=--experimental-vm-modules npx jest", "test:watch": "jest --watch", "build:ts": "tsc && tscpaths -p tsconfig.json -s ./src -o ./build", diff --git a/tests/helpers/create-form-element/create-form-element.helper.js b/tests/helpers/create-form-element/create-form-element.helper.js index 20af628..1940da4 100644 --- a/tests/helpers/create-form-element/create-form-element.helper.js +++ b/tests/helpers/create-form-element/create-form-element.helper.js @@ -7,9 +7,13 @@ import { createElement } from '../create-element/create-element.helper'; */ const createFormElement = (...children) => { return /** @type {HTMLFormElement} */ ( - createElement(ElementName.FORM, { - name: '' - }, ...children) + createElement( + ElementName.FORM, + { + name: '', + }, + ...children, + ) ); };