diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00e0acfe0..08457ffa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,26 +10,6 @@ on: branches: [ master ] jobs: - fmt: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache setup - uses: ./.github/actions/cache-setup - - - name: Install nightly for rustfmt features - run: | - FMT_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt) - rustup install nightly - rustup default "$FMT_NIGHTLY" - rustup component add rustfmt - - - name: Check formatting - run: cargo fmt --all -- --check - doc: runs-on: ubuntu-latest @@ -50,35 +30,6 @@ jobs: # - name: Validate links # run: cargo deadlinks --dir target/doc/glommio - toml: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache setup - uses: ./.github/actions/cache-setup - - - name: Install cargo-sort - run: cargo install cargo-sort - - - name: Sort Cargo.toml - run: cargo sort -w --check - - clippy: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache setup - uses: ./.github/actions/cache-setup - - - name: Run linters - run: cargo clippy --all-targets --all-features -- -D warnings - build: runs-on: ubuntu-latest @@ -102,5 +53,15 @@ jobs: - name: Cache setup uses: ./.github/actions/cache-setup - - name: Test all targets - run: sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && PATH=$PATH:/usr/share/rust/.cargo/bin && RUSTUP_TOOLCHAIN=stable cargo test --all-features" + - name: Install cargo helpers and test all targets + run: | + cat << EOF > "run-gha-workflow.sh" + PATH=$PATH:/usr/share/rust/.cargo/bin + rustup install nightly + rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu + rustup show + rustup default stable + cargo install cargo-sort + cargo test --all-features + EOF + sudo -E bash -c "ulimit -Sl 512 && ulimit -Hl 512 && bash run-gha-workflow.sh" diff --git a/glommio/tests/linters.rs b/glommio/tests/linters.rs new file mode 100644 index 000000000..93ccbebe4 --- /dev/null +++ b/glommio/tests/linters.rs @@ -0,0 +1,49 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the MIT/Apache-2.0 License, at your convenience +// +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2020 +// Datadog, Inc. +#[cfg(test)] +mod tests { + use std::process::Command; + #[test] + fn check_formating() { + let status = Command::new("cargo") + .args(["+nightly", "fmt", "--all", "--", "--check"]) + .status() + .unwrap(); + assert!( + status.success(), + "cargo fmt failed. Note that glommio uses nightly for formatting, so please invoke \ + cargo with +nightly" + ); + } + + #[test] + fn check_clippy() { + let status = Command::new("cargo") + .args([ + "clippy", + "--all-targets", + "--all-features", + "--", + "-D", + "warnings", + ]) + .status() + .unwrap(); + assert!(status.success()); + } + + #[test] + fn check_dependencies_sorted() { + let status = Command::new("cargo") + .args(["sort", "-w", "-c"]) + .status() + .unwrap(); + assert!( + status.success(), + "cargo-sort not installed or cargo.toml dependencies not sorted" + ); + } +}