Fix lint warnings #2
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: build | |
# This action works with pull requests and pushes | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
MSRV: 1.66.0 | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
profile: minimal | |
components: rustfmt, clippy | |
- name: Cache cargo files | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
./target | |
./test-target | |
key: ${{ runner.os }}-cargo-files-stable-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-files-stable | |
- name: Build | |
run: cargo build --all-features | |
- name: Check format | |
run: cargo fmt --check | |
- name: Check lint | |
run: cargo clippy --workspace --all-features -- -D warnings | |
tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build: [msrv, stable] | |
os: ["ubuntu-latest", "macOS-latest", "windows-latest"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Define Rust version | |
if: matrix.os != 'windows-latest' | |
run: | | |
if [ "${{ matrix.build }}" = "msrv" ]; then | |
echo "RUST_VERSION=${{ env.MSRV }}" >> $GITHUB_ENV | |
else | |
echo "RUST_VERSION=${{ matrix.build }}" >> $GITHUB_ENV | |
fi | |
- name: Define Rust version | |
if: matrix.os == 'windows-latest' | |
shell: powershell | |
run: | | |
if ("${{ matrix.build }}" -eq "msrv") { | |
"RUST_VERSION=$env:MSRV" >> $env:GITHUB_ENV | |
} else { | |
"RUST_VERSION=${{ matrix.build }}" >> $env:GITHUB_ENV | |
} | |
- name: Install toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.RUST_VERSION }} | |
override: true | |
profile: minimal | |
components: rustfmt, clippy | |
- name: Cache cargo files | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
./target | |
./test-target | |
key: ${{ runner.os }}-cargo-files-${{ matrix.build}}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-files-${{ matrix.build}} | |
- name: Test (default) | |
run: cargo test | |
- name: Test (termion) | |
if: matrix.os != 'windows-latest' | |
run: cargo test --no-default-features --features=termion | |
- name: Test (crossterm) | |
run: cargo test --no-default-features --features=crossterm | |
- name: Test (console) | |
run: cargo test --no-default-features --features=console | |
- name: Test (all features) | |
if: matrix.os != 'windows-latest' | |
run: cargo test --all-features | |
- name: Check format | |
if: ${{ false }} | |
run: cargo fmt --check | |
- name: Check lint | |
if: ${{ false }} | |
run: cargo clippy -- -D warnings |