Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Pull Request

## Description
<!-- Describe your changes in detail -->

## Type of Change
<!-- Mark relevant options with [x] -->
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring

## Pre-Submission Checklist
<!-- All items MUST be checked before submitting PR -->
- [ ] I have run `cargo build` locally and it succeeds
- [ ] I have run `cargo test` locally and all tests pass
- [ ] I have run `cargo fmt` to format my code
- [ ] I have run `cargo clippy` and fixed all warnings
- [ ] My code follows the project's style guidelines
- [ ] I have added tests for new functionality (if applicable)

## CI/CD Rules Confirmation
<!-- These rules are enforced automatically -->
By submitting this PR, I confirm that:
1. **No Errors**: Code compiles without errors, passes formatting checks, and has no clippy warnings
2. **Build Success**: The project builds successfully with `cargo build --all`
3. **Tests Pass**: All tests pass with `cargo test --all` (including any new test files)

## Related Issues
<!-- Link to related issues using #issue_number -->
Fixes #(issue)

## Additional Notes
<!-- Any additional information for reviewers -->
65 changes: 55 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ env:
CARGO_TERM_COLOR: always

jobs:
# Rule 1: Check for errors (formatting, linting, compilation)
check:
name: Check
name: Check - No Errors
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -36,17 +37,18 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-

- name: Run cargo check
run: cargo check --all --locked

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

- name: Run cargo clippy
- name: Run clippy linter (treat warnings as errors)
run: cargo clippy --all -- -D warnings

- name: Check for compilation errors
run: cargo check --all --locked

# Rule 3: All tests must pass
test:
name: Test Suite
name: Test - All Tests Must Pass
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -71,11 +73,33 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-

- name: Run cargo test
- name: Run all tests
run: cargo test --all --locked

- name: Check for new test files
id: check_new_tests
if: github.event_name == 'pull_request'
run: |
echo "Checking for new test files in this PR..."
git fetch origin ${{ github.base_ref }} --depth=1
NEW_TEST_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '(test.*\.rs|.*_test\.rs|tests/.*\.rs)$' || true)
if [ -n "$NEW_TEST_FILES" ]; then
echo "New test files detected:"
echo "$NEW_TEST_FILES"
echo "new_tests=true" >> $GITHUB_OUTPUT
else
echo "No new test files detected"
echo "new_tests=false" >> $GITHUB_OUTPUT
fi

- name: Validate new test files pass
if: steps.check_new_tests.outputs.new_tests == 'true'
run: |
echo "✅ New test files detected and all tests passed!"

# Rule 2: Build must succeed before PR
build:
name: Build
name: Build - Must Build Successfully
runs-on: ubuntu-latest
needs: [check, test]
steps:
Expand Down Expand Up @@ -114,8 +138,28 @@ jobs:
path: target/wasm32-unknown-unknown/release/stellaraid_core.wasm
retention-days: 30

# PR Validation - Enforces all 3 rules
pr-validation:
name: PR Validation - All Rules Passed
runs-on: ubuntu-latest
needs: [check, test, build]
if: github.event_name == 'pull_request'
steps:
- name: Validate all checks passed
run: |
echo "========================================"
echo " PR Validation Summary"
echo "========================================"
echo ""
echo "Rule 1 - No Errors: ${{ needs.check.result }}"
echo "Rule 2 - Build Success: ${{ needs.build.result }}"
echo "Rule 3 - Tests Pass: ${{ needs.test.result }}"
echo ""
echo "✅ ALL 3 RULES PASSED - PR APPROVED FOR MERGE"

# Cross-platform build verification
build-matrix:
name: Build Matrix
name: Build Matrix (Cross-Platform)
runs-on: ${{ matrix.os }}
needs: check
strategy:
Expand Down Expand Up @@ -150,6 +194,7 @@ jobs:
- name: Build WASM contract
run: cargo build -p stellaraid-core --target wasm32-unknown-unknown

# Security scans
security:
name: Security Scans
runs-on: ubuntu-latest
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/pr-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PR Rules Enforcement

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ main, master ]

permissions:
contents: read
pull-requests: write
issues: write

jobs:
# This job posts a comment on PRs reminding contributors of the rules
pr-rules-reminder:
name: PR Rules Reminder
runs-on: ubuntu-latest
steps:
- name: Post PR Rules Comment
uses: actions/github-script@v7
with:
script: |
const body = `## 🛡️ PR Validation Rules

Hello @${{ github.actor }}! Thank you for your contribution.

Before this PR can be merged, it **MUST** pass all 3 CI/CD rules:

### Rule 1: No Errors ✅
- Code must compile without errors
- Code must be properly formatted (\`cargo fmt\`)
- No clippy warnings (\`cargo clippy -- -D warnings\`)

### Rule 2: Build Success ✅
- Project must build successfully (\`cargo build --all\`)
- WASM contract must build successfully

### Rule 3: Tests Pass ✅
- All existing tests must pass (\`cargo test --all\`)
- **If you added new test files, they must also pass**

---

**Quick Local Check:**
\`\`\`bash
# Run these commands before pushing:
cargo fmt --all
cargo clippy --all -- -D warnings
cargo build --all
cargo test --all
\`\`\`

The CI will automatically check these rules. If any check fails, please fix the issues and push again.`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
47 changes: 35 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pre-commit hooks configuration for StellarAid project
# Optional: Enable pre-commit hooks for automatic code quality checks
# These hooks enforce the 3 CI/CD rules locally before pushing
#
# Installation:
# 1. Install pre-commit: pip install pre-commit
Expand All @@ -11,33 +11,56 @@
repos:
- repo: local
hooks:
# Rule 1: No Errors - Formatting check
- id: rustfmt
name: rustfmt
name: Rule 1 - Code Formatting (rustfmt)
entry: bash -c 'cargo fmt --all -- --check'
language: system
types: [rust]
pass_filenames: false
stages: [commit]

# Rule 1: No Errors - Linting check
- id: clippy
name: clippy
name: Rule 1 - Linting (clippy)
entry: bash -c 'cargo clippy --workspace -- -D warnings'
language: system
types: [rust]
pass_filenames: false
stages: [commit]

- id: cargo-test
name: cargo test
entry: bash -c 'cargo test --workspace'
# Rule 1: No Errors - Compilation check
- id: cargo-check
name: Rule 1 - Compilation Check
entry: bash -c 'cargo check --all --locked'
language: system
types: [rust]
pass_filenames: false
stages: [commit]

# Rule 2: Build Success - Full build
- id: cargo-build
name: Rule 2 - Build Success (cargo build)
entry: bash -c 'cargo build --all --locked'
language: system
types: [rust]
pass_filenames: false
stages: [push]

# Rule 2: Build Success - WASM build
- id: cargo-build-wasm
name: Rule 2 - WASM Build
entry: bash -c 'cargo build -p stellaraid-core --target wasm32-unknown-unknown'
language: system
types: [rust]
pass_filenames: false
stages: [push]

# Alternative: Using rust-toolchain hooks (if preferred)
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.1.0
# hooks:
# - id: ruff
# args: [ --fix ]
# Rule 3: Tests Pass - All tests
- id: cargo-test
name: Rule 3 - All Tests Pass
entry: bash -c 'cargo test --all --locked'
language: system
types: [rust]
pass_filenames: false
stages: [push]
11 changes: 11 additions & 0 deletions Flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

The fee estimation service is fully production-ready:

- ✅ All features implemented
- ✅ Comprehensive error handling
- ✅ Extensive test coverage
- ✅ Full documentation
- ✅ Performance optimized
- ✅ Type safe
- ✅ Memory safe
- ✅ Async-ready
Loading