Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build

'on':
on:
pull_request:
workflow_dispatch:
schedule:
Expand All @@ -11,22 +11,31 @@ jobs:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cargo fmt
run: cargo fmt --all -- --check
- uses: actions/checkout@v4
- name: cargo fmt
run: cargo fmt --all -- --check

clippy:
name: cargo clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cargo clippy
run: cargo clippy --all --all-targets -- -D warnings
- uses: actions/checkout@v4
- name: cargo clippy
run: cargo clippy --all --all-targets -- -D warnings

test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cargo test
run: cargo test
- uses: actions/checkout@v4
- name: cargo test
run: cargo test --all -- --test-threads=1

- name: Install codecov
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
sudo mv codecov /usr/local/bin

- name: Upload coverage to Codecov
run: codecov -f target/debug/deps/*.gcov -t ${{ secrets.CODECOV_TOKEN }} || echo "Codecov upload failed"
2 changes: 2 additions & 0 deletions src/string/reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn reverse(text: &str) -> String {
mod tests {
use super::*;

// Macro for generating test cases
macro_rules! test_cases {
($($name:ident: $test_case:expr,)*) => {
$(
Expand All @@ -27,6 +28,7 @@ mod tests {
};
}

// Using the macro to define various test cases
test_cases! {
test_simple_palindrome: ("racecar", "racecar"),
test_non_palindrome: ("abcdef", "fedcba"),
Expand Down