Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/root.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Execute ROOT macros
name: Run Cross-Validation
on:
schedule:
- cron: '17 2 * * 1' # every monday at 02:17 UTC
Expand All @@ -17,9 +17,15 @@ on:
description: 'Run latest LCG nightly build'
type: boolean
default: false
jsroot_version:
description: 'JSROOT Version (leave empty to not run tests)'
required: false
default: '7.11.1'
type: string

jobs:
cross-validation:
if: github.repository_owner == 'root-project' || github.event_name == 'pull_request'
name: Cross Validation
runs-on:
labels: [self-hosted]
Expand All @@ -28,6 +34,8 @@ jobs:
# run LCG releases 108, 109 and 110 for each schedules, and 110 for each PR/push
VERSIONS: ${{ inputs.versions || (github.event_name == 'schedule' && '108,109,110' || '110') }}
RUN_DEV3: ${{ inputs.run_dev3 == true || github.event_name == 'schedule' }}
JSROOT_SETUP: /cvmfs/sft.cern.ch/lcg/views/LCG_110/x86_64-el9-gcc13-opt/setup.sh
JSROOT_VERSION: ${{ inputs.jsroot_version || '~7.11.0' }} # use JSROOT version 7.11.x with newest patch version

container:
image: gitlab-registry.cern.ch/sft/docker/alma9-core:latest
Expand Down Expand Up @@ -59,7 +67,14 @@ jobs:
fi
eval "SCRIPTS=(/cvmfs/sft.cern.ch/lcg/views/$PATTERN/x86_64-el9-gcc13-opt/setup.sh)"
make -j$(nproc) validate source_scripts="${SCRIPTS[*]}"
shell: bash
shell: bash

- name: Run JSROOT tests
if: ${{ env.JSROOT_VERSION != '' }}
run: |
source "$JSROOT_SETUP"
npm install "jsroot@$JSROOT_VERSION"
make -j$(nproc) validate_jsroot

- name: Create HTML
run: make export_html
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ $(READ_DIR_JSROOT):
check:
@test -x "$(ROOT_EXE)" || { echo "Could not find root.exe"; exit 1; }

.PHONY: validate_jsroot
validate_jsroot:
@for w_dir in write/*; do \
$(MAKE) read_jsroot write_dir=$$(basename "$$w_dir"); \
done

.PHONY: validate
validate:
@if [ "$(source_scripts)" = "" ]; then\
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ npm install jsroot
Run `make read_jsroot` to read the generated `.root` files with [JSROOT](https://github.com/root-project/jsroot), a JavaScript library that is capable of reading ROOT files. The supported tests are inside `jsroot`. The resulting `.json` files are stored inside `read/jsroot`.

Run `make write` first to create the `.root` files using the ROOT macros!

Run `make validate_jsroot` to read the `.root` files for each subdir in `write/` and store them in subdirs in `read/<subdir>/jsroot`.
13 changes: 12 additions & 1 deletion jsroot/jsroot_reader.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFileSync, mkdirSync, existsSync } from "fs";
import { openFile, TSelector } from "jsroot";
import { openFile, TSelector, version } from "jsroot";
import { rntupleProcess } from "jsroot/rntuple";

/**
Expand Down Expand Up @@ -133,3 +133,14 @@ export function pairArrayToMap(arr) {
]),
);
}

// check if current version is newer than target
export function isNewer(target) {
const [major, minor, patch] = version.split(" ")[0].split(".").map(Number);
const [tMajor, tMinor, tPatch] = target.split(".").map(Number);
return (
major > tMajor ||
(major === tMajor && minor > tMinor) ||
(major === tMajor && minor === tMinor && patch > tPatch)
);
}
7 changes: 6 additions & 1 deletion jsroot/structure/cluster_groups/read.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { read } from "../../jsroot_reader.mjs";
import { read, isNewer } from "../../jsroot_reader.mjs";

if (!isNewer("7.11.1")) {
console.log(" -> Skipped structure/cluster_groups: version too low")
process.exit();
}

const fields = [
"Int32",
Expand Down
7 changes: 6 additions & 1 deletion jsroot/structure/empty/read.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { read } from "../../jsroot_reader.mjs";
import { read, isNewer } from "../../jsroot_reader.mjs";

if (!isNewer("7.11.1")) {
console.log(" -> Skipped structure/empty: version too low")
process.exit();
}

const fields = ["Int32"];

Expand Down
10 changes: 5 additions & 5 deletions jsroot/types/fundamental/integer/read.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { read } from "../../../jsroot_reader.mjs";
import { read, isNewer } from "../../../jsroot_reader.mjs";

/*
The following change in rntuple.mjs was necessary to make this test run:
1. line 910 & 919: remove Number() to avoid rounding of BigInt values
*/
if (!isNewer("7.11.1")) {
console.log(" -> Skipped types/fundamental/integer: version too low")
process.exit();
}

function checkBigInt(value, { marker }) {
const res = typeof value === "bigint" ? `${marker}${value}${marker}` : value;
Expand Down
7 changes: 6 additions & 1 deletion jsroot/types/fundamental/real32quant/read.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { read, floatToHex } from "../../../jsroot_reader.mjs";
import { read, floatToHex, isNewer } from "../../../jsroot_reader.mjs";

if (!isNewer("7.11.1")) {
console.log(" -> Skipped types/fundamental/real32quant: version too low")
process.exit();
}

function formatFloat(num, { field }) {
// round num to single-precision float to match the required field precision
Expand Down