Skip to content

Commit

Permalink
Merge pull request #1 from loco-rs/add-ci
Browse files Browse the repository at this point in the history
add ci
  • Loading branch information
kaplanelad authored Oct 13, 2024
2 parents 923e911 + 755c283 commit a02181b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 27 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
push:
branches:
- main
pull_request:

env:
RUST_TOOLCHAIN: 1.79.0
TOOLCHAIN_PROFILE: minimal

jobs:
rustfmt:
name: Check Style
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Run cargo fmt
run: cargo fmt --all -- --check

clippy:
name: Run Clippy
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt,clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run cargo clippy
run: cargo clippy --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms

test:
name: Run Tests
needs: [rustfmt, clippy]
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run cargo test
run: cargo test --all-features --all
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ thiserror = { version = "1" }
colored = { version = "2.1.0" }

[dev-dependencies]
insta = { version = "1.40.0" }
2 changes: 1 addition & 1 deletion src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl StringDefBuilder<'_> {

impl std::fmt::Display for StringDefBuilder<'_> {
/// Displays the generated string based on the current configuration of the builder.
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut rng = self.rng.borrow_mut();
let result = self.string_def.generate(&mut *rng);
write!(f, "{result}")
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! # Crazy Train
//!
//! **Crazy Train** is a Rust library designed for randomized and fuzz execution of command-line
//! interfaces (CLIs). It helps discover unforeseen sequences of steps and parameters that can lead
//! interfaces. It helps discover unforeseen sequences of steps and parameters that can lead
//! to unexpected errors. This library facilitates reproducible test plan runs, ensuring that the
//! command-line interface behaves as expected under various scenarios.
//!
Expand All @@ -23,6 +23,7 @@
//! crazy-train = "0.1.0" // Replace with the latest version
//! ```
//!

mod errors;
pub mod executer;
mod generator;
Expand Down
2 changes: 1 addition & 1 deletion src/randomizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Randomizer {
/// assert_eq!(randomizer.string(string_def.clone()).include_symbol(true).to_string(), "=wqf`g");
/// assert_eq!(randomizer.string(string_def.clone()).length(10).to_string(), "wgavmyyuzw");
/// ```
pub fn string(&self, def: StringDef) -> StringDefBuilder {
pub fn string(&self, def: StringDef) -> StringDefBuilder<'_> {
StringDefBuilder {
string_def: def,
rng: &self.rng,
Expand Down
16 changes: 0 additions & 16 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ impl Runner {
#[cfg(test)]
mod tests {

use insta::assert_debug_snapshot;
use std::path::PathBuf;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -246,21 +245,6 @@ mod tests {
}
}

#[test]
fn can_dump_plan() {
let location = std::env::temp_dir().join("crazy-train");

let step_one = TestStepOne { location };
let step_two = TestStepOne {
location: std::env::temp_dir().join("crazy-train-1"),
};

let randomaizer = Randomizer::with_seed(42);
let runner = new(vec![Box::new(step_one), Box::new(step_two)]).randomizer(randomaizer);

assert_debug_snapshot!(runner.dump_plan());
}

#[test]
fn can_run() {
let base_location = std::env::temp_dir().join("crazy-train");
Expand Down
7 changes: 0 additions & 7 deletions src/snapshots/crazy_train__runner__tests__can_dump_plan.snap

This file was deleted.

0 comments on commit a02181b

Please sign in to comment.