Update README.md #64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| rust-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('mandala-rust-ext/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install maturin | |
| run: pip install maturin | |
| - name: Build Rust extension | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| maturin build --release | |
| - name: Upload Rust build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rust-wheels | |
| path: mandala-rust-ext/target/wheels/ | |
| rust-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('mandala-rust-ext/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run Rust tests | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| cargo test --release || echo "No Rust tests found" | |
| - name: Run Rust clippy | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| cargo clippy -- -D warnings || echo "Clippy found issues" | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: rust-build | |
| strategy: | |
| matrix: | |
| python-version: ["3.11"] | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('mandala-rust-ext/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install maturin | |
| pip install -e ".[dev,test]" | |
| pip install pytest pytest-asyncio pytest-cov pytest-mock redis | |
| - name: Build Rust extension | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| maturin build --release | |
| pip install target/wheels/mandala_rust_ext-*.whl | |
| - name: Run tests with coverage | |
| env: | |
| REDIS_URL: redis://localhost:6379/0 | |
| run: | | |
| pytest tests/ \ | |
| --cov=mandala \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| --cov-report=html \ | |
| -v \ | |
| --tb=short | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| - name: Upload coverage HTML | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| - name: Check coverage threshold | |
| run: | | |
| coverage report --fail-under=40 || echo "WARNING: Coverage below 40% threshold" | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Set up Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| components: rustfmt, clippy | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff black mypy | |
| - name: Run Rust clippy | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| cargo clippy -- -D warnings || echo "Clippy found issues" | |
| - name: Run Rust fmt check | |
| working-directory: ./mandala-rust-ext | |
| run: | | |
| cargo fmt -- --check || echo "Rust fmt check failed" | |
| - name: Run ruff linter | |
| run: | | |
| ruff check src/mandala tests/ | |
| - name: Run black formatter check | |
| run: | | |
| black --check --target-version py311 src/mandala tests/ | |
| - name: Run mypy type checker | |
| run: | | |
| mypy src/mandala --ignore-missing-imports || true | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bandit safety | |
| - name: Run bandit security linter | |
| run: | | |
| bandit -r src/mandala -f json -o bandit-report.json || true | |
| - name: Run safety check | |
| run: | | |
| safety check --json || true |