Skip to content

CI: Improve feature checking for binary #192

CI: Improve feature checking for binary

CI: Improve feature checking for binary #192

Workflow file for this run

---
# Note, this is used in the badge URL!
name: build
"on":
push:
branches: [dev, master]
paths-ignore:
- "**.md"
- "docs/**"
- "contrib/**"
- "LICENSE"
- "*.sh"
- "**/Dockerfile*"
- "test.sh"
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
paths-ignore:
- "**.md"
- "docs/**"
- "contrib/**"
- "LICENSE"
- "*.sh"
- "**/Dockerfile*"
- "test.sh"
schedule:
# Run CI every week
- cron: "00 01 * * 0"
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
GSTREAMER_WIN_PATH: D:\gstreamer
NOT_WINDOWS_FEATURES: alsa-backend,pulseaudio-backend,jackaudio-backend,rodiojack-backend,with-avahi,with-dns-sd
jobs:
test:
name: cargo +${{ matrix.toolchain }} test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
toolchain:
- "1.85" # MSRV (Minimum supported rust version)
- stable
isPR:
- ${{ github.event_name == 'pull_request' }}
isCIWindows:
- ${{ github.event.pull_request && contains(github.event.pull_request.labels.*.name, format('CI{0} Windows', ':')) }}
exclude:
# excludes windows in a PR by default, unless labeled with 'CI: Windows'
- os: 'windows-latest'
isPR: true
isCIWindows: false
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install developer package dependencies (Linux)
if: runner.os == 'Linux'
run: >
sudo apt-get update && sudo apt-get install -y
libpulse-dev portaudio19-dev libasound2-dev libsdl2-dev
gstreamer1.0-dev libgstreamer-plugins-base1.0-dev
libavahi-compat-libdnssd-dev
- name: Install developer package dependencies (Windows)
if: runner.os == 'Windows'
run: choco install pkgconfiglite
- name: Cache gstreamer (Windows)
uses: actions/cache@v4
id: cache-gstreamer
if: runner.os == 'Windows'
with:
path: ${{ env.GSTREAMER_WIN_PATH }}
key: gstreamer-Windows-${{ hashFiles('**/Cargo.lock') }}
- name: Install gstreamer (Windows)
if: ${{ runner.os == 'Windows' && !steps.cache-gstreamer.outputs.cache-hit }}
run: choco install gstreamer-devel
- name: Fetch dependencies
run: cargo fetch --locked
- name: Build workspace with examples
run: cargo build --frozen --workspace --examples
- name: Run tests
run: cargo test --workspace
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Check binary with any tls option
run: >
cargo hack check -p librespot --each-feature
--exclude-no-default-features --exclude-all-features
--include-features native-tls,rustls-tls-native-roots,rustls-tls-webpki-roots
- name: Check binary features (cross-platform)
env:
PKG_CONFIG_PATH: ${{ env.GSTREAMER_WIN_PATH }}\1.0\msvc_x86_64\lib\pkgconfig
run: >
cargo hack check -p librespot --each-feature
--exclude-no-default-features --exclude-all-features --features native-tls
--exclude-features rustls-tls-native-roots,rustls-tls-webpki-roots,${{ env.NOT_WINDOWS_FEATURES }}
- name: Check binary features (linux)
if: runner.os == 'Linux'
run: >
cargo hack check -p librespot --each-feature
--exclude-no-default-features --exclude-all-features --features native-tls
--include-features ${{ env.NOT_WINDOWS_FEATURES }}
- name: Build binary with default features
run: cargo build --frozen
- name: Upload debug artifacts
uses: actions/upload-artifact@v4
with:
name: librespot-${{ matrix.os }}-${{ matrix.toolchain }}
path: >
target/debug/librespot${{ runner.os == 'Windows' && '.exe' || '' }}
if-no-files-found: error