diff --git a/package-lock.json b/package-lock.json index 4d8aa231..f680c7ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { + "@fontsource/roboto": "5.0.3", "@octokit/auth-app": "4.0.13", "@octokit/rest": "19.0.11", "@sgratzl/chartjs-chart-boxplot": "^3.10.0", @@ -768,6 +769,11 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fontsource/roboto": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-5.0.3.tgz", + "integrity": "sha512-jbZDFwEFARDlo8TqG7th/xjhuq87GYfFpFb+uxuy+0Ng1bhRVgBRWlLj8+WIKhCTOr+h4QXbjpybLWFLUirOwQ==" + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", diff --git a/package.json b/package.json index 68223442..c07dea24 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "MIT", "type": "module", "dependencies": { + "@fontsource/roboto": "5.0.3", "@octokit/auth-app": "4.0.13", "@octokit/rest": "19.0.11", "chart.js": "^3.5.1", diff --git a/src/charts.ts b/src/charts.ts index e8fcf9f5..890ee44d 100644 --- a/src/charts.ts +++ b/src/charts.ts @@ -13,7 +13,7 @@ import { BoxAndWiskers } from '@sgratzl/chartjs-chart-boxplot'; import { medianUnsorted } from '../src/stats.js'; -import { siteAesthetics } from './util.js'; +import { robustPath, siteAesthetics } from './util.js'; const fullyTransparent = 'rgba(0, 0, 0, 0)'; @@ -145,6 +145,8 @@ export function createCanvas(settings: CanvasSettings): ChartJSNodeCanvas { backgroundColour: siteAesthetics.backgroundColor, plugins: { modern: plugins }, chartCallback: (ChartJS) => { + ChartJS.defaults.font.family = 'Roboto'; + ChartJS.register({ id: 'my_background_color', beforeDraw: (chart, _options) => { @@ -171,7 +173,28 @@ export function createCanvas(settings: CanvasSettings): ChartJSNodeCanvas { if (settings.outputType === 'svg') { (canvasOptions).type = 'svg'; // work around the readonly property } - return new ChartJSNodeCanvas(canvasOptions); + + const canvas = new ChartJSNodeCanvas(canvasOptions); + + canvas.registerFont( + robustPath( + '../node_modules/@fontsource/roboto/files/roboto-latin-400-normal.woff' + ), + { + family: 'Roboto', + weight: '400' + } + ); + canvas.registerFont( + robustPath( + '../node_modules/@fontsource/roboto/files/roboto-latin-700-normal.woff' + ), + { + family: 'Roboto', + weight: '700' + } + ); + return canvas; } async function renderDataOnCanvas( diff --git a/src/logging.ts b/src/logging.ts index b6997ca5..0b1a3b2c 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -1,4 +1,5 @@ import { Logger } from 'tslog'; +import { isRunningTests } from './util.js'; // 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal const trace = 2; @@ -6,11 +7,7 @@ const info = 3; const error = 5; function getLoggingLevel(): number { - if ( - ('NODE_ENV' in process.env && process.env.NODE_ENV === 'test') || - ('JEST_WORKER_ID' in process.env && - process.env.JEST_WORKER_ID !== undefined) - ) { + if (isRunningTests()) { return error; } diff --git a/src/util.ts b/src/util.ts index b4457681..f45d53b3 100644 --- a/src/util.ts +++ b/src/util.ts @@ -56,6 +56,14 @@ export function isReBenchDotDev(): boolean { return siteConfig.publicUrl === _rebench_dev; } +export function isRunningTests(): boolean { + return ( + ('NODE_ENV' in process.env && process.env.NODE_ENV === 'test') || + ('JEST_WORKER_ID' in process.env && + process.env.JEST_WORKER_ID !== undefined) + ); +} + export const statsConfig = { numberOfBootstrapSamples: 50 }; diff --git a/tests/data/expected-results/charts/inline-1.svg b/tests/data/expected-results/charts/inline-1.svg index 03b4b943..dd326fc0 100644 --- a/tests/data/expected-results/charts/inline-1.svg +++ b/tests/data/expected-results/charts/inline-1.svg @@ -27,57 +27,57 @@ - - - - - - + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - + - - - - - + + + + + diff --git a/tests/data/expected-results/charts/jssom-som.png b/tests/data/expected-results/charts/jssom-som.png index f8b3ca65..9cc5190e 100644 Binary files a/tests/data/expected-results/charts/jssom-som.png and b/tests/data/expected-results/charts/jssom-som.png differ diff --git a/tests/data/expected-results/charts/jssom-som.svg b/tests/data/expected-results/charts/jssom-som.svg index 7518b427..cee82434 100644 --- a/tests/data/expected-results/charts/jssom-som.svg +++ b/tests/data/expected-results/charts/jssom-som.svg @@ -5,7 +5,7 @@ - + @@ -14,59 +14,59 @@ - - + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/jssom.png b/tests/data/expected-results/charts/jssom.png index 226a1a54..4b550a26 100644 Binary files a/tests/data/expected-results/charts/jssom.png and b/tests/data/expected-results/charts/jssom.png differ diff --git a/tests/data/expected-results/charts/trufflesom-macro-startup.png b/tests/data/expected-results/charts/trufflesom-macro-startup.png index 34d0bf3d..96272aa7 100644 Binary files a/tests/data/expected-results/charts/trufflesom-macro-startup.png and b/tests/data/expected-results/charts/trufflesom-macro-startup.png differ diff --git a/tests/data/expected-results/charts/trufflesom-macro-startup.svg b/tests/data/expected-results/charts/trufflesom-macro-startup.svg index 3cc604e9..66b60d0b 100644 --- a/tests/data/expected-results/charts/trufflesom-macro-startup.svg +++ b/tests/data/expected-results/charts/trufflesom-macro-startup.svg @@ -2,84 +2,84 @@ - + - + - + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/trufflesom-macro-steady.png b/tests/data/expected-results/charts/trufflesom-macro-steady.png index cc89250c..279a78e7 100644 Binary files a/tests/data/expected-results/charts/trufflesom-macro-steady.png and b/tests/data/expected-results/charts/trufflesom-macro-steady.png differ diff --git a/tests/data/expected-results/charts/trufflesom-macro-steady.svg b/tests/data/expected-results/charts/trufflesom-macro-steady.svg index d6546efa..0cf59363 100644 --- a/tests/data/expected-results/charts/trufflesom-macro-steady.svg +++ b/tests/data/expected-results/charts/trufflesom-macro-steady.svg @@ -2,57 +2,57 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/trufflesom-micro-somsom.png b/tests/data/expected-results/charts/trufflesom-micro-somsom.png index 014c9b85..1749c241 100644 Binary files a/tests/data/expected-results/charts/trufflesom-micro-somsom.png and b/tests/data/expected-results/charts/trufflesom-micro-somsom.png differ diff --git a/tests/data/expected-results/charts/trufflesom-micro-somsom.svg b/tests/data/expected-results/charts/trufflesom-micro-somsom.svg index 6848f28b..b9a94b3e 100644 --- a/tests/data/expected-results/charts/trufflesom-micro-somsom.svg +++ b/tests/data/expected-results/charts/trufflesom-micro-somsom.svg @@ -2,55 +2,55 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/trufflesom-micro-startup.png b/tests/data/expected-results/charts/trufflesom-micro-startup.png index 3f536616..4de985f8 100644 Binary files a/tests/data/expected-results/charts/trufflesom-micro-startup.png and b/tests/data/expected-results/charts/trufflesom-micro-startup.png differ diff --git a/tests/data/expected-results/charts/trufflesom-micro-startup.svg b/tests/data/expected-results/charts/trufflesom-micro-startup.svg index c9cadc0e..860166a6 100644 --- a/tests/data/expected-results/charts/trufflesom-micro-startup.svg +++ b/tests/data/expected-results/charts/trufflesom-micro-startup.svg @@ -2,140 +2,140 @@ - + - + - + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/trufflesom-micro-steady.png b/tests/data/expected-results/charts/trufflesom-micro-steady.png index 1cdc082b..40bccb77 100644 Binary files a/tests/data/expected-results/charts/trufflesom-micro-steady.png and b/tests/data/expected-results/charts/trufflesom-micro-steady.png differ diff --git a/tests/data/expected-results/charts/trufflesom-micro-steady.svg b/tests/data/expected-results/charts/trufflesom-micro-steady.svg index 05e21704..95c48ac1 100644 --- a/tests/data/expected-results/charts/trufflesom-micro-steady.svg +++ b/tests/data/expected-results/charts/trufflesom-micro-steady.svg @@ -2,85 +2,85 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/charts/trufflesom.png b/tests/data/expected-results/charts/trufflesom.png index a9c0cb9b..2ea97650 100644 Binary files a/tests/data/expected-results/charts/trufflesom.png and b/tests/data/expected-results/charts/trufflesom.png differ diff --git a/tests/data/expected-results/stats-data-prep/jssom/inline-24.svg b/tests/data/expected-results/stats-data-prep/jssom/inline-24.svg index cd6d433b..6c2183ed 100644 --- a/tests/data/expected-results/stats-data-prep/jssom/inline-24.svg +++ b/tests/data/expected-results/stats-data-prep/jssom/inline-24.svg @@ -26,56 +26,56 @@ - - - - - + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - + - - - - - + + + + + diff --git a/tests/data/expected-results/stats-data-prep/jssom/inline-4.svg b/tests/data/expected-results/stats-data-prep/jssom/inline-4.svg index c47a1110..c1eddb20 100644 --- a/tests/data/expected-results/stats-data-prep/jssom/inline-4.svg +++ b/tests/data/expected-results/stats-data-prep/jssom/inline-4.svg @@ -26,56 +26,56 @@ - - - - - + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - + - - - - - + + + + + diff --git a/tests/data/expected-results/stats-data-prep/jssom/overview-som.svg b/tests/data/expected-results/stats-data-prep/jssom/overview-som.svg index 7518b427..cee82434 100644 --- a/tests/data/expected-results/stats-data-prep/jssom/overview-som.svg +++ b/tests/data/expected-results/stats-data-prep/jssom/overview-som.svg @@ -5,7 +5,7 @@ - + @@ -14,59 +14,59 @@ - - + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/jssom/overview.png b/tests/data/expected-results/stats-data-prep/jssom/overview.png index 226a1a54..4b550a26 100644 Binary files a/tests/data/expected-results/stats-data-prep/jssom/overview.png and b/tests/data/expected-results/stats-data-prep/jssom/overview.png differ diff --git a/tests/data/expected-results/stats-data-prep/tsom/inline-111.svg b/tests/data/expected-results/stats-data-prep/tsom/inline-111.svg index 2213b726..c4b78d86 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/inline-111.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/inline-111.svg @@ -11,7 +11,7 @@ - + @@ -70,196 +70,196 @@ - - - - - - - + + + + + + + - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - + - - - - + + + + - + - - - - - - - - + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/inline-156.svg b/tests/data/expected-results/stats-data-prep/tsom/inline-156.svg index 89567af9..4062a81f 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/inline-156.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/inline-156.svg @@ -23,43 +23,43 @@ - - - - - + + + + + - + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - + + + - + - + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview-macro-startup.svg b/tests/data/expected-results/stats-data-prep/tsom/overview-macro-startup.svg index 3cc604e9..66b60d0b 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/overview-macro-startup.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/overview-macro-startup.svg @@ -2,84 +2,84 @@ - + - + - + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview-macro-steady.svg b/tests/data/expected-results/stats-data-prep/tsom/overview-macro-steady.svg index d6546efa..0cf59363 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/overview-macro-steady.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/overview-macro-steady.svg @@ -2,57 +2,57 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-somsom.svg b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-somsom.svg index 6848f28b..b9a94b3e 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-somsom.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-somsom.svg @@ -2,55 +2,55 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-startup.svg b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-startup.svg index c9cadc0e..860166a6 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-startup.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-startup.svg @@ -2,140 +2,140 @@ - + - + - + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-steady.svg b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-steady.svg index 05e21704..95c48ac1 100644 --- a/tests/data/expected-results/stats-data-prep/tsom/overview-micro-steady.svg +++ b/tests/data/expected-results/stats-data-prep/tsom/overview-micro-steady.svg @@ -2,85 +2,85 @@ - + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/expected-results/stats-data-prep/tsom/overview.png b/tests/data/expected-results/stats-data-prep/tsom/overview.png index a9c0cb9b..2ea97650 100644 Binary files a/tests/data/expected-results/stats-data-prep/tsom/overview.png and b/tests/data/expected-results/stats-data-prep/tsom/overview.png differ