Skip to content

ci: add Windows runner to test matrix #34

ci: add Windows runner to test matrix

ci: add Windows runner to test matrix #34

Workflow file for this run

name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
lint:
name: fmt + clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install libopenmpt
run: |
sudo apt-get update
sudo apt-get install -y libopenmpt-dev libasound2-dev pkg-config
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: cargo fmt --all -- --check
- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings
test:
name: test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install libopenmpt (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libopenmpt-dev libasound2-dev pkg-config
- name: Install libopenmpt (macOS)
if: runner.os == 'macOS'
run: brew install libopenmpt pkg-config
- name: Install libopenmpt (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# vcpkg is pre-installed on GitHub's Windows runners.
vcpkg install libopenmpt:x64-windows
$root = "$env:VCPKG_INSTALLATION_ROOT/installed/x64-windows"
# openmpt-sys's build.rs emits `-lopenmpt`, so MSVC looks for
# `openmpt.lib`; vcpkg ships it as `libopenmpt.lib`. Alias it.
if ((Test-Path "$root/lib/libopenmpt.lib") -and -not (Test-Path "$root/lib/openmpt.lib")) {
Copy-Item "$root/lib/libopenmpt.lib" "$root/lib/openmpt.lib"
}
# build.rs honours this and skips pkg-config (absent on Windows).
echo "RTRAX_OPENMPT_LIB_DIR=$root/lib" >> $env:GITHUB_ENV
# Put the DLL on PATH so test binaries can load it at runtime.
echo "$root/bin" >> $env:GITHUB_PATH
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- name: cargo build
run: cargo build --all-targets
- name: cargo test
run: cargo test --all-targets