Skip to content

Commit

Permalink
HDDS-8240. Disable JaCoCo for PRs and in forks (#4449)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai committed Mar 25, 2023
1 parent 191bb5f commit 11355a4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
env:
FAIL_FAST: ${{ github.event_name == 'pull_request' }}
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
OZONE_WITH_COVERAGE: ${{ github.repository == 'apache/ozone' && github.event_name != 'pull_request' }}
jobs:
build-info:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -93,7 +94,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run a full build
run: hadoop-ozone/dev-support/checks/build.sh -Pcoverage -Pdist -Psrc
run: hadoop-ozone/dev-support/checks/build.sh -Pdist -Psrc
- name: Store binaries for tests
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -148,6 +149,8 @@ jobs:
java-version: ${{ matrix.java }}
- name: Compile Ozone using Java ${{ matrix.java }}
run: hadoop-ozone/dev-support/checks/build.sh -Dskip.npx -Dskip.installnpx -Djavac.version=${{ matrix.java }}
env:
OZONE_WITH_COVERAGE: false
- name: Delete temporary build artifacts before caching
run: |
#Never cache local artifacts
Expand Down Expand Up @@ -274,7 +277,6 @@ jobs:
env:
KEEP_IMAGE: false
OZONE_ACCEPTANCE_SUITE: ${{ matrix.suite }}
OZONE_WITH_COVERAGE: true
OZONE_VOLUME_OWNER: 1000
- name: Archive build results
uses: actions/upload-artifact@v3
Expand Down
12 changes: 11 additions & 1 deletion hadoop-ozone/dev-support/checks/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../../.." || exit 1

: ${OZONE_WITH_COVERAGE:="false"}

MAVEN_OPTIONS='-V -B -Dmaven.javadoc.skip=true -DskipTests -DskipDocs --no-transfer-progress'

if [[ "${OZONE_WITH_COVERAGE}" == "true" ]]; then
MAVEN_OPTIONS="${MAVEN_OPTIONS} -Pcoverage"
else
MAVEN_OPTIONS="${MAVEN_OPTIONS} -Djacoco.skip"
fi

export MAVEN_OPTS="-Xmx4096m $MAVEN_OPTS"
mvn -V -B -Dmaven.javadoc.skip=true -DskipTests -DskipDocs --no-transfer-progress clean install "$@"
mvn ${MAVEN_OPTIONS} clean install "$@"
exit $?
6 changes: 6 additions & 0 deletions hadoop-ozone/dev-support/checks/findbugs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../../.." || exit 1

: ${OZONE_WITH_COVERAGE:="false"}

source "${DIR}/_lib.sh"

install_spotbugs

MAVEN_OPTIONS='-B -fae -Dskip.npx -Dskip.installnpx --no-transfer-progress'

if [[ "${OZONE_WITH_COVERAGE}" != "true" ]]; then
MAVEN_OPTIONS="${MAVEN_OPTIONS} -Djacoco.skip"
fi

#shellcheck disable=SC2086
mvn ${MAVEN_OPTIONS} test-compile spotbugs:spotbugs "$@"
rc=$?
Expand Down
11 changes: 9 additions & 2 deletions hadoop-ozone/dev-support/checks/junit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cd "$DIR/../../.." || exit 1

: ${CHECK:="unit"}
: ${ITERATIONS:="1"}
: ${OZONE_WITH_COVERAGE:="false"}

declare -i ITERATIONS
if [[ ${ITERATIONS} -le 0 ]]; then
Expand All @@ -30,6 +31,10 @@ fi
export MAVEN_OPTS="-Xmx4096m $MAVEN_OPTS"
MAVEN_OPTIONS='-B -Dskip.npx -Dskip.installnpx --no-transfer-progress'

if [[ "${OZONE_WITH_COVERAGE}" != "true" ]]; then
MAVEN_OPTIONS="${MAVEN_OPTIONS} -Djacoco.skip"
fi

if [[ "${FAIL_FAST:-}" == "true" ]]; then
MAVEN_OPTIONS="${MAVEN_OPTIONS} --fail-fast -Dsurefire.skipAfterFailureCount=1"
else
Expand Down Expand Up @@ -71,7 +76,9 @@ for i in $(seq 1 ${ITERATIONS}); do
fi
done

#Archive combined jacoco records
mvn -B -N jacoco:merge -Djacoco.destFile=$REPORT_DIR/jacoco-combined.exec
if [[ "${OZONE_WITH_COVERAGE}" == "true" ]]; then
#Archive combined jacoco records
mvn -B -N jacoco:merge -Djacoco.destFile=$REPORT_DIR/jacoco-combined.exec
fi

exit ${rc}
6 changes: 4 additions & 2 deletions hadoop-ozone/dist/src/main/compose/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ rm "$ALL_RESULT_DIR"/* || true

source "$SCRIPT_DIR"/testlib.sh

if [ "$OZONE_WITH_COVERAGE" ]; then
: ${OZONE_WITH_COVERAGE:="false"}

if [[ "${OZONE_WITH_COVERAGE}" == "true" ]]; then
java -cp "$PROJECT_DIR"/share/coverage/$(ls "$PROJECT_DIR"/share/coverage | grep test-util):"$PROJECT_DIR"/share/coverage/jacoco-core.jar org.apache.hadoop.test.JacocoServer &
DOCKER_BRIDGE_IP=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}')
export OZONE_OPTS="-javaagent:share/coverage/jacoco-agent.jar=output=tcpclient,address=$DOCKER_BRIDGE_IP,includes=org.apache.hadoop.ozone.*:org.apache.hadoop.hdds.*:org.apache.hadoop.fs.ozone.*"
Expand All @@ -39,7 +41,7 @@ cd "$SCRIPT_DIR"
RESULT=0
run_test_scripts ${tests} || RESULT=$?

if [ "$OZONE_WITH_COVERAGE" ]; then
if [[ "${OZONE_WITH_COVERAGE}" == "true" ]]; then
pkill -f JacocoServer
cp /tmp/jacoco-combined.exec "$SCRIPT_DIR"/result
fi
Expand Down

0 comments on commit 11355a4

Please sign in to comment.