From dacdff761cdc39bcc271b611cea8e1ff08bf76dd Mon Sep 17 00:00:00 2001 From: bernizhel Date: Thu, 13 Jul 2023 16:23:42 +0300 Subject: [PATCH] ci: separate workflows, add eslint and prettier --- .github/workflows/ci.yml | 59 -------------------------------- .github/workflows/commitlint.yml | 36 +++++++++++++++++++ .github/workflows/eslint.yml | 32 +++++++++++++++++ .github/workflows/prettier.yml | 32 +++++++++++++++++ .github/workflows/setup.yml | 27 +++++++++++++++ .github/workflows/unit-tests.yml | 32 +++++++++++++++++ 6 files changed, 159 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/eslint.yml create mode 100644 .github/workflows/prettier.yml create mode 100644 .github/workflows/setup.yml create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 5e012458b..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - unit-test: - # if: github.ref == 'refs/heads/master' && github.event_name == 'pull_request' - # if: github.event_name == 'pull_request' - name: Unit tests - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: . - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Install correct Node.js version - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' - cache-dependency-path: 'package-lock.json' - - name: Install dependencies - run: npm ci - - name: Run `test-ci` npm script - run: npm run test-ci - commitlint: - runs-on: ubuntu-latest - defaults: - run: - working-directory: . - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - - name: Print versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - name: Install commitlint - run: | - npm install conventional-changelog-conventionalcommits - npm install commitlint@latest - - - name: Validate current commit (last commit) with commitlint - if: github.event_name == 'push' - run: npx commitlint --from HEAD~1 --to HEAD --verbose - - - name: Validate PR commits with commitlint - if: github.event_name == 'pull_request' - run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 000000000..59d075623 --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,36 @@ +name: Commitlint + +on: [push, pull_request, workflow_call] + +jobs: + commitlint: + name: Commitlint + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: . + steps: + - uses: ${{ github.workspace }}/.github/workflows/setup.yml + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Install system dependencies + # run: | + # sudo apt-get update + # sudo apt-get upgrade + # sudo apt-get install -y git + # - name: Install Node.js + # uses: actions/setup-node@v3 + # with: + # node-version-file: '.nvmrc' + - name: Install commitlint + run: | + npm install conventional-changelog-conventionalcommits + npm install commitlint@latest + - name: Validate current commit (last commit) with commitlint + if: github.event_name == 'push' # || github.event_name == 'workflow_call' + run: npx commitlint --from HEAD~1 --to HEAD --verbose + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml new file mode 100644 index 000000000..0b2c49809 --- /dev/null +++ b/.github/workflows/eslint.yml @@ -0,0 +1,32 @@ +name: ESLint + +on: [push, pull_request, workflow_call] + +jobs: + eslint: + name: ESLint + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: . + steps: + - uses: ${{ github.workspace }}/.github/workflows/setup.yml + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Install system dependencies + # run: | + # sudo apt-get update + # sudo apt-get upgrade + # sudo apt-get install -y git + # - name: Install correct Node.js version + # uses: actions/setup-node@v3 + # with: + # node-version-file: '.nvmrc' + # cache: 'npm' + # cache-dependency-path: 'package-lock.json' + # - name: Install dependencies + # run: npm ci + - name: Run `lint:check` npm script + run: npm run lint:check diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 000000000..0fa1a9fea --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,32 @@ +name: Prettier + +on: [push, pull_request, workflow_call] + +jobs: + eslint: + name: Prettier + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: . + steps: + - uses: ${{ github.workspace }}/.github/workflows/setup.yml + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Install system dependencies + # run: | + # sudo apt-get update + # sudo apt-get upgrade + # sudo apt-get install -y git + # - name: Install correct Node.js version + # uses: actions/setup-node@v3 + # with: + # node-version-file: '.nvmrc' + # cache: 'npm' + # cache-dependency-path: 'package-lock.json' + # - name: Install dependencies + # run: npm ci + - name: Run `format:check` npm script + run: npm run format:check diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 000000000..b84de72ed --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,27 @@ +name: Set up workflow machine + +on: [workflow_call] + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: . + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install system dependencies + # sudo apt-get install -y git + run: | + sudo apt-get update + sudo apt-get upgrade + - name: Install correct Node.js version + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'npm' + cache-dependency-path: 'package-lock.json' diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..484a0a61e --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,32 @@ +name: Unit tests + +on: [push, pull_request, workflow_call] + +jobs: + unit-test: + name: Unit tests + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: . + steps: + - uses: ${{ github.workspace }}/.github/workflows/setup.yml + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Install system dependencies + # run: | + # sudo apt-get update + # sudo apt-get upgrade + # sudo apt-get install -y git + # - name: Install correct Node.js version + # uses: actions/setup-node@v3 + # with: + # node-version-file: '.nvmrc' + # cache: 'npm' + # cache-dependency-path: 'package-lock.json' + # - name: Install dependencies + # run: npm ci + - name: Run `test-ci` npm script + run: npm run test-ci