Added more tests for edge cases. #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: "default features" | |
| features: "" | |
| - name: "rust_decimal" | |
| features: "--features rust_decimal" | |
| - name: "bigdecimal" | |
| features: "--features bigdecimal" | |
| - name: "all features" | |
| features: "--all-features" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run tests (${{ matrix.name }}) | |
| run: cargo test ${{ matrix.features }} --verbose | |
| clippy: | |
| name: Clippy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-clippy- | |
| - name: Run Clippy (all features) | |
| run: cargo clippy --all-features -- -D warnings | |
| fmt: | |
| name: Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| docs: | |
| name: Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-docs- | |
| - name: Check documentation | |
| env: | |
| RUSTDOCFLAGS: -D warnings | |
| run: cargo doc --all-features --no-deps | |
| msrv: | |
| name: Minimum Supported Rust Version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain (MSRV) | |
| uses: dtolnay/rust-toolchain@1.85 | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-msrv- | |
| - name: Check MSRV compatibility | |
| run: cargo check --all-features | |
| coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: llvm-tools-preview | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-cov-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-cov- | |
| - name: Generate coverage report | |
| run: cargo llvm-cov --all-features --lcov --output-path lcov.info | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: lcov.info | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Generate coverage summary | |
| run: | | |
| # Run coverage and capture output | |
| COVERAGE_OUTPUT=$(cargo llvm-cov --all-features 2>&1) | |
| # Extract the summary line (TOTAL row) | |
| TOTAL_LINE=$(echo "$COVERAGE_OUTPUT" | grep "^TOTAL") | |
| # Parse coverage percentages | |
| REGION_COV=$(echo "$TOTAL_LINE" | awk '{print $4}') | |
| FUNC_COV=$(echo "$TOTAL_LINE" | awk '{print $7}') | |
| LINE_COV=$(echo "$TOTAL_LINE" | awk '{print $10}') | |
| # Get file-level details | |
| ENCODING_LINE=$(echo "$COVERAGE_OUTPUT" | grep "encoding.rs") | |
| LIB_LINE=$(echo "$COVERAGE_OUTPUT" | grep "lib.rs") | |
| ENCODING_COV=$(echo "$ENCODING_LINE" | awk '{print $10}') | |
| LIB_COV=$(echo "$LIB_LINE" | awk '{print $10}') | |
| # Write formatted summary | |
| echo "## 📊 Code Coverage Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Metric | Coverage |" >> $GITHUB_STEP_SUMMARY | |
| echo "|--------|----------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Lines** | $LINE_COV |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Functions** | $FUNC_COV |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Regions** | $REGION_COV |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Per-File Coverage" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| File | Line Coverage |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|---------------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| \`encoding.rs\` | $ENCODING_COV |" >> $GITHUB_STEP_SUMMARY | |
| echo "| \`lib.rs\` | $LIB_COV |" >> $GITHUB_STEP_SUMMARY |