diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d496ad5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + merge_group: + branches: [ main] + +defaults: + run: + working-directory: . + +jobs: + build: + strategy: + matrix: + node-version: [ 18, 20 ] + os: [ubuntu-22.04] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository # v4.0.0 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac + - name: Install PNPM # v2.4.0 + uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 + with: + version: 8 + - name: Use Node.js ${{ matrix.node-version }} # v3.8.1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Run Linters + run: pnpm lint + - name: Run Tests + run: pnpm test:coverage diff --git a/.hooks/pre-commit b/.hooks/pre-commit new file mode 100755 index 0000000..587c838 --- /dev/null +++ b/.hooks/pre-commit @@ -0,0 +1,7 @@ +#!/bin/sh + +set -eu +set -o pipefail + +pnpm lint +pnpm test diff --git a/biome.json b/biome.json index 147920e..ad9d461 100644 --- a/biome.json +++ b/biome.json @@ -6,7 +6,7 @@ "rules": { "recommended": true }, - "ignore": ["./node_modules/**/*"], + "ignore": ["./coverage/**/*", "./node_modules/**/*"], "include": ["./*.json", "./*.js", "./*.mjs", "./*.mts", "./*.d.ts"] }, "formatter": { diff --git a/package.json b/package.json index 359035f..4edf035 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,12 @@ ], "scripts": { "format": "biome format --write .", - "lint": "pnpm run lint:biome && pnpm run lint:tsc", + "install-githooks": "if [ -d .git ]; then git config core.hooksPath .hooks; fi", + "lint": "pnpm run lint:biome && pnpm run lint:tsc && pnpm run lint:publint", "lint:biome": "biome lint .", + "lint:publint": "publint", "lint:tsc": "tsc -p .", + "prepublishOnly": "pnpm lint && pnpm test", "test": "vitest run", "test:coverage": "vitest run --coverage" }, @@ -50,6 +53,7 @@ "@types/node": "^20.11.19", "@vitest/coverage-v8": "^1.2.2", "astro": "^4.4.0", + "publint": "^0.2.7", "typescript": "^5.3.3", "vitest": "^1.2.2" },