name: Rust CI
on:
push:
branches: [master]
paths:
- "**/*.rs"
- "**/Cargo.toml"
- Cargo.lock
- .github/workflows/rust.yml
pull_request:
branches: [master]
paths:
- "**/*.rs"
- "**/Cargo.toml"
- Cargo.lock
- .github/workflows/rust.yml
permissions: {}
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Rust
run: rustup update stable --no-self-update
- name: Cache cargo deps
uses: actions/cache@v5
continue-on-error: true
with:
path: |-
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-linting-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy
run: cargo clippy --no-deps --all-features -- -D warnings
- name: Run rustfmt
run: cargo fmt --all --check
- name: Pre-publish (dry run)
if: runner.os == 'linux'
run: cargo publish -p iced_term --dry-run
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Rust
run: rustup update stable --no-self-update
- name: Cache cargo deps
uses: actions/cache@v5
continue-on-error: true
with:
path: |-
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-testing-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --all-features --lib --verbose
examples:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
example:
- custom_bindings
- fonts
- full_screen
- split_view
- themes
- focus
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Rust
run: rustup update stable --no-self-update
- name: Cache cargo deps
uses: actions/cache@v5
continue-on-error: true
with:
path: |-
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-example-${{ matrix.example }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- name: Build examples
env:
EXAMPLE: ${{ matrix.example }}
shell: bash
run: cargo build -p ${EXAMPLE}
- name: Upload example build artifact
uses: actions/upload-artifact@v7
with:
name: example-${{ matrix.example }}-${{ matrix.os }}
path: target/debug/${{ matrix.example }}${{ runner.os == 'Windows' && '.exe' || '' }}