nmt-rs 0.2.5

A namespaced merkle tree compatible with Celestia
Documentation
name: Rust

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    runs-on: ubuntu-latest
    name: check
    env:
      RUSTFLAGS: -D warnings
      SCCACHE_GHA_ENABLED: "true"
      RUSTC_WRAPPER: "sccache"
    steps:
      - uses: actions/checkout@v4
      - name: Install stable toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: clippy
          rustflags: -D warnings
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.8
      - name: Run cargo clippy
        run: cargo clippy --all-features --all-targets -- -D warnings
      - name: Run cargo fmt check
        run: |
          if ! cargo fmt --check --verbose ; then
            echo "Formatting errors detected, please run 'cargo fmt' to fix it";
            exit 1
          fi

  # Check that every combination of features is working properly.
  hack:
    runs-on: ubuntu-latest
    name: features
    env:
      SCCACHE_GHA_ENABLED: "true"
      RUSTC_WRAPPER: "sccache"
    steps:
      - uses: actions/checkout@v4
      - name: Install stable toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          rustflags: -D warnings
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.8
      - name: cargo install cargo-hack
        uses: taiki-e/install-action@cargo-hack
      # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
      - name: cargo hack
        run: cargo hack --feature-powerset check

  test:
    runs-on: ubuntu-latest
    env:
      SCCACHE_GHA_ENABLED: "true"
      RUSTC_WRAPPER: "sccache"
    steps:
      - uses: actions/checkout@v4
      - name: Install stable toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          rustflags: -D warnings
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.8
      - name: Run cargo test
        run: cargo test --all-features

  coverage:
    runs-on: ubuntu-latest
    env:
      SCCACHE_GHA_ENABLED: "true"
      RUSTC_WRAPPER: "sccache"
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Install stable toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          rustflags: -D warnings
          components: llvm-tools-preview
      - name: Run sccache-cache
        uses: mozilla-actions/sccache-action@v0.0.8
      - name: cargo install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov
      - name: cargo generate-lockfile
        if: hashFiles('Cargo.lock') == ''
        run: cargo generate-lockfile
      - name: cargo llvm-cov
        run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
      - name: Upload to codecov.io
        if: ${{ github.repository == 'Sovereign-Labs/nmt-rs' }}
        uses: codecov/codecov-action@v5
        with:
          fail_ci_if_error: false