Skip to content

Commit 2681868

Browse files
Upgrade Java JAR build workflow with modern improvements
- Update GitHub Actions to v4+ with SHA pinning - Add ARM64 support for Ubuntu and macOS - Use vcpkg for LLVM to remove z3 runtime dependency - Add disk space cleanup for macOS runners - Add disk space monitoring throughout build - Enhance testing for ARM64 libraries Ref: DX-103340
1 parent 011d73e commit 2681868

1 file changed

Lines changed: 139 additions & 37 deletions

File tree

dev/tasks/java-jars/github.yml

Lines changed: 139 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ jobs:
3030
ARCH: {{ '${{ matrix.platform.archery_arch }}' }}
3131
ARCH_ALIAS: {{ '${{ matrix.platform.archery_arch_alias }}' }}
3232
ARCH_SHORT: {{ '${{ matrix.platform.archery_arch_short }}' }}
33+
ARCHERY_USE_DOCKER_CLI: {{ "${{matrix.platform.archery_use_docker_cli || '1'}}" }}
3334
strategy:
3435
fail-fast: false
3536
matrix:
3637
platform:
37-
- runs_on: ["ubuntu-latest"]
38+
- runs_on: ubuntu-latest
3839
arch: "x86_64"
3940
archery_arch: "amd64"
4041
archery_arch_alias: "x86_64"
4142
archery_arch_short: "amd64"
42-
- runs_on: ["buildjet-8vcpu-ubuntu-2204-arm"]
43+
- runs_on: ubuntu-24.04-arm
4344
arch: "aarch_64"
4445
archery_arch: "arm64v8"
4546
archery_arch_alias: "aarch64"
@@ -72,7 +73,7 @@ jobs:
7273
- name: Compress into single artifact to keep directory structure
7374
run: tar -cvzf arrow-shared-libs-linux-{{ arch }}.tar.gz arrow/java-dist/
7475
- name: Upload artifacts
75-
uses: actions/upload-artifact@v4
76+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
7677
with:
7778
name: ubuntu-shared-lib-{{ arch }}
7879
path: arrow-shared-libs-linux-{{ arch }}.tar.gz
@@ -91,113 +92,201 @@ jobs:
9192
fail-fast: false
9293
matrix:
9394
platform:
94-
- { runs_on: ["macos-15-intel"], arch: "x86_64"}
95+
- { runs_on: macos-15, arch: "aarch_64" }
9596
env:
96-
MACOSX_DEPLOYMENT_TARGET: "12.0"
97+
MACOSX_DEPLOYMENT_TARGET: "15.0"
9798
steps:
9899
{{ macros.github_checkout_arrow()|indent }}
99100
- name: Set up Python
100-
uses: actions/setup-python@v4
101+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
101102
with:
102103
cache: 'pip'
103104
python-version: 3.12
104105
- name: Install Archery
105106
shell: bash
106107
run: pip install -e arrow/dev/archery[all]
108+
- name: Checkout vcpkg
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
repository: Microsoft/vcpkg
112+
path: arrow/vcpkg
113+
fetch-depth: 0
114+
- name: Install vcpkg
115+
run: |
116+
cd arrow/vcpkg
117+
./bootstrap-vcpkg.sh
118+
echo "VCPKG_ROOT_LOCAL=${PWD}" >> ${GITHUB_ENV}
119+
echo "${PWD}" >> ${GITHUB_PATH}
120+
- name: Clean up disk space
121+
run: |
122+
echo "=== Free disk space before cleanup ==="
123+
df -h /
124+
125+
echo ""
126+
echo "=== Removing Xcode simulators ==="
127+
sudo rm -rf /Library/Developer/CoreSimulator/Caches || :
128+
echo "Removed /Library/Developer/CoreSimulator/Caches"
129+
130+
echo ""
131+
echo "=== Removing user simulator data ==="
132+
rm -rf ~/Library/Developer/CoreSimulator || :
133+
echo "Removed ~/Library/Developer/CoreSimulator"
134+
135+
echo ""
136+
echo "=== Free disk space after cleanup ==="
137+
df -h /
107138
- name: Install dependencies
108139
run: |
109-
# We want to use llvm@14 to avoid shared z3
110-
# dependency. llvm@14 doesn't depend on z3 and llvm depends
111-
# on z3. And Homebrew's z3 provides only shared library. It
112-
# doesn't provides static z3 because z3's CMake doesn't accept
113-
# building both shared and static libraries at once.
114-
# See also: Z3_BUILD_LIBZ3_SHARED in
115-
# https://github.com/Z3Prover/z3/blob/master/README-CMake.md
116-
#
117-
# If llvm is installed, Apache Arrow C++ uses llvm rather than
118-
# llvm@14 because llvm is newer than llvm@14.
119-
brew uninstall llvm || :
140+
echo "=== Free disk space at start of dependency installation ==="
141+
df -h /
120142
143+
echo ""
121144
# Ensure updating python@XXX with the "--overwrite" option.
122145
# If python@XXX is updated without "--overwrite", it causes
123146
# a conflict error. Because Python 3 installed not by
124147
# Homebrew exists in /usr/local on GitHub Actions. If
125148
# Homebrew's python@XXX is updated without "--overwrite", it
126149
# tries to replace /usr/local/bin/2to3 and so on and causes
127150
# a conflict error.
128-
# brew update
151+
brew update
129152
for python_package in $(brew list | grep python@); do
130153
brew install --overwrite ${python_package}
131154
done
132155
brew install --overwrite python
133156
157+
if [ "$(uname -m)" = "arm64" ]; then
158+
# pkg-config formula is deprecated but it's still installed
159+
# in GitHub Actions runner now. We can remove this once
160+
# pkg-config formula is removed from GitHub Actions runner.
161+
brew uninstall pkg-config || :
162+
fi
163+
164+
# Install basic build tools via brew (vcpkg needs these)
165+
brew install cmake ninja pkg-config
134166
brew bundle --file=arrow/cpp/Brewfile
167+
168+
# Clean up any existing LLVM installations in favor of vcpkg.
169+
# Need to uninstall all versioned LLVM packages (llvm@18, llvm@17, etc.)
170+
for llvm_pkg in $(brew list | grep -E '^llvm(@[0-9]+)?$'); do
171+
brew uninstall "${llvm_pkg}" || :
172+
done
173+
135174
# We want to link aws-sdk-cpp statically but Homebrew's
136175
# aws-sdk-cpp provides only shared library. If we have
137176
# Homebrew's aws-sdk-cpp, our build mix Homebrew's
138177
# aws-sdk-cpp and bundled aws-sdk-cpp. We uninstall Homebrew's
139178
# aws-sdk-cpp to ensure using only bundled aws-sdk-cpp.
140-
brew uninstall aws-sdk-cpp
179+
brew uninstall aws-sdk-cpp || :
141180
# We want to use bundled RE2 for static linking. If
142181
# Homebrew's RE2 is installed, its header file may be used.
143182
# We uninstall Homebrew's RE2 to ensure using bundled RE2.
144183
brew uninstall grpc || : # gRPC depends on RE2
145-
brew uninstall re2
184+
brew uninstall re2 || :
146185
# We want to use bundled Protobuf for static linking. If
147186
# Homebrew's Protobuf is installed, its library file may be
148187
# used on test We uninstall Homebrew's Protobuf to ensure using
149188
# bundled Protobuf.
150-
brew uninstall protobuf
151-
# fix cmake and boost versionsAdd commentMore actions
152-
brew uninstall -f boost || true
153-
brew uninstall -f cmake || true
154-
mkdir -p homebrew-custom/Formula
155-
curl -o homebrew-custom/Formula/cmake.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/f68532bfe5cb87474093df8a839c3818c6aa44dd/Formula/c/cmake.rb
156-
curl -o homebrew-custom/Formula/boost.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/23f9c56c5075dd56b4471e2c93f89f6400b49ddd/Formula/b/boost.rb
157-
brew tap-new local/homebrew-custom
158-
cp ./homebrew-custom/Formula/*.rb "$(brew --repo local/homebrew-custom)/Formula/"
159-
brew install -v local/homebrew-custom/cmake
160-
brew install -v local/homebrew-custom/boost
161-
brew pin cmake
162-
brew pin boost
163-
#
189+
brew uninstall protobuf || :
190+
191+
echo ""
192+
echo "=== Free disk space before LLVM build ==="
193+
df -h /
194+
195+
echo ""
196+
# Use vcpkg to install LLVM.
197+
# Create overlay directory if it doesn't exist
198+
mkdir -p arrow/ci/vcpkg/overlay/llvm
199+
vcpkg install \
200+
--clean-after-build \
201+
--vcpkg-root=${VCPKG_ROOT_LOCAL} \
202+
--x-install-root=${VCPKG_ROOT_LOCAL}/installed \
203+
--x-manifest-root=arrow/ci/vcpkg \
204+
--overlay-ports=arrow/ci/vcpkg/overlay/llvm/ \
205+
--x-feature=gandiva
164206
207+
echo ""
208+
echo "=== Free disk space after LLVM build ==="
209+
df -h /
165210
211+
echo ""
166212
brew bundle --file=arrow/java/Brewfile
167213
- name: Build C++ libraries
168214
env:
169215
ARROW_USE_CCACHE: "ON"
170216
run: |
171217
set -e
218+
echo "=== Free disk space at start of build ==="
219+
df -h /
220+
221+
echo ""
172222
# make brew Java available to CMake
173223
export JAVA_HOME=$(brew --prefix openjdk@11)/libexec/openjdk.jdk/Contents/Home
174224
arrow/ci/scripts/java_jni_macos_build.sh \
175225
$GITHUB_WORKSPACE/arrow \
176226
$GITHUB_WORKSPACE/arrow/cpp-build \
177227
$GITHUB_WORKSPACE/arrow/java-dist
228+
229+
echo ""
230+
echo "=== Free disk space at end of build ==="
231+
df -h /
178232
- name: Compress into single artifact to keep directory structure
179233
run: tar -cvzf arrow-shared-libs-macos-{{ arch }}.tar.gz arrow/java-dist/
180234
- name: Upload artifacts
181-
uses: actions/upload-artifact@v4
235+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
182236
with:
183237
name: macos-shared-lib-{{ arch }}
184238
path: arrow-shared-libs-macos-{{ arch }}.tar.gz
185239

240+
build-cpp-windows:
241+
name: Build C++ libraries Windows
242+
runs-on: windows-2019
243+
steps:
244+
{{ macros.github_checkout_arrow()|indent }}
245+
- name: Set up Java
246+
uses: actions/setup-java@v4
247+
with:
248+
java-version: '11'
249+
distribution: 'temurin'
250+
- name: Download Timezone Database
251+
shell: bash
252+
run: arrow/ci/scripts/download_tz_database.sh
253+
- name: Install sccache
254+
shell: bash
255+
run: arrow/ci/scripts/install_sccache.sh pc-windows-msvc $(pwd)/sccache
256+
- name: Build C++ libraries
257+
shell: cmd
258+
env:
259+
{{ macros.github_set_sccache_envvars()|indent(8) }}
260+
run: |
261+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
262+
REM For ORC
263+
set TZDIR=/c/msys64/usr/share/zoneinfo
264+
bash -c "arrow/ci/scripts/java_jni_windows_build.sh $(pwd)/arrow $(pwd)/arrow/cpp-build $(pwd)/arrow/java-dist"
265+
- name: Compress into single artifact to keep directory structure
266+
shell: bash
267+
run: tar -cvzf arrow-shared-libs-windows.tar.gz arrow/java-dist/
268+
- name: Upload artifacts
269+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
270+
with:
271+
name: windows-shared-lib
272+
path: arrow-shared-libs-windows.tar.gz
273+
186274
package-jars:
187275
name: Build jar files
188276
runs-on: {{ '${{ matrix.platform.runs_on }}' }}
189277
strategy:
190278
fail-fast: false
191279
matrix:
192280
platform:
193-
- { runs_on: ["macos-15-intel"], arch: "x86_64"}
281+
- { runs_on: macos-13, arch: "x86_64"}
194282
needs:
195283
- build-cpp-ubuntu
196284
- build-cpp-macos
285+
- build-cpp-windows
197286
steps:
198287
{{ macros.github_checkout_arrow(fetch_depth=0)|indent }}
199288
- name: Download Libraries
200-
uses: actions/download-artifact@v4
289+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
201290
with:
202291
path: artifacts
203292
- name: Decompress artifacts
@@ -206,6 +295,8 @@ jobs:
206295
tar -xvzf arrow-shared-libs-linux-x86_64.tar.gz
207296
tar -xvzf arrow-shared-libs-linux-aarch_64.tar.gz
208297
tar -xvzf arrow-shared-libs-macos-x86_64.tar.gz
298+
tar -xvzf arrow-shared-libs-macos-aarch_64.tar.gz
299+
tar -xvzf arrow-shared-libs-windows.tar.gz
209300
- name: Test that shared libraries exist
210301
run: |
211302
set -x
@@ -224,6 +315,15 @@ jobs:
224315
test -f arrow/java-dist/arrow_dataset_jni/x86_64/libarrow_dataset_jni.dylib
225316
test -f arrow/java-dist/arrow_orc_jni/x86_64/libarrow_orc_jni.dylib
226317
test -f arrow/java-dist/gandiva_jni/x86_64/libgandiva_jni.dylib
318+
319+
test -f arrow/java-dist/arrow_cdata_jni/aarch_64/libarrow_cdata_jni.dylib
320+
test -f arrow/java-dist/arrow_dataset_jni/aarch_64/libarrow_dataset_jni.dylib
321+
test -f arrow/java-dist/arrow_orc_jni/aarch_64/libarrow_orc_jni.dylib
322+
test -f arrow/java-dist/gandiva_jni/aarch_64/libgandiva_jni.dylib
323+
324+
test -f arrow/java-dist/arrow_cdata_jni/x86_64/arrow_cdata_jni.dll
325+
test -f arrow/java-dist/arrow_dataset_jni/x86_64/arrow_dataset_jni.dll
326+
test -f arrow/java-dist/arrow_orc_jni/x86_64/arrow_orc_jni.dll
227327
- name: Build bundled jar
228328
env:
229329
MAVEN_ARGS: >-
@@ -233,6 +333,7 @@ jobs:
233333
pushd arrow/java
234334
mvn versions:set -DnewVersion={{ arrow.no_rc_snapshot_version }}
235335
mvn versions:set -DnewVersion={{ arrow.no_rc_snapshot_version }} -f bom
336+
mvn versions:set -DnewVersion={{ arrow.no_rc_snapshot_version }} -f maven
236337
popd
237338
arrow/ci/scripts/java_full_build.sh \
238339
$GITHUB_WORKSPACE/arrow \
@@ -242,3 +343,4 @@ jobs:
242343
"arrow/java-dist/*.pom",
243344
"arrow/java-dist/*.xml",
244345
"arrow/java-dist/*.zip"])|indent }}
346+

0 commit comments

Comments
 (0)