Skip to content

Commit d95871d

Browse files
committed
ci: refactor: Remove ajv and typebox
1 parent 718c596 commit d95871d

File tree

4 files changed

+31
-97
lines changed

4 files changed

+31
-97
lines changed

ci/github-actions/benchmark/report-files.ts

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { Type, Static } from '@sinclair/typebox'
21
import console from 'console'
32
import { readFileSync } from 'fs'
4-
import process from 'process'
5-
import createAjv from '../lib/ajv'
63

74
export const PREFIX = 'tmp.benchmark-report'
85

@@ -36,26 +33,40 @@ const postProcessSchema = <Schema extends {}>(schema: Schema) => ({
3633
additionalProperties: true,
3734
})
3835

39-
export const ReportUnit = postProcessSchema(Type.Object({
40-
command: Type.String(),
41-
mean: Type.Number(),
42-
min: Type.Number(),
43-
max: Type.Number(),
44-
}))
45-
export type ReportUnit = Static<typeof ReportUnit>
36+
export interface ReportUnit {
37+
command: string
38+
mean: number
39+
min: number
40+
max: number
41+
}
4642

47-
export const Report = postProcessSchema(Type.Object({
48-
results: Type.Array(ReportUnit),
49-
}))
50-
export type Report = Static<typeof Report>
43+
export interface Report {
44+
results: ReportUnit[]
45+
}
5146

5247
export function assertReport(data: unknown): asserts data is Report {
53-
const ajv = createAjv()
54-
const valid = ajv.validate(Report, data)
55-
if (valid) return
56-
console.error('ValidationError', { data })
57-
console.error(ajv.errorsText(ajv.errors))
58-
throw process.exit(1)
48+
if (typeof data !== 'object' || data === null) {
49+
console.error(data)
50+
throw new TypeError(`Data is not an object: ${data}`)
51+
}
52+
const { results } = data as { [_ in string]: unknown }
53+
if (!Array.isArray(results)) {
54+
console.error(data)
55+
throw new TypeError(`Property 'results' is not an array`)
56+
}
57+
for (const item of results) {
58+
if (typeof item !== 'object' || data === null) {
59+
console.error(item)
60+
throw new TypeError(`An item is not an object: ${item}`)
61+
}
62+
for (const name of ['command', 'mean', 'min', 'max'] as const) {
63+
if (name in item) {
64+
continue
65+
}
66+
console.error(item)
67+
throw new TypeError(`Property '${name}' does not exist in an item`)
68+
}
69+
}
5970
}
6071

6172
export function loadByPath(path: string): Report {

ci/github-actions/lib/ajv.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

ci/github-actions/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"dependencies": {
44
"@actions/core": "^1.3.0",
55
"@actions/github": "^5.0.0",
6-
"@sinclair/typebox": "^0.16.7",
76
"@popeindustries/lit-html-server": "^3.1.0",
8-
"ajv": "^8.5.0",
9-
"ajv-formats": "^2.1.0",
107
"shell-escape": "^0.2.0",
118
"fs-extra": "^10.0.0",
129
"node-fetch": "^2.6.1",

ci/github-actions/pnpm-lock.yaml

Lines changed: 0 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)