Skip to content
Merged
207 changes: 207 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test ${{ matrix.os }} (${{ matrix.arch }}) - LightGBM ${{ matrix.lightgbm_version }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# macOS ARM64 (M1/M2/M3)
- os: macos
arch: arm64
runner: macos-14
lightgbm_version: "4.6.0"
- os: macos
arch: arm64
runner: macos-14
lightgbm_version: "4.5.0"

# macOS x86_64 (Intel)
- os: macos
arch: x86_64
runner: macos-15-large
lightgbm_version: "4.6.0"

# Linux x86_64
- os: linux
arch: x86_64
runner: ubuntu-latest
lightgbm_version: "4.6.0"
- os: linux
arch: x86_64
runner: ubuntu-latest
lightgbm_version: "4.5.0"

- os: linux
arch: arm64
runner: ubuntu-latest
lightgbm_version: "4.6.0"
Comment on lines +47 to +50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Linux ARM64 testing will not work with ubuntu-latest runner.

GitHub's ubuntu-latest runners are x86_64 only. This matrix entry will build for x86_64 architecture despite specifying arch: arm64, providing false confidence that ARM64 Linux builds work.

Options to fix:

  1. Remove the Linux ARM64 entry if ARM64 support isn't ready for CI testing
  2. Set up self-hosted ARM64 runners and reference them here
  3. Add QEMU emulation setup steps before the build
  4. Use a cross-compilation approach with explicit target triple

If you don't have ARM64 runners, apply this diff to remove the misleading entry:

-          - os: linux
-            arch: arm64
-            runner: ubuntu-latest
-            lightgbm_version: "4.6.0"
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- os: linux
arch: arm64
runner: ubuntu-latest
lightgbm_version: "4.6.0"
🤖 Prompt for AI Agents
In .github/workflows/ci.yml around lines 47 to 50 the matrix entry declares os:
linux and arch: arm64 but uses the ubuntu-latest runner (x86_64), which gives a
false ARM64 test; either remove this misleading Linux ARM64 matrix entry if you
do not have ARM64 runners, or replace it by referencing available ARM64 capacity
(point to a self-hosted ARM64 runner), or add QEMU emulation setup steps before
the build, or switch to a cross-compilation flow with an explicit ARM64
target—implement one of those fixes so the matrix no longer claims Linux ARM64
tests that actually run on x86_64.


# Windows x86_64
- os: windows
arch: x86_64
runner: windows-latest
lightgbm_version: "4.6.0"

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-${{ matrix.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-cargo-registry-

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-${{ matrix.arch }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-cargo-index-

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-${{ matrix.arch }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-cargo-build-target-

- name: Install system dependencies (Linux)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev

- name: Install system dependencies (macOS)
if: matrix.os == 'macos'
run: |
brew install libomp

- name: Check build (no features)
env:
LIGHTGBM_VERSION: ${{ matrix.lightgbm_version }}
run: cargo check --verbose

- name: Build (no features)
env:
LIGHTGBM_VERSION: ${{ matrix.lightgbm_version }}
run: cargo build --verbose

- name: Run tests (no features)
env:
LIGHTGBM_VERSION: ${{ matrix.lightgbm_version }}
run: cargo test --verbose

- name: Build examples
env:
LIGHTGBM_VERSION: ${{ matrix.lightgbm_version }}
run: |
cargo build --example basic_usage --verbose
cargo build --example advanced_usage --verbose

- name: Verify library architecture (macOS)
if: matrix.os == 'macos'
run: |
echo "Checking library architecture..."
file target/debug/lib_lightgbm.dylib
lipo -info target/debug/lib_lightgbm.dylib

- name: Verify library architecture (Linux)
if: matrix.os == 'linux'
run: |
echo "Checking library architecture..."
file target/debug/lib_lightgbm.so
readelf -h target/debug/lib_lightgbm.so | grep Machine

- name: Verify library exists (Windows)
if: matrix.os == 'windows'
run: |
echo "Checking library exists..."
Get-Item target/debug/lib_lightgbm.dll

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Run clippy (no features)
run: cargo clippy -- -D warnings

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check formatting
run: cargo fmt -- --check

# Test minimum supported LightGBM version
min-version:
name: Test minimum LightGBM version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Test with LightGBM 4.0.0
env:
LIGHTGBM_VERSION: "4.0.0"
run: |
cargo check --verbose
cargo build --verbose

# Test unsupported platform (should fail gracefully)
# Commented out because it requires manual verification
unsupported-platform:
name: Test Windows ARM64 (unsupported)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Add ARM64 target
run: rustup target add aarch64-pc-windows-msvc

- name: Test unsupported platform detection
continue-on-error: true
run: cargo build --target aarch64-pc-windows-msvc --verbose
id: unsupported_build

- name: Verify build failed with correct error
if: steps.unsupported_build.outcome == 'failure'
run: echo "Build failed as expected for Windows ARM64"
Loading
Loading