Skip to content

Commit

Permalink
Format code and add lint job in CI (#103)
Browse files Browse the repository at this point in the history
* Separate lint job

* Fix formatting

* Derive Default for ErrorMessage enum

* Revert "Derive Default for ErrorMessage enum"

This reverts commit 9f43ceb.

* Ignore clippy::derivable_impls for ErrorMessage
  • Loading branch information
mikaelmello committed Mar 12, 2023
1 parent a0b082a commit 14b1648
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,49 @@ env:
MSRV: 1.58.1

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
fetch-depth: 1

- 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 -- -D warnings

tests:
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -72,10 +115,6 @@ jobs:
- name: Test (default)
run: cargo test --verbose

- name: Test (all features)
if: matrix.os != 'windows-latest'
run: cargo test --verbose --all-features

- name: Test (termion)
if: matrix.os != 'windows-latest'
run: cargo test --verbose --no-default-features --features=termion
Expand All @@ -86,6 +125,10 @@ jobs:
- name: Test (console)
run: cargo test --verbose --no-default-features --features=console

- name: Test (all features)
if: matrix.os != 'windows-latest'
run: cargo test --verbose --all-features

- name: Check format
if: ${{ false }}
run: cargo fmt --check
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/termion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::fmt;
use std::io::{stdin, stderr, Result, Stdin, Stderr, Write};
use std::io::{stderr, stdin, Result, Stderr, Stdin, Write};

use termion::{
color::{self, Color},
Expand Down
3 changes: 3 additions & 0 deletions src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub enum ErrorMessage {
Custom(String),
}

// Deriving an enum default was stabilized on v1.62 which would require us
// to bump the MSRV to 1.62.0.
#[allow(clippy::derivable_impls)]
impl Default for ErrorMessage {
fn default() -> Self {
ErrorMessage::Default
Expand Down

0 comments on commit 14b1648

Please sign in to comment.