serde-structprop 0.1.0

Serde serializer and deserializer for the structprop config file format
Documentation
name: CI

on:
  push:
    branches: ["main"]
  pull_request:
  workflow_call:

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    steps:
      - uses: actions/checkout@v6

      - name: Install stable toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Build
        run: cargo build --all-targets

      - name: Run tests
        run: cargo test

  lint:
    name: Lint
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install stable toolchain with clippy and rustfmt
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Check formatting
        run: cargo fmt --check

      - name: Clippy
        run: cargo clippy --all-targets -- -W clippy::pedantic

  commits:
    name: Conventional commits
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
        with:
          # Full history is required for cog check to validate all commits.
          fetch-depth: 0

      - name: Check conventional commits
        uses: cocogitto/cocogitto-action@v3
        with:
          check: true
          # On PRs check only the commits introduced by the PR.
          # On pushes to main check only commits since the previous HEAD.
          from: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}

  changelog:
    name: Verify changelog
    runs-on: ubuntu-latest
    # Only run on pushes to main, not on PRs.
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'

    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Install cocogitto
        uses: cocogitto/cocogitto-action@v3
        with:
          check: false
          release: false

      - name: Verify changelog generation
        # Confirm that cog can generate a changelog from the current history.
        # The authoritative CHANGELOG.md is produced locally by maintainers
        # running `cog bump --auto` before pushing a version tag; it is not
        # written by CI because main is branch-protected.
        run: cog changelog > CHANGELOG.md

  semver:
    name: Semver compatibility
    runs-on: ubuntu-latest
    # Only meaningful on PRs — compares the PR branch against the published
    # crate version to catch accidental breaking API changes.
    if: github.event_name == 'pull_request'

    steps:
      - uses: actions/checkout@v6

      - name: Install stable toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Check if crate is published on crates.io
        id: crates_io
        run: |
          STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://crates.io/api/v1/crates/serde-structprop)
          if [ "$STATUS" = "200" ]; then
            echo "published=true" >> "$GITHUB_OUTPUT"
          else
            echo "published=false" >> "$GITHUB_OUTPUT"
            echo "Crate not yet published on crates.io; skipping semver check."
          fi

      - name: Check semver compatibility
        if: steps.crates_io.outputs.published == 'true'
        uses: obi1kenobi/cargo-semver-checks-action@v2

  msrv:
    name: MSRV
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust 1.85
        uses: dtolnay/rust-toolchain@1.85

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Check MSRV builds
        run: cargo check