name: Build
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
run: choco install openssl -y
shell: pwsh
- name: Set OPENSSL_DIR (Windows)
if: runner.os == 'Windows'
run: |
$paths = @("C:\Program Files\OpenSSL-Win64", "C:\Program Files\OpenSSL")
$found = $null
foreach ($p in $paths) {
if (Test-Path "$p\include") { $found = $p; break }
}
if (-not $found) {
$dirs = Get-ChildItem "C:\Program Files" -Filter "OpenSSL*" -Directory -ErrorAction SilentlyContinue
foreach ($d in $dirs) {
if (Test-Path "$($d.FullName)\include") { $found = $d.FullName; break }
}
}
if (-not $found) { throw "OpenSSL include dir not found. Checked: $($paths -join ', ')" }
"OPENSSL_DIR=$found" >> $env:GITHUB_ENV
$libSubdirs = @("lib\VC\x64\MD", "lib\VC\x64\MDd", "lib\VC\x64\MT", "lib\VC\x64\MTd", "lib")
$libDir = $null
foreach ($sub in $libSubdirs) {
$d = Join-Path $found $sub
if (Test-Path "$d\libcrypto.lib") { $libDir = $d; break }
}
if (-not $libDir) { throw "OpenSSL libcrypto.lib not found under $found" }
"OPENSSL_LIB_DIR=$libDir" >> $env:GITHUB_ENV
shell: pwsh
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test --verbose
msrv:
name: MSRV Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (MSRV)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.93
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock') }}
- name: Check MSRV
run: cargo check --all-targets
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
run: choco install openssl -y
shell: pwsh
- name: Set OPENSSL_DIR (Windows)
if: runner.os == 'Windows'
run: |
$paths = @("C:\Program Files\OpenSSL-Win64", "C:\Program Files\OpenSSL")
$found = $null
foreach ($p in $paths) {
if (Test-Path "$p\include") { $found = $p; break }
}
if (-not $found) {
$dirs = Get-ChildItem "C:\Program Files" -Filter "OpenSSL*" -Directory -ErrorAction SilentlyContinue
foreach ($d in $dirs) {
if (Test-Path "$($d.FullName)\include") { $found = $d.FullName; break }
}
}
if (-not $found) { throw "OpenSSL include dir not found. Checked: $($paths -join ', ')" }
"OPENSSL_DIR=$found" >> $env:GITHUB_ENV
$libSubdirs = @("lib\VC\x64\MD", "lib\VC\x64\MDd", "lib\VC\x64\MT", "lib\VC\x64\MTd", "lib")
$libDir = $null
foreach ($sub in $libSubdirs) {
$d = Join-Path $found $sub
if (Test-Path "$d\libcrypto.lib") { $libDir = $d; break }
}
if (-not $libDir) { throw "OpenSSL libcrypto.lib not found under $found" }
"OPENSSL_LIB_DIR=$libDir" >> $env:GITHUB_ENV
shell: pwsh
- name: Build
run: cargo build --release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ublx-${{ matrix.os }}
path: target/release/ublx*