Skip to content

cargo fmt

cargo fmt #679

Workflow file for this run

name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
extra_flags: [""]
include:
- os: ubuntu
extra_flags: --target=i686-unknown-linux-gnu
# disable SRT interop tests on windows
env:
SRT_ALLOW_NO_INTEROP_TESTS: matrix.os == "windows" && 1 || null
RUST_LOG: info
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v1
- name: install target
run: rustup target add i686-unknown-linux-gnu && sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install g++-multilib gcc-multilib srt-tools:i386
if: matrix.extra_flags != ''
- name: install srt+gtest (linux)
run: sudo apt-get install srt-tools libgtest-dev
if: matrix.os == 'ubuntu'
- name: install srt (macos)
run: |
brew update && brew install srt
export LIBSRT_PATH="$(brew --prefix srt)/lib/libsrt.dylib"
if: matrix.os == 'macos'
- name: Build
run: cargo build ${{ matrix.extra_flags }} --tests --examples --verbose
- name: Run tests
run: cargo test ${{ matrix.extra_flags }} --verbose
- name: Run C++ unit tests (linux only)
run: cd srt-c-unittests && cargo test
if: matrix.os == 'ubuntu'
clippy:
runs-on: ubuntu-latest
steps:
- name: install ffmpeg
run: sudo apt update && sudo apt-get install libavformat-dev libswscale-dev
- uses: actions/checkout@v2
- name: Cargo clippy
run: cargo clippy --tests --examples --features ac-ffmpeg -- -D clippy::all
- name: Check if C++ examples compile
run: make -C srt-c
c_header_updated:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: download cbindgen
run: wget https://github.com/eqrion/cbindgen/releases/download/v0.24.3/cbindgen && chmod +x ./cbindgen
- name: generate SRT header
run: ./cbindgen --config srt-c/cbindgen.toml --crate srt-c --output srt-c/srtrs_new.h
- name: Check up to date
run: diff srt-c/srtrs.h srt-c/srtrs_new.h
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check formatting
run: cargo fmt -- --check
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: Swatinem/rust-cache@v1
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview
- name: install srt
run: sudo apt-get install srt-tools libgtest-dev
- name: Download grcov
run: wget https://github.com/mozilla/grcov/releases/download/v0.8.13/grcov-x86_64-unknown-linux-gnu.tar.bz2 -O grcov.tar.bz2 && tar -xf grcov.tar.bz2
- name: Build with profdata
run: RUSTFLAGS="-C instrument-coverage" cargo test --no-run --features=log_disable
- name: Generate reports
run: RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="srt.%p.profraw" cargo test --features=log_disable
- name: Generate reports from C++ unit tests
run: cd srt-c-unittests && RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="srt.%p.profraw" cargo run
- name: Delete invalid profdata files
run: set -x; for p in $(find . -name "*.profraw"); do $(find $(rustc --print sysroot) -name llvm-profdata) show $p > /dev/null || rm $p; done
- name: Run grcov
run: ./grcov . --llvm --binary-path ./target/debug/ -t lcov -s . --ignore '*/examples/*' --ignore '*/tests/*' -o lcov.info
- name: Upload results
run: bash <(curl -s https://codecov.io/bash) -f lcov.info