add impl example for read_options #507
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust Build and Test | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
- '[0-9]+.[0-9]+' | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
lint: | |
name: Lint ${{ matrix.features.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
features: | |
- name: all features | |
value: --all-features --manifest-path binrw/Cargo.toml | |
check_formatting: True | |
- name: no_std | |
value: --no-default-features --manifest-path binrw/Cargo.toml | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: clippy, rustfmt | |
- name: Check formatting | |
# There is no reason to check formatting more than once since it is | |
# a syntax check that does not change depending upon compiler features | |
if: matrix.features.check_formatting | |
run: cargo fmt -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets ${{ matrix.features.value }} -- -D warnings | |
- name: Build documentation | |
run: cargo rustdoc ${{ matrix.features.value }} -- -D warnings | |
test: | |
name: Test ${{ matrix.features.name }} on Rust ${{ matrix.rust }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust: | |
- stable | |
- nightly | |
- 1.66 # rust-version, msrv | |
features: | |
- name: all features | |
value: --all-features | |
- name: no_std | |
value: --no-default-features --manifest-path binrw/Cargo.toml | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Build workspace | |
run: cargo build ${{ matrix.features.value }} | |
# Testing is separated just to more clearly differentiate in the CI | |
# whether the build failed or a test failed | |
- name: Run tests | |
run: cargo test ${{ matrix.features.value }} | |
coverage: | |
name: Code coverage | |
runs-on: ubuntu-latest | |
env: | |
RUST_BACKTRACE: 1 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: llvm-tools-preview | |
- name: Install llvm-cov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-llvm-cov | |
- name: Generate default features | |
run: > | |
cargo llvm-cov --doctests | |
--no-report | |
- name: Generate all features | |
run: > | |
cargo llvm-cov --doctests --all-features | |
--no-report | |
- name: Generate no features | |
run: > | |
cargo llvm-cov --doctests --no-default-features | |
--no-report | |
- name: Show coverage results | |
run: > | |
cargo llvm-cov --doctests | |
--ignore-filename-regex 'binrw/(tests|src/docs)' | |
--no-run | |
# https://github.com/actions/runner/issues/520 | |
- name: Determine whether codecov.io secret is available | |
id: has_codecov | |
run: echo 'result=${{ secrets.CODECOV_TOKEN }}' >> $GITHUB_OUTPUT | |
- name: Generate coverage file | |
run: > | |
cargo llvm-cov --doctests | |
--ignore-filename-regex 'binrw/(tests|src/docs)' | |
--no-run | |
--lcov --output-path lcov.info | |
if: steps.has_codecov.outputs.result != 0 | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v1 | |
with: | |
files: lcov.info | |
token: ${{ secrets.CODECOV_TOKEN }} | |
if: steps.has_codecov.outputs.result != 0 |