Skip to content

Commit

Permalink
Merge pull request #6 from ContinuIT-nl/fix/jsonSchema
Browse files Browse the repository at this point in the history
Add jsonSchema build to buildstep using valibot. Minify npm output.
  • Loading branch information
ritsaert authored Jan 8, 2025
2 parents 60509fa + 7129623 commit 7cfb37f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 14 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 7 additions & 1 deletion build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { build, stop } from 'npm:[email protected]';
import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.11.1';
import { toJsonSchema } from 'jsr:@valibot/[email protected]';
import { testReportConfigSchema } from './src/testReportConfig.ts';

await Deno.mkdir('npm', { recursive: true });

Expand All @@ -9,7 +11,7 @@ const result = await build({
outfile: './npm/bundle.mjs',
bundle: true,
format: 'esm',
minify: false,
minify: true,
sourcemap: true,
});

Expand Down Expand Up @@ -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');
32 changes: 22 additions & 10 deletions configSchema/testReportConfigSchema.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -40,9 +41,10 @@
},
"coverage_percentage_minimal": {
"type": "number",
"default": 90
"default": 0
}
},
"required": [],
"additionalProperties": false
},
"manifest": {
Expand All @@ -65,7 +67,7 @@
},
"badges": {
"type": "boolean",
"default": true
"default": false
},
"collapseDetails": {
"type": "boolean",
Expand All @@ -92,10 +94,13 @@
"default": "#555"
},
"style": {
"type": "string",
"enum": [
"flat",
"rectangle"
"anyOf": [
{
"const": "flat"
},
{
"const": "rectangle"
}
],
"default": "flat"
},
Expand Down Expand Up @@ -136,7 +141,15 @@
"default": "#555"
},
"style": {
"$ref": "#/properties/testBadge/properties/style"
"anyOf": [
{
"const": "flat"
},
{
"const": "rectangle"
}
],
"default": "flat"
},
"levels": {
"type": "array",
Expand Down Expand Up @@ -181,6 +194,5 @@
"required": [
"input"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
"additionalProperties": false
}
8 changes: 5 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7cfb37f

Please sign in to comment.