diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fec17ad..0c6705d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,15 +1,99 @@ name: Rust -on: [push] +on: [push, pull_request] jobs: - build: - + lint: + name: Linting and Formatting Checks runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install rustfmt + run: rustup component add rustfmt + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: Check Formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Install clippy + run: rustup component add clippy + + - name: Clippy Linting + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + test: + name: Run Tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + # add windows-latest when it is clear why tests are failing + os: [ubuntu-latest, macos-latest] steps: - - uses: actions/checkout@v1 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + + - name: Run Tests + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Run Editorconfig Checker + uses: actions-rs/cargo@v1 + with: + command: run