Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-10: Add basic checks into pre-commit-config #435

Merged
merged 7 commits into from
Dec 26, 2024
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
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

[*.sh]
indent_style = space
indent_size = 2
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ repos:
- id: check-added-large-files
- id: file-contents-sorter
files: .gitignore

- repo: local
hooks:
- id: rat
Expand All @@ -39,3 +38,15 @@ repos:
dev/release/run_rat.sh apache-arrow-go.tar.gz"
always_run: true
pass_filenames: false
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
hooks:
- id: shfmt
args:
# The default args is "--write --simplify" but we don't use
# "--simplify". Because it's conflicted will ShellCheck.
- "--write"
15 changes: 7 additions & 8 deletions ci/scripts/java_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ if [[ "${ARROW_JAVA_BUILD:-ON}" != "ON" ]]; then
exit
fi

arrow_dir=${1}
source_dir=${1}
build_dir=${2}
java_jni_dist_dir=${3}

: ${BUILD_DOCS_JAVA:=OFF}
: "${BUILD_DOCS_JAVA:=OFF}"

mvn="mvn -B -DskipTests -Drat.skip=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"

if [ $ARROW_JAVA_SKIP_GIT_PLUGIN ]; then
if [ "$ARROW_JAVA_SKIP_GIT_PLUGIN" ]; then
mvn="${mvn} -Dmaven.gitcommitid.skip=true"
fi

Expand All @@ -50,13 +49,13 @@ cp -r "${source_dir}/dev" "${build_dir}"

poms=$(find "${source_dir}" -not \( -path "${source_dir}"/build -prune \) -type f -name pom.xml)
if [[ "$OSTYPE" == "darwin"* ]]; then
poms=$(echo "$poms" | xargs -n1 python -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")
poms=$(echo "$poms" | xargs -n1 python -c "import sys; import os.path; print(os.path.relpath(sys.argv[1], '${source_dir}'))")
else
poms=$(echo "$poms" | xargs -n1 realpath -s --relative-to="${source_dir}")
poms=$(echo "$poms" | xargs -n1 realpath -s --relative-to="${source_dir}")
fi

for source_root in $(echo "${poms}" | awk -F/ '{print $1}' | sort -u); do
cp -r "${source_dir}/${source_root}" "${build_dir}"
cp -r "${source_dir}/${source_root}" "${build_dir}"
done

pushd "${build_dir}"
Expand All @@ -79,9 +78,9 @@ ${mvn} -T 2C clean install
if [ "${BUILD_DOCS_JAVA}" == "ON" ]; then
# HTTP pooling is turned of to avoid download issues https://issues.apache.org/jira/browse/ARROW-11633
# GH-43378: Maven site plugins not compatible with multithreading
mkdir -p ${build_dir}/docs/java/reference
mkdir -p "${build_dir}"/docs/java/reference
${mvn} -Dcheckstyle.skip=true -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false clean install site
rsync -a target/site/apidocs/ ${build_dir}/docs/java/reference
rsync -a target/site/apidocs/ "${build_dir}"/docs/java/reference
fi

popd
56 changes: 28 additions & 28 deletions ci/scripts/java_jni_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,54 +27,54 @@ prefix_dir="${build_dir}/java-jni"

echo "=== Clear output directories and leftovers ==="
# Clear output directories and leftovers
rm -rf ${build_dir}
rm -rf "${build_dir}"

echo "=== Building Arrow Java C Data Interface native library ==="
mkdir -p "${build_dir}"
pushd "${build_dir}"

case "$(uname)" in
Linux)
n_jobs=$(nproc)
;;
Darwin)
n_jobs=$(sysctl -n hw.logicalcpu)
;;
*)
n_jobs=${NPROC:-1}
;;
Linux)
n_jobs=$(nproc)
;;
Darwin)
n_jobs=$(sysctl -n hw.logicalcpu)
;;
*)
n_jobs=${NPROC:-1}
;;
esac

: ${ARROW_JAVA_BUILD_TESTS:=${ARROW_BUILD_TESTS:-OFF}}
: ${CMAKE_BUILD_TYPE:=release}
: "${ARROW_JAVA_BUILD_TESTS:=${ARROW_BUILD_TESTS:-OFF}}"
: "${CMAKE_BUILD_TYPE:=release}"
cmake \
-DARROW_JAVA_JNI_ENABLE_DATASET=${ARROW_DATASET:-OFF} \
-DARROW_JAVA_JNI_ENABLE_GANDIVA=${ARROW_GANDIVA:-OFF} \
-DARROW_JAVA_JNI_ENABLE_ORC=${ARROW_ORC:-OFF} \
-DBUILD_TESTING=${ARROW_JAVA_BUILD_TESTS} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_PREFIX_PATH=${arrow_install_dir} \
-DCMAKE_INSTALL_PREFIX=${prefix_dir} \
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \
-DARROW_JAVA_JNI_ENABLE_DATASET="${ARROW_DATASET:-OFF}" \
-DARROW_JAVA_JNI_ENABLE_GANDIVA="${ARROW_GANDIVA:-OFF}" \
-DARROW_JAVA_JNI_ENABLE_ORC="${ARROW_ORC:-OFF}" \
-DBUILD_TESTING="${ARROW_JAVA_BUILD_TESTS}" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="${arrow_install_dir}" \
-DCMAKE_INSTALL_PREFIX="${prefix_dir}" \
-DCMAKE_UNITY_BUILD="${CMAKE_UNITY_BUILD:-OFF}" \
-DProtobuf_USE_STATIC_LIBS=ON \
-GNinja \
${JAVA_JNI_CMAKE_ARGS:-} \
${arrow_dir}
"${JAVA_JNI_CMAKE_ARGS:-}" \
"${arrow_dir}"
export CMAKE_BUILD_PARALLEL_LEVEL=${n_jobs}
cmake --build . --config ${CMAKE_BUILD_TYPE}
cmake --build . --config "${CMAKE_BUILD_TYPE}"
if [ "${ARROW_JAVA_BUILD_TESTS}" = "ON" ]; then
ctest \
--output-on-failure \
--parallel ${n_jobs} \
--parallel "${n_jobs}" \
--timeout 300
fi
cmake --build . --config ${CMAKE_BUILD_TYPE} --target install
cmake --build . --config "${CMAKE_BUILD_TYPE}" --target install
popd

mkdir -p ${dist_dir}
mkdir -p "${dist_dir}"
# For Windows. *.dll are installed into bin/ on Windows.
if [ -d "${prefix_dir}/bin" ]; then
mv ${prefix_dir}/bin/* ${dist_dir}/
mv "${prefix_dir}"/bin/* "${dist_dir}"/
else
mv ${prefix_dir}/lib/* ${dist_dir}/
mv "${prefix_dir}"/lib/* "${dist_dir}"/
fi
14 changes: 8 additions & 6 deletions ci/scripts/java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ if [[ "${ARROW_JAVA_TEST:-ON}" != "ON" ]]; then
exit
fi

arrow_dir=${1}
source_dir=${1}
build_dir=${2}
java_jni_dist_dir=${3}
Expand All @@ -31,7 +30,7 @@ mvn="mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMave
# Use `2 * ncores` threads
mvn="${mvn} -T 2C"

pushd ${build_dir}
pushd "${build_dir}"

${mvn} -Darrow.test.dataRoot="${source_dir}/testing/data" clean test

Expand All @@ -43,13 +42,16 @@ if [ "${ARROW_JAVA_JNI}" = "ON" ]; then
fi
if [ "${#projects[@]}" -gt 0 ]; then
${mvn} clean test \
-Parrow-jni \
-pl $(IFS=,; echo "${projects[*]}") \
-Darrow.cpp.build.dir=${java_jni_dist_dir}
-Parrow-jni \
-pl "$(
IFS=,
echo \""${projects[*]}"\"
)" \
-Darrow.cpp.build.dir="${java_jni_dist_dir}"
fi

if [ "${ARROW_JAVA_CDATA}" = "ON" ]; then
${mvn} clean test -Parrow-c-data -pl c -Darrow.c.jni.dist.dir=${java_jni_dist_dir}
${mvn} clean test -Parrow-c-data -pl c -Darrow.c.jni.dist.dir="${java_jni_dist_dir}"
fi

popd
Loading