Upgrade CI workflows #22
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@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v5 | |
| 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@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v5 | |
| 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@v6 | |
| - 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@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v5 | |
| 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@v6 | |
| - name: Install Rust toolchain (MSRV) | |
| uses: dtolnay/rust-toolchain@1.85 | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@v5 | |
| 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@v6 | |
| - 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@v5 | |
| 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@v5 | |
| with: | |
| files: lcov.info | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN}} | |
| slug: paradedb/decimal-bytes | |
| - name: Generate coverage summary | |
| run: | | |
| # Run coverage and capture output | |
| COVERAGE_OUTPUT=$(cargo llvm-cov --all-features 2>&1) | |
| # Extract percentages using grep -o to find all percentage patterns | |
| # Format: "Regions Cover% Functions Cover% Lines Cover%" | |
| # We want the last percentage on each line (Line coverage) | |
| # Get the TOTAL line and extract percentages | |
| TOTAL_LINE=$(echo "$COVERAGE_OUTPUT" | grep "^TOTAL") | |
| # Extract all percentages from the line, take the last one (line coverage) | |
| LINE_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | tail -1) | |
| # Function coverage is the second percentage | |
| FUNC_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | head -2 | tail -1) | |
| # Region coverage is the first percentage | |
| REGION_COV=$(echo "$TOTAL_LINE" | grep -oE '[0-9]+\.[0-9]+%' | head -1) | |
| # Get file-level line coverage (last percentage on each line) | |
| ENCODING_COV=$(echo "$COVERAGE_OUTPUT" | grep "encoding.rs" | grep -oE '[0-9]+\.[0-9]+%' | tail -1) | |
| LIB_COV=$(echo "$COVERAGE_OUTPUT" | grep "lib.rs" | grep -oE '[0-9]+\.[0-9]+%' | tail -1) | |
| # 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 |