Skip to content
Open
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
94 changes: 74 additions & 20 deletions .github/workflows/pd-store-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
with:
fetch-depth: 5

- name: Run JaCoCo report validator tests
run: hugegraph-server/hugegraph-dist/src/assembly/travis/test-check-jacoco-report.sh

- name: Use staged maven repo settings
run: |
cp $HOME/.m2/settings.xml /tmp/settings.xml || true
Expand Down Expand Up @@ -65,7 +68,7 @@ jobs:
USE_STAGE: 'false' # Whether to include the stage repository.
# TODO: remove outdated env
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
REPORT_DIR: target/site/jacoco
REPORT_FILE: hugegraph-pd/hg-pd-test/target/site/jacoco/jacoco.xml

steps:
- name: Install JDK 11
Expand All @@ -92,20 +95,26 @@ jobs:
cp $HOME/.m2/settings.xml /tmp/settings.xml
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml

- name: Run common test
- name: Package
# todo remove --fail-at-end after test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp --fail-at-end

- name: Run core test
- name: Check source formatting
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test
mvn editorconfig:check -pl hugegraph-pd/hg-pd-test -am -ntp

# The above tests do not require starting a PD instance.
# These tests do not require starting a PD instance. Run them after the
# clean package so their JaCoCo data survives until the final report.
- name: Run common test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am \
-P pd-common-test -Djacoco.sessionId=pd-common-test

- name: Package
# todo remove --fail-at-end after test
- name: Run core test
run: |
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp --fail-at-end
mvn test -pl hugegraph-pd/hg-pd-test -am \
-P pd-core-test -Djacoco.sessionId=pd-core-test

- name: Check startup test prerequisites (PD)
id: pd-preflight
Expand Down Expand Up @@ -139,16 +148,33 @@ jobs:

- name: Run client test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-client-test
mvn test -pl hugegraph-pd/hg-pd-test -am \
-P pd-client-test -Djacoco.sessionId=pd-client-test

- name: Run rest test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-rest-test
mvn test -pl hugegraph-pd/hg-pd-test -am \
-P pd-rest-test -Djacoco.sessionId=pd-rest-test

- name: Generate aggregate coverage report
run: |
mvn verify -pl hugegraph-pd/hg-pd-test -am -P jacoco \
-DskipTests -Deditorconfig.skip=true -ntp

- name: Validate aggregate coverage report
run: |
$TRAVIS_DIR/check-jacoco-report.sh \
--require-session pd-common-test \
--require-session pd-core-test \
--require-session pd-client-test \
--require-session pd-rest-test \
"$REPORT_FILE" \
hg-pd-grpc hg-pd-common hg-pd-client hg-pd-core hg-pd-service hg-pd-dist

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.0.0
with:
file: ${{ env.REPORT_DIR }}/*.xml
files: ${{ env.REPORT_FILE }}

store:
needs: struct
Expand All @@ -157,7 +183,7 @@ jobs:
USE_STAGE: 'false' # Whether to include the stage repository.
# TODO: remove outdated env
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
REPORT_DIR: target/site/jacoco
REPORT_FILE: hugegraph-store/hg-store-test/target/site/jacoco/jacoco.xml

steps:
- name: Install JDK 11
Expand Down Expand Up @@ -189,6 +215,10 @@ jobs:
run: |
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp --fail-at-end

- name: Check source formatting
run: |
mvn editorconfig:check -pl hugegraph-store/hg-store-test -am -ntp

- name: Check startup test prerequisites (Store)
id: store-preflight
run: |
Expand Down Expand Up @@ -228,32 +258,56 @@ jobs:

- name: Run common test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-common-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-common-test -Djacoco.sessionId=store-common-test

- name: Run client test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-client-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-client-test -Djacoco.sessionId=store-client-test

- name: Run core test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-core-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-core-test -Djacoco.sessionId=store-core-test

- name: Run rocksdb test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-rocksdb-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-rocksdb-test -Djacoco.sessionId=store-rocksdb-test

- name: Run server test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-server-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-server-test -Djacoco.sessionId=store-server-test

- name: Run raft-core test
run: |
mvn test -pl hugegraph-store/hg-store-test -am -P store-raftcore-test
mvn test -pl hugegraph-store/hg-store-test -am \
-P store-raftcore-test -Djacoco.sessionId=store-raftcore-test

- name: Generate aggregate coverage report
run: |
mvn verify -pl hugegraph-store/hg-store-test -am -P jacoco \
-DskipTests -Deditorconfig.skip=true -ntp

- name: Validate aggregate coverage report
run: |
$TRAVIS_DIR/check-jacoco-report.sh \
--require-session store-common-test \
--require-session store-client-test \
--require-session store-core-test \
--require-session store-rocksdb-test \
--require-session store-server-test \
--require-session store-raftcore-test \
"$REPORT_FILE" \
hg-store-grpc hg-store-common hg-store-client hg-store-rocksdb \
hg-store-core hg-store-node

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.0.0
with:
file: ${{ env.REPORT_DIR }}/*.xml
files: ${{ env.REPORT_FILE }}

hstore:
needs: struct
Expand Down
37 changes: 10 additions & 27 deletions hugegraph-pd/hg-pd-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<excludes>
<exclude>**/grpc/**.*</exclude>
<exclude>**/config/**.*</exclude>
</excludes>
</configuration>
<version>0.8.8</version>
<executions>
<execution>
<id>coverage-report</id>
<phase>verify</phase>
<goals>
<goal>prepare-agent</goal>
<goal>report-aggregate</goal>
</goals>
<configuration>
<outputDirectory>
${project.basedir}/target/site/jacoco
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -258,25 +259,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>pre-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-test</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/site/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
<version>0.8.8</version>
<configuration>
<excludes>
<exclude>org/apache/hugegraph/pd/rest/*.class</exclude>
Expand Down
3 changes: 2 additions & 1 deletion hugegraph-pd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<version>0.8.8</version>
<configuration>
<append>true</append>
<excludes>
<exclude>**/grpc/**.*</exclude>
<exclude>**/config/**.*</exclude>
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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.

if ! grep -Fq "<group name=\"${module}\"" "${REPORT_FILE}"; then
echo "ERROR: missing JaCoCo group '${module}' in ${REPORT_FILE}" >&2
exit 1
fi
done

echo "JaCoCo report ${REPORT_FILE} contains all expected modules"
Loading
Loading