name: Code Style
on:
  pull_request:

jobs:
  codestyle:
    name: Code Style (fmt + clippy)
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
        profile: minimal
        components: rustfmt
    - name: Check formatting
      run: |
        cargo fmt --all -- --check
    - name: Install libudev-dev
      run: |
        sudo apt-get update
        sudo apt-get install --assume-yes libudev-dev
    - name: Check lints (cargo clippy)
      run: cargo clippy -- -D warnings
    - name: Check additional compilation configs
      run: |
        # all features disabled 
        cargo check --tests --no-default-features 
        # config, used by `cargo-near`, when importing `near-cli-rs` as a lib
        cargo check --tests --no-default-features --features ledger

