diff --git a/.github/CICD_GUIDE.md b/.github/CICD_GUIDE.md index 423f9bd..1298905 100644 --- a/.github/CICD_GUIDE.md +++ b/.github/CICD_GUIDE.md @@ -15,7 +15,7 @@ The Janus project uses GitHub Actions for continuous integration and deployment. ### Manual Trigger ```bash -# Via GitHub UI: Actions tab → CI/CD Pipeline → Run workflow +# Via GitHub UI: Actions tab → choose `Fast PR Checks` or `Release And Extended CI` → Run workflow ``` ## Jobs Overview @@ -313,7 +313,8 @@ Common issues: ### Main Configuration -- `.github/workflows/ci.yml` - Main pipeline +- `.github/workflows/fast-pr.yml` - Fast pull request validation +- `.github/workflows/release.yml` - Extended branch, release, and scheduled checks ### Supporting Files @@ -355,4 +356,4 @@ Common issues: - Simplified from 9 jobs to 5-6 jobs - Reduced pipeline time by ~70% - Added dependency review for PRs -- Updated publish job to remove Rust dependencies \ No newline at end of file +- Updated publish job to remove Rust dependencies diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b5f9cde..16e8f41 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -57,7 +57,7 @@ make fmt # Format all code make clippy # Lint checks ``` -**CI Pipeline:** GitHub Actions runs `rustfmt`, `clippy`, and tests on Ubuntu/Windows/macOS with stable/beta Rust. See `.github/workflows/ci.yml`. +**CI Pipeline:** GitHub Actions runs fast PR checks from `.github/workflows/fast-pr.yml` and extended push/release checks from `.github/workflows/release.yml`. ### Benchmarking diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index d44b732..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,273 +0,0 @@ -name: CI/CD Pipeline - -on: - push: - branches: [main, develop] - pull_request: - branches: [main, develop] - workflow_dispatch: - -env: - RUST_VERSION: stable - CARGO_TERM_COLOR: always - -jobs: - # Check code formatting - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - - name: Check formatting - run: cargo fmt --all -- --check - - # Lint with Clippy - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo build - uses: actions/cache@v4 - with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - - name: Run Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - # Run tests - test: - name: Test Suite - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - rust: [stable, beta] - exclude: - - os: windows-latest - rust: beta - - os: macos-latest - rust: beta - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo build - uses: actions/cache@v4 - with: - path: target - key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - - name: Run tests - run: cargo test --all-features --verbose - - - name: Run doc tests - run: cargo test --doc --all-features --verbose - - # Test with Docker services - integration-test: - name: Integration Tests - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo build - uses: actions/cache@v4 - with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - - name: Run integration tests - run: cargo test --test '*' --all-features --verbose - - # Code coverage - coverage: - name: Code Coverage - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - components: llvm-tools-preview - - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Generate coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - files: lcov.info - flags: rust - name: rust-coverage - - # Build release binaries - build: - name: Build - runs-on: ${{ matrix.os }} - needs: [fmt, clippy, test] - strategy: - matrix: - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: windows-latest - target: x86_64-pc-windows-msvc - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - - name: Cache cargo registry - uses: actions/cache@v4 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v4 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo build - uses: actions/cache@v4 - with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Build release binary - run: cargo build --release --target ${{ matrix.target }} --verbose - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: janus-${{ matrix.target }} - path: | - target/${{ matrix.target }}/release/janus${{ matrix.os == 'windows-latest' && '.exe' || '' }} - - # Security audit - security: - name: Security Audit - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Install cargo-audit - run: cargo install cargo-audit - - - name: Run security audit - run: cargo audit - - # Publish to crates.io (on release tags) - publish: - name: Publish to crates.io - runs-on: ubuntu-latest - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - needs: [fmt, clippy, test, integration-test, build, security] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Publish to crates.io - run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} - - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: - generate_release_notes: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/fast-pr.yml b/.github/workflows/fast-pr.yml new file mode 100644 index 0000000..c538132 --- /dev/null +++ b/.github/workflows/fast-pr.yml @@ -0,0 +1,68 @@ +name: Fast PR Checks + +on: + pull_request: + branches: [main, develop] + paths-ignore: + - "**/*.md" + - "docs/**" + +concurrency: + group: fast-pr-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Check formatting + run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - name: Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + + - name: Run Clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + + - name: Run tests + run: cargo test --all-features --verbose + + - name: Run doc tests + run: cargo test --doc --all-features --verbose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e3272c2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,168 @@ +name: Release And Extended CI + +on: + push: + branches: [main, develop] + tags: + - "v*" + workflow_dispatch: + schedule: + - cron: "0 6 * * 1" + +concurrency: + group: release-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + test-matrix: + name: Test Suite (${{ matrix.os }}, ${{ matrix.rust }}) + if: github.event_name != 'schedule' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + rust: stable + - os: windows-latest + rust: stable + - os: macos-latest + rust: stable + - os: ubuntu-latest + rust: beta + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + + - name: Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + with: + shared-key: ${{ matrix.os }}-${{ matrix.rust }} + + - name: Run tests + run: cargo test --all-features --verbose + + - name: Run doc tests + if: matrix.os == 'ubuntu-latest' && matrix.rust == 'stable' + run: cargo test --doc --all-features --verbose + + security: + name: Security Audit + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install cargo-audit + uses: taiki-e/install-action@cargo-audit + + - name: Cache advisory database + uses: actions/cache@v4 + with: + path: ~/.cargo/advisory-db + key: ${{ runner.os }}-advisory-db + + - name: Run security audit + run: cargo audit + + coverage: + name: Code Coverage + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + + - name: Generate coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + files: lcov.info + flags: rust + name: rust-coverage + + build-release: + name: Build Release (${{ matrix.target }}) + if: startsWith(github.ref, 'refs/tags/v') + needs: [test-matrix, security] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: macos-latest + target: x86_64-apple-darwin + - os: macos-latest + target: aarch64-apple-darwin + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache Rust build artifacts + uses: Swatinem/rust-cache@v2 + with: + shared-key: release-${{ matrix.os }}-${{ matrix.target }} + + - name: Build release binary + run: cargo build --release --target ${{ matrix.target }} --verbose + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: janus-${{ matrix.target }} + path: target/${{ matrix.target }}/release/janus${{ matrix.os == 'windows-latest' && '.exe' || '' }} + + publish: + name: Publish to crates.io + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [test-matrix, security, build-release] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Publish to crates.io + run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}