diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22e5e2d..39aa507 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,3 +33,6 @@ jobs: - name: Run tests, coverage, create test report and badges run: deno task test + + - name: Try to build npm package + run: deno task build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a52e878..2d07023 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,5 +21,17 @@ jobs: with: deno-version: v2.x - - name: Publish package - run: deno publish + - name: Publish JSR package + run: deno task publish_jsr + + - name: Setup Node / NPM + uses: actions/setup-node@v4 + with: + node-version: '22.x' + registry-url: 'https://npm.pkg.github.com' + scope: '@continuit' + + - name: Publish NPM package + run: deno task publish_npm + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 9e67d53..88fbe52 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # testreport [![JSR](https://jsr.io/badges/@continuit/testreport)](https://jsr.io/@continuit/testreport) +[![NPM](https://img.shields.io/npm/v/@continuit/testreport?logo=npm)](https://www.npmjs.com/package/@continuit/testreport) [![ci](https://github.com/ContinuIT-nl/testreport/actions/workflows/ci.yml/badge.svg)](https://github.com/ContinuIT-nl/testreport/actions/workflows/ci.yml) [![test](./test_results/test_badge.svg)](./test_results/test_results.md) [![coverage](./test_results/coverage_badge.svg)](./test_results/test_results.md) diff --git a/build.ts b/build.ts index 46cb405..4655427 100644 --- a/build.ts +++ b/build.ts @@ -1,5 +1,7 @@ import { build, stop } from 'npm:esbuild@0.20.2'; import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.11.1'; +import { toJsonSchema } from 'jsr:@valibot/to-json-schema@0.2.1'; +import { testReportConfigSchema } from './src/testReportConfig.ts'; await Deno.mkdir('npm', { recursive: true }); @@ -9,7 +11,7 @@ const result = await build({ outfile: './npm/bundle.mjs', bundle: true, format: 'esm', - minify: false, + minify: true, sourcemap: true, }); @@ -53,4 +55,8 @@ await Deno.mkdir('npm/test_results', { recursive: true }); await Deno.copyFile('./test_results/test_badge.svg', 'npm/test_results/test_badge.svg'); await Deno.copyFile('./test_results/coverage_badge.svg', 'npm/test_results/coverage_badge.svg'); +// Also build the JSON Schema +const schema = toJsonSchema(testReportConfigSchema); +await Deno.writeTextFile('configSchema/testReportConfigSchema.json', JSON.stringify(schema, null, 2)); + console.log('build complete'); diff --git a/configSchema/testReportConfigSchema.json b/configSchema/testReportConfigSchema.json index df5b5fc..b34a0fc 100644 --- a/configSchema/testReportConfigSchema.json +++ b/configSchema/testReportConfigSchema.json @@ -1,9 +1,10 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "$schema": { "type": "string", - "default": "https://github.com/ContinuIT-nl/testreport/blob/main/configSchema/testReportConfigSchema.json" + "default": "https://raw.githubusercontent.com/ContinuIT-nl/testreport/refs/heads/main/configSchema/testReportConfigSchema.json" }, "input": { "type": "object", @@ -40,9 +41,10 @@ }, "coverage_percentage_minimal": { "type": "number", - "default": 90 + "default": 0 } }, + "required": [], "additionalProperties": false }, "manifest": { @@ -65,7 +67,7 @@ }, "badges": { "type": "boolean", - "default": true + "default": false }, "collapseDetails": { "type": "boolean", @@ -92,10 +94,13 @@ "default": "#555" }, "style": { - "type": "string", - "enum": [ - "flat", - "rectangle" + "anyOf": [ + { + "const": "flat" + }, + { + "const": "rectangle" + } ], "default": "flat" }, @@ -136,7 +141,15 @@ "default": "#555" }, "style": { - "$ref": "#/properties/testBadge/properties/style" + "anyOf": [ + { + "const": "flat" + }, + { + "const": "rectangle" + } + ], + "default": "flat" }, "levels": { "type": "array", @@ -181,6 +194,5 @@ "required": [ "input" ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" + "additionalProperties": false } diff --git a/deno.json b/deno.json index 12a9f1b..f67c966 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@continuit/testreport", - "version": "0.1.1", + "version": "0.1.2", "description": "Generates a test report and badges from your test and coverage results. Allows checking the report in your CI pipeline.", "keywords": [ "test", @@ -20,9 +20,11 @@ "tasks": { "test": "deno task test_prepare && deno test -RSW --coverage --clean --junit-path test_results/junit.xml && deno coverage --lcov --output=test_results/cov.lcov && deno coverage && deno run -RW ./src/mod.ts ./testreport.json", "test_prepare": "rm -rf test_output && mkdir -p test_output && mkdir -p test_output/deno_success && mkdir -p test_output/deno_disabled && mkdir -p test_output/deno_failed && mkdir -p test_output/jest && mkdir -p test_output/vitest && mkdir -p test_output/no_tests && mkdir -p test_output/invalid_input && mkdir -p test_output/invalid_output", - "create_config_schema": "deno eval 'import { zodToJsonSchema } from \"npm:zod-to-json-schema\"; import { testReportConfigSchema } from \"./src/testReportConfig.ts\"; Deno.writeTextFileSync(\"./configSchema/testReportConfigSchema.json\", JSON.stringify(zodToJsonSchema(testReportConfigSchema), null, 2));'", "clean": "rm -rf test_output && rm -rf coverage", - "build": "deno run -A build.ts" + "build": "deno run -A build.ts", + "all": "deno lint && deno fmt && deno check ./src/mod.ts && deno task test && deno task build && deno fmt", + "publish_jsr": "deno publish", + "publish_npm": "deno task build && cd npm && npm publish --public" }, "imports": { "@continuit/xmlscanner": "jsr:@continuit/xmlscanner@^1.0.0", diff --git a/deno.lock b/deno.lock index 21ffc55..a8b4434 100644 --- a/deno.lock +++ b/deno.lock @@ -11,9 +11,11 @@ "jsr:@std/internal@^1.0.5": "1.0.5", "jsr:@std/path@^1.0.6": "1.0.8", "jsr:@std/path@^1.0.8": "1.0.8", + "jsr:@valibot/to-json-schema@0.2.1": "0.2.1", "jsr:@valibot/valibot@~0.42.1": "0.42.1", "npm:@types/node@*": "22.5.4", - "npm:esbuild@0.20.2": "0.20.2" + "npm:esbuild@0.20.2": "0.20.2", + "npm:valibot@0.42": "0.42.1" }, "jsr": { "@continuit/xmlscanner@1.0.0": { @@ -48,6 +50,12 @@ "@std/path@1.0.8": { "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" }, + "@valibot/to-json-schema@0.2.1": { + "integrity": "db91ae91e6873d0f9da9bdd78b8b2c87ccad1768218db99b07b711ae3d04a4a8", + "dependencies": [ + "npm:valibot" + ] + }, "@valibot/valibot@0.42.1": { "integrity": "ba0f6f7964aaeec0e4b1f793d575061f325ae6254cbb9d7ff01fb65068a0a23b" } @@ -158,6 +166,9 @@ }, "undici-types@6.19.8": { "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, + "valibot@0.42.1": { + "integrity": "sha512-3keXV29Ar5b//Hqi4MbSdV7lfVp6zuYLZuA9V1PvQUsXqogr+u5lvLPLk3A4f74VUXDnf/JfWMN6sB+koJ/FFw==" } }, "workspace": {