diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..ce969b0 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,30 @@ +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/vitest-coverage.yml b/.github/workflows/vitest-coverage.yml new file mode 100644 index 0000000..9236267 --- /dev/null +++ b/.github/workflows/vitest-coverage.yml @@ -0,0 +1,27 @@ +name: Vitest Unit Tests +on: + push: + branches: [main] + pull_request: + branches: [main] +jobs: + test: + runs-on: ubuntu-latest + + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/checkout@v4 + - name: 'Install Node' + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - name: 'Install Deps' + run: npm install + - name: 'Test' + run: npx vitest --coverage.enabled true + - name: 'Report Coverage' + if: always() + uses: davelosert/vitest-coverage-report-action@v2 \ No newline at end of file diff --git a/vitest.config.ts b/vitest.config.ts index de97867..33c4f4f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,7 +3,9 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { coverage: { - provider: 'v8' + provider: 'v8', + reporter: ['text', "json-summary", "json"], + reportOnFailure: true }, }, })