Skip to content

Commit

Permalink
build: Add CI for MacOS aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao committed Feb 16, 2024
1 parent 9600e05 commit b0cdf6a
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 7 deletions.
13 changes: 12 additions & 1 deletion .github/actions/setup-builder/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ runs:
shell: bash
run: |
apt-get update
apt-get install -y openjdk-${{inputs.jdk-version}}-jdk protobuf-compiler
apt-get install -y protobuf-compiler
- name: Install JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Set JAVA_HOME
shell: bash
run: echo "JAVA_HOME=$(echo ${JAVA_HOME})" >> $GITHUB_ENV

- name: Setup Rust toolchain
shell: bash
# rustfmt is needed for the substrait build script
Expand Down
62 changes: 62 additions & 0 deletions .github/actions/setup-macos-builder/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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.

name: Prepare Builder for MacOS
description: 'Prepare Build Environment'
inputs:
rust-version:
description: 'version of rust to install (e.g. nightly)'
required: true
default: 'nightly'
jdk-version:
description: 'jdk version to install (e.g., 17)'
required: true
default: '17'
runs:
using: "composite"
steps:
- name: Install Build Dependencies
shell: bash
run: |
# Install protobuf
mkdir -p $HOME/d/protoc
cd $HOME/d/protoc
export PROTO_ZIP="protoc-21.4-osx-aarch_64.zip"
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v21.4/$PROTO_ZIP
unzip $PROTO_ZIP
echo "$HOME/d/protoc/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/d/protoc/bin
- name: Install JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
architecture: 'aarch64'

- name: Set JAVA_HOME
shell: bash
run: echo "JAVA_HOME=$(echo ${JAVA_HOME})" >> $GITHUB_ENV

- name: Setup Rust toolchain
shell: bash
# rustfmt is needed for the substrait build script
run: |
echo "Installing ${{inputs.rust-version}}"
rustup toolchain install ${{inputs.rust-version}}
rustup default ${{inputs.rust-version}}
rustup component add rustfmt clippy
158 changes: 152 additions & 6 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ jobs:
cd core
cargo check --benches
- name: Setup JAVA_HOME
run: |
echo "JAVA_HOME=/usr/lib/jvm/java-${{env.JAVA_VERSION}}-openjdk-amd64" >> $GITHUB_ENV
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -107,9 +103,159 @@ jobs:
cd core
cargo build
- name: Setup JAVA_HOME
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run Maven compile
run: |
./mvnw compile test-compile scalafix:scalafix -Psemanticdb
- name: Run tests
run: |
SPARK_HOME=`pwd` ./mvnw clean install
macos-rust-test:
name: Rust test (macos)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Setup Rust & Java toolchain
uses: ./.github/actions/setup-macos-builder
with:
rust-version: nightly
jdk-version: ${{env.JAVA_VERSION}}

- name: Check cargo fmt
run: |
cd core
cargo fmt --all -- --check --color=never
- name: Check cargo clippy
run: |
cd core
cargo clippy --color=never -- -D warnings
- name: Check compilation
run: |
cd core
cargo check --benches
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build common module (pre-requisite for Rust tests)
run: |
cd common
../mvnw clean compile -DskipTests
- name: Run cargo test
run: |
cd core
# This is required to run some JNI related tests on the Rust side
RUST_BACKTRACE=1 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/lib:$JAVA_HOME/lib/server cargo test
macos-java-test:
name: Java test (macos)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Setup Rust & Java toolchain
uses: ./.github/actions/setup-macos-builder
with:
rust-version: nightly
jdk-version: ${{env.JAVA_VERSION}}

- name: Run cargo build
run: |
cd core
cargo build
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run Maven compile
run: |
echo "JAVA_HOME=/usr/lib/jvm/java-${{env.JAVA_VERSION}}-openjdk-amd64" >> $GITHUB_ENV
./mvnw compile test-compile scalafix:scalafix -Psemanticdb
- name: Run tests
run: |
SPARK_HOME=`pwd` ./mvnw clean install
macos-aarch64-rust-test:
name: Rust test (macos-aarch64)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Setup Rust & Java toolchain
uses: ./.github/actions/setup-macos-builder
with:
rust-version: nightly
jdk-version: ${{env.JAVA_VERSION}}

- name: Check cargo fmt
run: |
cd core
cargo fmt --all -- --check --color=never
- name: Check cargo clippy
run: |
cd core
cargo clippy --color=never -- -D warnings
- name: Check compilation
run: |
cd core
cargo check --benches
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build common module (pre-requisite for Rust tests)
run: |
cd common
../mvnw clean compile -DskipTests
- name: Run cargo test
run: |
cd core
# This is required to run some JNI related tests on the Rust side
RUST_BACKTRACE=1 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/lib:$JAVA_HOME/lib/server cargo test
macos-aarch64-java-test:
name: Java test (macos-aarch64)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Setup Rust & Java toolchain
uses: ./.github/actions/setup-macos-builder
with:
rust-version: nightly
jdk-version: ${{env.JAVA_VERSION}}

- name: Run cargo build
run: |
cd core
cargo build
- name: Cache Maven dependencies
uses: actions/cache@v4
Expand Down

0 comments on commit b0cdf6a

Please sign in to comment.