From f620bee3a3b21de00d148f359604106b5beae1cd Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti Date: Fri, 23 Feb 2024 20:54:32 +0100 Subject: [PATCH] ci: add codeQuality and build jobs --- .github/workflows/lint_and_test.yml | 48 ++++++++++++++++++++++++----- package.json | 5 +-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 9522596b..a418f414 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -1,4 +1,4 @@ -name: Lint & Test +name: Format, Lint, & Test on: push: @@ -10,8 +10,46 @@ on: - '**' jobs: + codeQuality: + name: Check code quality (lint and format) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Format check + run: npm run format + + - name: Format check + run: npm run lint + + build: + name: Build + runs-on: ubuntu-latest + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + test: - name: Lint & test on node ${{ matrix.node }} and ${{ matrix.os }} + name: Test on node ${{ matrix.node }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -29,10 +67,6 @@ jobs: - name: Install dependencies run: npm install - # lint is included in pretest - # - name: Lint - # run: npm run lint - - name: Test run: npm test @@ -40,4 +74,4 @@ jobs: run: npm run test:coverage - name: Coveralls - uses: coverallsapp/github-action@v2 \ No newline at end of file + uses: coverallsapp/github-action@v2 diff --git a/package.json b/package.json index d3330362..717aff09 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,9 @@ }, "scripts": { "lint": "eslint src typescript test \"./*.{ts,mts}\"", - "pretest": "npm run generate_ts_v4_index && npm run lint", + "format": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --check", + "format:fix": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --write", + "pretest": "npm run generate_ts_v4_index", "test": "vitest --run", "test:coverage": "vitest --project runtime --project compatibility --coverage --run", "test:runtime": "vitest --project runtime", @@ -113,7 +115,6 @@ "fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/esm/package.json", "preversion": "npm run test && npm run build && git push", "postversion": "npm run fix_dist_package && git push && git push --tags && npm run release", - "prettier": "prettier --write \"{,**/}*.{ts,tsx,mts,js,json,md}\"", "prepare": "husky install", "release": "gh-release" },