Skip to content

Commit acabd70

Browse files
tsteenbefviernau
authored andcommitted
ort-evaluator: Conditionally set Evaluator CLI options
Only set options for files or directories found in configuration directory. Signed-off-by: Thomas Steenbergen <[email protected]>
1 parent ab25f7b commit acabd70

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ ort-scan:
136136
ORT_CONFIG_CUSTOM_LICENSE_TEXTS_DIR: "${ORT_CONFIG_DIR}/custom-license-ids"
137137
ORT_CONFIG_LICENSE_CONFIGURATION_FILE: "${ORT_CONFIG_DIR}/license-classifications.yml"
138138
ORT_CONFIG_RESOLUTIONS_FILE: "${ORT_CONFIG_DIR}/resolutions.yml"
139+
ORT_CONFIG_RULES_FILE: "${ORT_CONFIG_DIR}/evaluator.rules.kts"
139140
ORT_CONFIG_PACKAGE_CONFIGURATION_DIR: "${ORT_CONFIG_DIR}/package-configurations"
141+
ORT_CONFIG_PACKAGE_CONFIGURATION_FILE: "${ORT_CONFIG_DIR}/packages.yml"
140142
ORT_CONFIG_NOTICE_TEMPLATE_PATHS: "${ORT_CONFIG_DIR}/notice/summary.ftl,${ORT_CONFIG_DIR}/notice/by-package.ftl"
141143

142144
ORT_DATA_DIR: ".ort"

scripts/ort-evaluator.sh

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,49 @@ else
1111
ORT_RESULTS_INPUT_FILE=$ORT_RESULTS_SCANNER_FILE
1212
fi
1313

14+
if [[ -f "$ORT_CONFIG_LICENSE_CONFIGURATION_FILE" ]]; then
15+
ORT_EVALUATOR_OPTIONS="--license-classifications-file $ORT_CONFIG_LICENSE_CONFIGURATION_FILE"
16+
else
17+
ORT_EVALUATOR_OPTIONS=""
18+
fi
19+
20+
if [[ -d "$ORT_CONFIG_PACKAGE_CONFIGURATION_DIR" ]]; then
21+
ORT_EVALUATOR_OPTIONS="$ORT_EVALUATOR_OPTIONS --package-configuration-dir $ORT_CONFIG_PACKAGE_CONFIGURATION_DIR"
22+
elif [[ -f "$ORT_CONFIG_PACKAGE_CONFIGURATION_FILE" ]]; then
23+
ORT_EVALUATOR_OPTIONS="$ORT_EVALUATOR_OPTIONS --package-configuration-file $ORT_CONFIG_PACKAGE_CONFIGURATION_FILE"
24+
elif [[ -d "$ORT_CONFIG/packages" ]]; then
25+
# Use legacy named package configuration directory if present.
26+
ORT_EVALUATOR_OPTIONS="$ORT_EVALUATOR_OPTIONS --package-configuration-dir $ORT_CONFIG/packages"
27+
ORT_CONFIG_PACKAGE_CONFIGURATION_DIR=$ORT_CONFIG/packages
28+
fi
29+
30+
if [[ ! -f "$ORT_CONFIG_RULES_FILE" ]]; then
31+
# Use legacy named policy rules file if present
32+
if [[ -f "$ORT_CONFIG_DIR/rules.kts" ]]; then
33+
ORT_CONFIG_RULES_FILE="$ORT_CONFIG_DIR/rules.kts"
34+
else
35+
# Use first found file with .rules.kts extension
36+
FIND_RESULTS=$(find $ORT_CONFIG_DIR -type f -name '*.rules.kts')
37+
RESULT_FILES=( $FIND_RESULTS )
38+
ORT_CONFIG_RULES_FILE="${RESULT_FILES[0]}"
39+
fi
40+
fi
41+
42+
if [[ -f "$ORT_CONFIG_RULES_FILE" ]]; then
43+
echo "Using ORT policy rules file found in $ORT_CONFIG_RULES_FILE..."
44+
else
45+
echo "Error: ORT policy rules file (*.rules.kts) not found. Please set ORT_CONFIG_RULES_FILE"
46+
fi
47+
1448
$ORT \
1549
--$ORT_LOG_LEVEL \
1650
--stacktrace \
1751
evaluate \
52+
$ORT_EVALUATOR_OPTIONS \
1853
-i $ORT_RESULTS_INPUT_FILE \
1954
-o $ORT_RESULTS_DIR \
20-
-r $ORT_CONFIG_DIR/rules.kts \
21-
-f JSON \
22-
--license-classifications-file $ORT_CONFIG_LICENSE_CONFIGURATION_FILE \
23-
--package-configuration-dir $ORT_CONFIG_PACKAGE_CONFIGURATION_DIR
55+
-r $ORT_CONFIG_RULES_FILE \
56+
-f JSON
2457

2558
EXIT_CODE=$?
2659
if [ $EXIT_CODE -ge 2 ]; then

0 commit comments

Comments
 (0)