diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..dc678c8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,95 @@ +name: Rust CI +on: [push, pull_request] + +jobs: + build_linux: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + run: | + rustup component add rustfmt + rustup component add clippy + + - name: Cache Cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-registry-linux + + - name: Cache Cargo build + uses: actions/cache@v3 + with: + path: target + key: cargo-build-linux + + - name: Run tests + run: cargo test --verbose + + - name: Run tests (release) + run: cargo test --verbose --release + + - name: Run Cargo Clippy + run: cargo clippy + + - name: Run Cargo Format + run: cargo fmt --check + + - name: Run Cargo Doc + run: cargo doc --no-deps + + build_osx: + runs-on: macos-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-registry-osx + + - name: Cache Cargo build + uses: actions/cache@v3 + with: + path: target + key: cargo-build-osx + + - name: Run tests + run: cargo test + + - name: Run tests (release) + run: cargo test --release + + build_win: + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-registry-windows + + - name: Cache Cargo build + uses: actions/cache@v3 + with: + path: target + key: cargo-build-windows + + - name: Run tests + run: cargo test + + - name: Run tests (release) + run: cargo test --release diff --git a/src/pace/reader.rs b/src/pace/reader.rs index cca514a..258a80a 100644 --- a/src/pace/reader.rs +++ b/src/pace/reader.rs @@ -60,7 +60,13 @@ pub trait InstanceVisitor { fn visit_unrecognized_line(&mut self, _lineno: usize, _line: &str) -> Action { Action::Continue } - fn visit_stride_line(&mut self, _lineno: usize, _line: &str, _key : &str, _value : &str) -> Action { + fn visit_stride_line( + &mut self, + _lineno: usize, + _line: &str, + _key: &str, + _value: &str, + ) -> Action { Action::Continue } } @@ -161,7 +167,9 @@ impl<'a, V: InstanceVisitor> InstanceReader<'a, V> { } else if content.starts_with("#s") { // stride line in the format "#s key: value" if let Some((key, value)) = try_parse_stride_line(content) { - if self.visitor.visit_stride_line(lineno, content, key, value) == Action::Terminate { + if self.visitor.visit_stride_line(lineno, content, key, value) + == Action::Terminate + { return Ok(()); } } else { @@ -247,8 +255,15 @@ mod tests { Action::Continue } - fn visit_stride_line(&mut self, lineno: usize, line: &str, key: &str, value: &str) -> Action { - self.stride_lines.push((lineno, line.to_string(), key.to_string(), value.to_string())); + fn visit_stride_line( + &mut self, + lineno: usize, + line: &str, + key: &str, + value: &str, + ) -> Action { + self.stride_lines + .push((lineno, line.to_string(), key.to_string(), value.to_string())); Action::Continue } } @@ -326,7 +341,14 @@ mod tests { let mut reader = InstanceReader::new(&mut visitor); reader.read(input.as_bytes()).unwrap(); - assert_eq!(visitor.stride_lines, - vec![(1, "#s stride_key: somevalue".to_string(), "stride_key".to_string(), "somevalue".to_string())]); + assert_eq!( + visitor.stride_lines, + vec![( + 1, + "#s stride_key: somevalue".to_string(), + "stride_key".to_string(), + "somevalue".to_string() + )] + ); } }