diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ee565032 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +env: + FORCE_COLOR: 1 + +jobs: + quality: + name: Lint & Format + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run linting + run: node --run lint + + - name: Check formatting + run: node --run format:check + + test: + name: Test & Coverage + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests with coverage + run: node --run test:ci + + - name: Upload coverage to Codecov + if: always() + uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2 + with: + files: ./lcov.info + + - name: Upload test results to Codecov + if: always() + uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0 + with: + files: ./junit.xml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index ae060f82..00000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - branches: [main] - -permissions: - contents: read - -env: - FORCE_COLOR: 1 - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Harden Runner - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Setup Node.js - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Lint - run: node --run lint - - - name: Format - run: node --run format - - - name: Test with coverage - run: node --run test:coverage diff --git a/.gitignore b/.gitignore index ff95866d..d46bde90 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ npm-debug.log # Default Output Directory out + +# Tests +lcov.info +junit.xml diff --git a/package-lock.json b/package-lock.json index 578a6b62..8d5b9e60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ }, "devDependencies": { "@eslint/js": "^9.27.0", + "@reporters/github": "^1.7.2", "@types/mdast": "^4.0.4", "@types/node": "^22.15.3", "eslint": "^9.27.0", @@ -455,6 +456,17 @@ "dpack": "^0.6.22" } }, + "node_modules/@reporters/github": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@reporters/github/-/github-1.7.2.tgz", + "integrity": "sha512-8mvTyKUxxDXkNIWfzv3FsHVwjr8JCwVtwidQws2neV6YgrsJW6OwTOBBhd01RKrDMXPxgpMQuFEfN9hRuUZGuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.0", + "stack-utils": "^2.0.6" + } + }, "node_modules/@shikijs/core": { "version": "3.4.2", "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-3.4.2.tgz", @@ -3691,6 +3703,29 @@ "dev": true, "license": "CC0-1.0" }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", diff --git a/package.json b/package.json index c4c6e40d..0491ba00 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,10 @@ "lint:fix": "eslint --fix . --no-warn-ignored", "format": "prettier .", "format:write": "prettier --write .", + "format:check": "prettier --check .", "test": "node --test", "test:coverage": "node --experimental-test-coverage --test", + "test:ci": "node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=spec --test-reporter-destination=stdout --test", "test:update-snapshots": "node --test --test-update-snapshots", "test:watch": "node --test --watch", "prepare": "husky", @@ -23,6 +25,7 @@ }, "devDependencies": { "@eslint/js": "^9.27.0", + "@reporters/github": "^1.7.2", "@types/mdast": "^4.0.4", "@types/node": "^22.15.3", "eslint": "^9.27.0",