anya-core 1.2.0

Enterprise-grade Bitcoin Infrastructure Platform
Documentation
name: Rust CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build-test:
    name: Build and Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        project: [anya-core, anya-enterprise, attachments]
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - name: Set up Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
        # Set up the Rust toolchain
      - name: Cache Cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-
        # Cache Cargo dependencies to speed up builds
      - name: Build
        run: cargo build --verbose --workspace --package ${{ matrix.project }}
        # Build the specified Rust package
      - name: Run Tests
        run: cargo test --verbose --workspace --package ${{ matrix.project }}
        # Run tests for the specified Rust package

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt
        # Set up Rustfmt
      - name: Cache Cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-
        # Cache Cargo dependencies
      - name: Check Formatting
        run: cargo fmt --all -- --check
        # Verify that all code is properly formatted

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: clippy
        # Set up Clippy
      - name: Cache Cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-
        # Cache Cargo dependencies
      - name: Run Clippy
        run: cargo clippy --all-features --workspace -- -D warnings
        # Perform linting to catch code issues

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
        # Set up Rust for Coverage
      - name: Cache Cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-
        # Cache Cargo dependencies
      - name: Install Tarpaulin
        run: cargo install cargo-tarpaulin
        # Install Tarpaulin for coverage analysis
      - name: Run Tarpaulin
        run: cargo tarpaulin --ignore-tests --workspace --verbose
        # Execute coverage tests

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - name: Set up Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
        # Set up the Rust toolchain
      - name: Build Project
        run: cargo build --verbose --workspace
        # Build the entire workspace

  security:
    name: Security Checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        # Checkout the repository code
      - name: Set up Rust Security Tools
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
        # Set up Rust toolchain for security tools
      - name: Cache Cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-
        # Cache Cargo dependencies
      - name: Run Vulnerability Checks
        run: cargo audit
        # Check for vulnerabilities in dependencies
      - name: Run Deny License Check
        run: cargo deny check licenses
        # Ensure all dependencies have acceptable licenses
      - name: Run Deny Policy Check
        run: cargo deny check
        # Verify against custom policies
      - name: Analyze Code for Security
        run: echo "Running additional security analysis steps here..."
        # Placeholder for additional security analyses

  finalize:
    name: Finalize CI
    needs: [build-test, fmt, clippy, coverage, build, security]
    runs-on: ubuntu-latest
    steps:
      - name: All checks passed
        run: echo "CI pipeline completed successfully."
        # Confirm all CI jobs have passed

  data-workflow:
    name: Data Workflow
    runs-on: ubuntu-latest
    needs: [build-test, fmt, clippy, coverage, build, security]
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v3
      - name: Set up Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: ["rustfmt", "clippy"]
          target: x86_64-unknown-linux-gnu
          override: true
      - name: Cache Dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Process Data
        run: |
          cargo run --bin data-processor
          cargo test --test data_integration
      - name: Validate Results
        run: cargo run --bin validate-data
      - name: Upload Artifacts
        uses: actions/upload-artifact@v3
        with:
          name: processed-data
          path: data/processed
          retention-days: 5