diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db306b460ff..56b06d84c6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: build -'on': +on: pull_request: workflow_dispatch: schedule: @@ -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" diff --git a/src/string/reverse.rs b/src/string/reverse.rs index bf17745a147..1fb997be653 100644 --- a/src/string/reverse.rs +++ b/src/string/reverse.rs @@ -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,)*) => { $( @@ -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"),