bevy_fsm 0.4.0

Observer-driven finite state machine framework for Bevy ECS with variant-specific events and flexible validation
Documentation
name: CI

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

concurrency:
  group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
  cancel-in-progress: true

env:
  RUSTFLAGS: -Dwarnings
  RUSTDOCFLAGS: -Dwarnings
  RUST_TOOLCHAIN: "1.95.0"

jobs:
  # Check formatting
  format:
    name: Format
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          components: rustfmt

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

  # Check for forbidden doc attributes
  forbidden-attributes:
    name: Check for forbidden attributes
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Check for no_run attribute
        run: |

          if grep -rE '```[a-z]*[, ]*no_run' --include="*.rs" .; then
            echo "Error: Found 'no_run' attribute in documentation (e.g., \`\`\`no_run, \`\`\`rust,no_run)"
            exit 1
          fi

      - name: Check for ignore attribute
        run: |

          if grep -rE '```[a-z]*[, ]*ignore' --include="*.rs" .; then
            echo "Error: Found 'ignore' attribute in documentation (e.g., \`\`\`ignore, \`\`\`rust,ignore)"
            exit 1
          fi

      - name: Check for #[ignore] in tests
        run: |

          if grep -r "#\[ignore\]" --include="*.rs" .; then
            echo "Error: Found '#[ignore]' attribute in tests"
            exit 1
          fi

  # Check documentation
  docs:
    name: Docs
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN }}

      - name: Restore Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ci
          save-if: false

      - name: Check documentation
        run: cargo doc --no-deps --all-features

  # Run Clippy lints (pedantic)
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN }}
          components: clippy

      - name: Restore Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ci
          save-if: ${{ github.ref == 'refs/heads/main' }}

      - name: Run Clippy
        run: >

          cargo clippy --all-targets --all-features --
          -W clippy::pedantic
          -A clippy::needless_pass_by_value
          -A clippy::too_many_arguments
          -A clippy::type_complexity

  # Run tests
  test:
    name: Test
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN }}

      - name: Restore Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: test
          save-if: ${{ github.ref == 'refs/heads/main' }}

      - name: Run tests
        run: cargo test --all-targets --all-features

      - name: Run doc tests
        run: cargo test --doc --all-features