| # 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: Rust |
| |
| on: |
| pull_request: |
| branches: |
| - main |
| paths: |
| - "c/**" |
| - "ci/rust-nightly/**" |
| - "rust/**" |
| - ".github/workflows/rust.yml" |
| push: |
| branches-ignore: |
| - 'dependabot/**' |
| paths: |
| - "c/**" |
| - "ci/rust-nightly/**" |
| - "rust/**" |
| - ".github/workflows/rust.yml" |
| |
| concurrency: |
| group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }}-rust |
| cancel-in-progress: true |
| |
| permissions: |
| contents: read |
| |
| defaults: |
| run: |
| shell: bash -l -eo pipefail {0} |
| |
| jobs: |
| rust: |
| strategy: |
| matrix: |
| # See: https://github.com/apache/arrow-adbc/pull/1803#issuecomment-2117669300 |
| os: |
| - macos-15-intel |
| - macos-latest |
| - ubuntu-latest |
| - windows-latest |
| minimal-versions: |
| - false |
| include: |
| - os: ubuntu-latest |
| minimal-versions: true # Test can be built with older arrow |
| - os: windows-latest |
| minimal-versions: true # Test can be built with older windows specific deps |
| name: Rust ${{ matrix.os }} ${{ matrix.minimal-versions && '(minimal versions for adbc_core)' || '' }} |
| runs-on: ${{ matrix.os }} |
| env: |
| CARGO_INCREMENTAL: 0 |
| RUSTFLAGS: "-Adead_code" # TODO(alexandreyc): remove this line when implementation is complete |
| steps: |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| with: |
| fetch-depth: 0 |
| persist-credentials: false |
| - name: Cargo update for minimal versions |
| if: ${{ matrix.minimal-versions }} |
| working-directory: ci/rust-nightly |
| run: | |
| CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo generate-lockfile \ |
| --manifest-path "${GITHUB_WORKSPACE}/rust/Cargo.toml" \ |
| -Z direct-minimal-versions |
| - name: Use stable Rust |
| id: rust |
| run: | |
| rustup toolchain install stable --no-self-update |
| rustup default stable |
| - name: Get required Go version |
| run: | |
| (. ./.env && echo "GO_VERSION=${GO}") >> $GITHUB_ENV |
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| with: |
| go-version: "${{ env.GO_VERSION }}" |
| check-latest: true |
| cache: true |
| cache-dependency-path: go/adbc/go.sum |
| - name: Install Protoc |
| if: runner.os == 'Linux' |
| run: | |
| curl -L "https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-$(uname -m).zip" -o protoc.zip |
| unzip protoc.zip -d $HOME/.local |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| - name: Install Protoc |
| if: runner.os == 'macOS' |
| run: | |
| curl -L "https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-osx-universal_binary.zip" -o protoc.zip |
| unzip "protoc.zip" -d $HOME/.local |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| - name: Install Protoc |
| if: runner.os == 'Windows' |
| run: | |
| curl -L "https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-win64.zip" -o protoc.zip |
| unzip "protoc.zip" -d $HOME/.local |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| - name: Install sqlite3 |
| if: runner.os == 'Linux' |
| run: sudo apt-get install libsqlite3-dev |
| - name: Setup conda |
| uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1 |
| if: runner.os == 'Windows' |
| with: |
| miniforge-version: latest |
| - name: Install Dependencies |
| if: runner.os == 'Windows' |
| run: | |
| conda install -c conda-forge --file ci/conda_env_cpp.txt |
| - name: Build C++/Go drivers |
| run: | |
| mkdir -p build |
| mkdir -p local |
| pushd build |
| cmake \ |
| -DADBC_BUILD_TESTS=OFF \ |
| -DADBC_DRIVER_FLIGHTSQL=ON \ |
| -DADBC_DRIVER_MANAGER=ON \ |
| -DADBC_DRIVER_SQLITE=ON \ |
| -DADBC_USE_ASAN=OFF \ |
| -DADBC_USE_UBSAN=OFF \ |
| -DADBC_SQLITE_COMPILE_DEFINES=-DADBC_SQLITE_WITH_NO_LOAD_EXTENSION \ |
| -DCMAKE_BUILD_TYPE=Release \ |
| -DCMAKE_INSTALL_PREFIX=../local \ |
| ../c |
| cmake --build . --target install |
| popd |
| - name: Set dynamic linker path |
| if: runner.os == 'Linux' |
| run: | |
| echo "LD_LIBRARY_PATH=${{ github.workspace }}/local/lib:$LD_LIBRARY_PATH" >> "$GITHUB_ENV" |
| echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.so" >> "$GITHUB_ENV" |
| - name: Set dynamic linker path |
| if: matrix.os == 'macos-latest' |
| run: | |
| echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/sqlite/lib:${{ github.workspace }}/local/lib:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV" |
| echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.dylib" >> "$GITHUB_ENV" |
| - name: Set dynamic linker path |
| if: matrix.os == 'macos-15-intel' |
| run: | |
| echo "DYLD_LIBRARY_PATH=/usr/local/opt/sqlite/lib:${{ github.workspace }}/local/lib:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV" |
| echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.dylib" >> "$GITHUB_ENV" |
| - name: Set dynamic linker path |
| if: runner.os == 'Windows' |
| run: | |
| echo "PATH=${{ github.workspace }}/local/bin;${{ github.workspace }}/local/lib;$PATH" >> "$GITHUB_ENV" |
| echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/bin/adbc_driver_sqlite.dll" >> "$GITHUB_ENV" |
| - name: Clippy |
| if: runner.os != 'Linux' && ! matrix.minimal-versions |
| working-directory: rust |
| run: | |
| rustup component add clippy |
| cargo clippy --workspace --all-targets --all-features --locked -- -Dwarnings |
| - name: Clippy (nightly) |
| if: runner.os == 'Linux' && ! matrix.minimal-versions |
| working-directory: ci/rust-nightly |
| run: | |
| # -Zcrate-attr enables the unstable non_exhaustive_omitted_patterns lint |
| # (https://github.com/apache/arrow-adbc/pull/3245). |
| # It applies to all workspace packages, so we also allow unused_features for crates that |
| # don't use the lint. |
| cargo clippy --manifest-path "${GITHUB_WORKSPACE}/rust/Cargo.toml" \ |
| --workspace --all-targets --all-features --locked -- -Dwarnings \ |
| -Zcrate-attr='feature(non_exhaustive_omitted_patterns_lint)' \ |
| -Zcrate-attr='allow(unused_features)' |
| - name: Test (Default Features) |
| env: |
| RUST_BACKTRACE: "1" |
| working-directory: rust |
| run: > |
| cargo test --all-targets --workspace |
| - name: Test (All Features) |
| env: |
| RUST_BACKTRACE: "1" |
| working-directory: rust |
| run: > |
| cargo test --all-targets --all-features --workspace |
| - name: Doctests |
| env: |
| RUST_BACKTRACE: "1" |
| working-directory: rust |
| run: > |
| cargo test --doc --all-features --workspace |
| - name: Check docs |
| working-directory: rust |
| run: > |
| cargo doc --all-features --workspace |
| - name: Install cargo-msrv |
| if: matrix.os == 'ubuntu-latest' |
| run: | |
| # Install cargo-msrv |
| cargo_msrv_version="v0.18.4" |
| cargo_msrv_hash="367a48e4ad014b119bf728a9e95e863575e02fdf6cf95ae24f44ca73b445ee14" |
| cargo_msrv_archive="cargo-msrv.tgz" |
| |
| curl -L "https://github.com/foresterre/cargo-msrv/releases/download/${cargo_msrv_version}/cargo-msrv-x86_64-unknown-linux-gnu-${cargo_msrv_version}.tgz" -o "${cargo_msrv_archive}" |
| echo "${cargo_msrv_hash} ${cargo_msrv_archive}" | sha256sum -c - |
| tar xz -f "${cargo_msrv_archive}" --wildcards --strip-components=1 -C "$HOME/.local/bin" "*/cargo-msrv" |
| rm "${cargo_msrv_archive}" |
| |
| - name: Verify MSRV (Minimum Supported Rust Version) |
| if: matrix.os == 'ubuntu-latest' && matrix.minimal-versions |
| working-directory: rust |
| run: | |
| find . -mindepth 2 -name Cargo.toml | while read -r dir |
| do |
| echo "Checking package '$dir'" |
| cargo msrv verify --manifest-path "$dir" || exit 1 |
| done |