imbajin commented on code in PR #3161:
URL: https://github.com/apache/hugegraph/pull/3161#discussion_r3814519826


##########
hugegraph-server/hugegraph-dist/src/assembly/travis/check-jacoco-report.sh:
##########
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -uo pipefail
+
+REQUIRED_SESSIONS=()
+while [[ "${1:-}" == "--require-session" ]]; do
+    REQUIRED_SESSIONS+=("${2:-}")
+    shift 2 || true
+done
+
+if (( ${#REQUIRED_SESSIONS[@]} == 0 )); then
+    echo "ERROR: at least one --require-session is required" >&2
+    exit 1
+fi
+
+REPORT_FILE="${1:-}"
+shift || true
+
+if [[ -z "${REPORT_FILE}" || ! -s "${REPORT_FILE}" ]]; then
+    echo "ERROR: JaCoCo report not found or empty: ${REPORT_FILE:-<unset>}" >&2
+    exit 1
+fi
+
+if ! grep -Eq '<counter type="INSTRUCTION" missed="[0-9]+" 
covered="[1-9][0-9]*"' \
+     "${REPORT_FILE}"; then
+    echo "ERROR: JaCoCo report has no covered instructions: ${REPORT_FILE}" >&2
+    exit 1
+fi
+
+for session in "${REQUIRED_SESSIONS[@]}"; do

Review Comment:
   ⚠️ Important: This only proves that some reactor module emitted 
`<sessioninfo id="...">`. Because the workflow uses `-am` and assigns the same 
`-Djacoco.sessionId` to the whole reactor, a target profile that matches zero 
tests can still pass when an upstream module emits the same session and another 
module contributes covered instructions. Please assert a non-zero test count 
for the selected PD/Store suite, or use suite/module-specific execution data, 
before allowing the upload.



##########
hugegraph-server/hugegraph-dist/src/assembly/travis/check-jacoco-report.sh:
##########
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -uo pipefail
+
+REQUIRED_SESSIONS=()
+while [[ "${1:-}" == "--require-session" ]]; do
+    REQUIRED_SESSIONS+=("${2:-}")
+    shift 2 || true

Review Comment:
   ⚠️ Important: If the command ends with `--require-session`, `${2:-}` is 
accepted as an empty session and `shift 2` fails; `|| true` leaves `$1` 
unchanged, so this `while` loop never terminates. Please reject a missing or 
empty value before shifting and exit nonzero for malformed input.



##########
hugegraph-server/hugegraph-dist/src/assembly/travis/check-jacoco-report.sh:
##########
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -uo pipefail
+
+REQUIRED_SESSIONS=()
+while [[ "${1:-}" == "--require-session" ]]; do
+    REQUIRED_SESSIONS+=("${2:-}")
+    shift 2 || true
+done
+
+if (( ${#REQUIRED_SESSIONS[@]} == 0 )); then
+    echo "ERROR: at least one --require-session is required" >&2
+    exit 1
+fi
+
+REPORT_FILE="${1:-}"
+shift || true
+
+if [[ -z "${REPORT_FILE}" || ! -s "${REPORT_FILE}" ]]; then
+    echo "ERROR: JaCoCo report not found or empty: ${REPORT_FILE:-<unset>}" >&2
+    exit 1
+fi
+
+if ! grep -Eq '<counter type="INSTRUCTION" missed="[0-9]+" 
covered="[1-9][0-9]*"' \
+     "${REPORT_FILE}"; then
+    echo "ERROR: JaCoCo report has no covered instructions: ${REPORT_FILE}" >&2
+    exit 1
+fi
+
+for session in "${REQUIRED_SESSIONS[@]}"; do
+    if ! grep -Fq "<sessioninfo id=\"${session}\" " "${REPORT_FILE}"; then
+        echo "ERROR: missing JaCoCo session '${session}' in ${REPORT_FILE}" >&2
+        exit 1
+    fi
+done
+
+for module in "$@"; do

Review Comment:
   ⚠️ Important: The validator accepts a report with a covered counter and 
required session even when no module arguments are supplied, because this loop 
is skipped for an empty `"$@"`. A future workflow edit that drops the module 
list would therefore still upload an incomplete aggregate. Please require at 
least one module and add a contract test for the missing-module case, ideally 
asserting the exact PD/Store module lists.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to