hocon-rs 0.2.0

Rust implementation of HOCON
Documentation
name: Rust

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  CRATE_NAME: hocon-rs

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
        features:
          - ""
          - "urls_includes"
          - "json_arbitrary_precision"
    steps:
      # Checkout repo
      - uses: actions/checkout@v4

      - name: Cache Rust build (cargo)
        uses: Swatinem/rust-cache@v2

      # Setup Rust
      - name: Setup Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt, clippy

      # Install coverage tool
      - name: Install cargo-llvm-cov
        if: matrix.rust == 'stable'
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-llvm-cov

      # Run tests
      - name: Run tests
        run: |
          if [ -z "${{ matrix.features }}" ]; then
            cargo test --verbose
          else
            cargo test --verbose --features ${{ matrix.features }}
          fi

      # Format check
      - name: Format
        if: matrix.rust == 'stable'
        run: cargo fmt --all -- --check

      # Clippy
      - name: Clippy
        if: matrix.rust == 'stable'
        run: cargo clippy -- -D warnings

      # Coverage report (stable only)
      - name: Generate coverage report
        if: matrix.rust == 'stable'
        run: |
          if [ -z "${{ matrix.features }}" ]; then
            cargo llvm-cov --lcov --output-path lcov.info
          else
            cargo llvm-cov --lcov --output-path lcov.info --features ${{ matrix.features }}
          fi
        shell: bash

      # Upload coverage to Codecov
      - name: Upload coverage to Codecov
        if: matrix.rust == 'stable'
        uses: codecov/codecov-action@v4
        with:
          files: lcov.info
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: ${{ matrix.rust }}-${{ matrix.features }}
          name: codecov-${{ matrix.rust }}-${{ matrix.features }}
          fail_ci_if_error: true