name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
unit-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install xorg-dev
run: |
sudo apt-get install xorg-dev pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Run tests on Linux or macOS
run: |
cargo llvm-cov --color always --lcov --output-path lcov.info
cargo llvm-cov --color always --no-run
if: ${{ matrix.os != 'windows-latest' }}
- name: Run tests on Windows
run: |
cargo llvm-cov --color always --lcov --output-path lcov.info
cargo llvm-cov --color always --no-run
if: ${{ matrix.os == 'windows-latest' }}
- run: cargo test --no-default-features -- --skip .rs
if: ${{ matrix.os != 'windows-latest' }}
- run: cargo test --no-default-features -- --skip .rs
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v4
with:
flags: smart-tests
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt -- --check
- run: cargo clippy --examples --tests -- -D warnings
- run: cargo rustdoc -p ratatui_input -- -D warnings
cargo-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Run `cargo doc` with same configuration as docs.rs
run: |
set -e
md="$(cargo metadata --format-version=1 | jq '.packages[] | select(.name=="ratatui_input") | .metadata.docs.rs')"
export RUSTDOCFLAGS="$(echo "$md" | jq -r '.["rustdoc-args"] | join(" ")') -D warnings"
features="$(echo "$md" | jq -r '.features | join(",")')"
set -x
for target in $(echo "$md" | jq -r '.targets | join(" ")')
do
rustup target add "$target"
cargo doc -p ratatui_input "--features=$features" "--target=$target"
done