librespot/.github/workflows/test.yml
yubiuser b85bab5095
Remove .cargo/config.toml and set link compiler on CI with CARGO_TARGET_<triple>_LINKER (#1333)
* Remove .cargo/config.toml and set link compiler on CI with CARGO_TARGET_<triple>_LINKER

* Run windows and cross builds parallel to linux tests

Signed-off-by: yubiuser <github@yubiuser.dev>
2024-09-13 07:40:22 +02:00

260 lines
8.1 KiB
YAML

# Note, this is used in the badge URL!
name: test
on:
push:
branches: [dev, master]
paths:
[
"**.rs",
"Cargo.toml",
"Cargo.lock",
"rustfmt.toml",
".github/workflows/*",
"!*.md",
"!contrib/*",
"!docs/*",
"!LICENSE",
"!*.sh",
]
pull_request:
paths:
[
"**.rs",
"Cargo.toml",
"Cargo.lock",
"rustfmt.toml",
".github/workflows/*",
"!*.md",
"!contrib/*",
"!docs/*",
"!LICENSE",
"!*.sh",
]
schedule:
# Run CI every week
- cron: "00 01 * * 0"
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings -A renamed-and-removed-lints
# The layering here is as follows:
# 1. code formatting
# 2. absence of lints
# 3. absence of errors and warnings on Linux/x86
# 4. cross compilation on Windows and Linux/ARM
jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
- name: Install toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile default --default-toolchain stable -y
- run: cargo fmt --all -- --check
clippy:
needs: fmt
name: cargo +${{ matrix.toolchain }} clippy (${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
toolchain: [stable]
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
- name: Install toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile default --default-toolchain ${{ matrix.toolchain }} -y
- name: Get Rustc version
id: get-rustc-version
run: echo "version=$(rustc -V)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Rust dependencies
uses: actions/cache@v4.0.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: ${{ runner.os }}-${{ steps.get-rustc-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: Install developer package dependencies
run: sudo apt-get update && sudo apt install -y libunwind-dev && sudo apt-get install libpulse-dev portaudio19-dev libasound2-dev libsdl2-dev gstreamer1.0-dev libgstreamer-plugins-base1.0-dev libavahi-compat-libdnssd-dev
- run: cargo install cargo-hack
- run: cargo hack --workspace --remove-dev-deps
- run: cargo clippy -p librespot-core --no-default-features
- run: cargo clippy -p librespot-core
- run: cargo hack clippy --each-feature -p librespot-discovery
- run: cargo hack clippy --each-feature -p librespot-playback
- run: cargo hack clippy --each-feature
test-linux:
name: cargo +${{ matrix.toolchain }} check (${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
needs: clippy
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
toolchain:
- "1.74" # MSRV (Minimum supported rust version)
- stable
experimental: [false]
# Ignore failures in beta
include:
- os: ubuntu-latest
toolchain: beta
experimental: true
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
- name: Install toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain ${{ matrix.toolchain }} -y
- name: Get Rustc version
id: get-rustc-version
run: echo "version=$(rustc -V)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Rust dependencies
uses: actions/cache@v4.0.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: ${{ runner.os }}-${{ steps.get-rustc-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: Install developer package dependencies
run: sudo apt-get update && sudo apt install -y libunwind-dev && sudo apt-get install libpulse-dev portaudio19-dev libasound2-dev libsdl2-dev gstreamer1.0-dev libgstreamer-plugins-base1.0-dev libavahi-compat-libdnssd-dev
- run: cargo build --workspace --examples
- run: cargo test --workspace
- run: cargo install cargo-hack
- run: cargo hack --workspace --remove-dev-deps
- run: cargo check -p librespot-core --no-default-features
- run: cargo check -p librespot-core
- run: cargo hack check --each-feature -p librespot-discovery
- run: cargo hack check --each-feature -p librespot-playback
- run: cargo hack check --each-feature
test-windows:
needs: clippy
name: cargo +${{ matrix.toolchain }} check (${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [windows-latest]
toolchain:
- "1.74" # MSRV (Minimum supported rust version)
- stable
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
# hyper-rustls >=0.27 uses aws-lc as default backend which requires NASM to build
- name: Install NASM
uses: ilammy/setup-nasm@v1.5.1
- name: Install toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain ${{ matrix.toolchain }} -y
- name: Get Rustc version
id: get-rustc-version
run: echo "version=$(rustc -V)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Rust dependencies
uses: actions/cache@v4.0.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: ${{ runner.os }}-${{ steps.get-rustc-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- run: cargo build --workspace --examples
- run: cargo test --workspace
- run: cargo install cargo-hack
- run: cargo hack --workspace --remove-dev-deps
- run: cargo check --no-default-features
- run: cargo check
test-cross-arm:
name: cross +${{ matrix.toolchain }} build ${{ matrix.target }}
needs: clippy
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
target: [armv7-unknown-linux-gnueabihf]
toolchain:
- "1.74" # MSRV (Minimum supported rust version)
- stable
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
- name: Install toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain ${{ matrix.toolchain }} -y
- name: Get Rustc version
id: get-rustc-version
run: echo "version=$(rustc -V)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Rust dependencies
uses: actions/cache@v4.0.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-${{ steps.get-rustc-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- name: Install the cross compiler rust targets
run: rustup target add ${{ matrix.target }}
- name: Install cross compiler
run: |
if [ ${{ matrix.target }} = "armv7-unknown-linux-gnueabihf" ]; then
sudo apt-get install -y gcc-arm-linux-gnueabihf
fi
- name: Set target link compiler
run: |
# Convert target to uppercase and replace - with _
target=${{ matrix.target }}
target=${target^^}
target=${target//-/_}
if [ ${{ matrix.target }} = "armv7-unknown-linux-gnueabihf" ]; then
echo "CARGO_TARGET_${target}_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
fi
- name: Build
run: cargo build --verbose --target ${{ matrix.target }} --no-default-features
- name: Check binary
run: file target/${{ matrix.target }}/debug/librespot