chore: fix .gitignore and add frontend source files #362
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: Comprehensive Test Suite | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| # Enforced by cargo llvm-cov --fail-under-lines (line %, package-scoped runs). | |
| COVERAGE_FAIL_LINES_PREDICT_IQ: "80" | |
| COVERAGE_FAIL_LINES_PREDICTIQ_API: "17" | |
| jobs: | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v3 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install Soroban CLI | |
| run: | | |
| cargo install --locked soroban-cli --features opt | |
| - name: Run unit tests | |
| run: cargo test --lib --workspace | |
| working-directory: contracts/predict-iq | |
| - name: Run module tests | |
| run: cargo test --lib --features testutils | |
| working-directory: contracts/predict-iq | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli --features opt | |
| - name: Run integration tests | |
| run: cargo test --test '*' --workspace | |
| working-directory: contracts/predict-iq | |
| gas-benchmarks: | |
| name: Gas Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli --features opt | |
| - name: Run gas benchmarks | |
| run: cargo test --benches --features testutils | |
| working-directory: contracts/predict-iq | |
| - name: Check benchmark results | |
| run: | | |
| echo "Benchmark results:" | |
| cat target/criterion/*/report/index.html || echo "No criterion reports found" | |
| backend-coverage: | |
| name: Backend coverage (contracts + API) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| components: llvm-tools-preview | |
| - name: Install cargo-llvm-cov | |
| run: cargo install cargo-llvm-cov --locked | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli --features opt | |
| - name: Prepare coverage output directory | |
| run: mkdir -p coverage-reports | |
| - name: Coverage gate — predict-iq (Soroban contract) | |
| env: | |
| CARGO_LLVM_COV_TARGET_DIR: ${{ github.workspace }}/llvm-cov-target/predict-iq | |
| run: > | |
| cargo llvm-cov -p predict-iq --all-features | |
| --fail-under-lines ${COVERAGE_FAIL_LINES_PREDICT_IQ} | |
| --lcov --output-path coverage-reports/predict-iq.lcov | |
| --html --output-dir coverage-reports/predict-iq-html | |
| - name: Coverage gate — predictiq-api (Rust API service) | |
| env: | |
| CARGO_LLVM_COV_TARGET_DIR: ${{ github.workspace }}/llvm-cov-target/predictiq-api | |
| working-directory: services/api | |
| run: > | |
| cargo llvm-cov | |
| --fail-under-lines ${COVERAGE_FAIL_LINES_PREDICTIQ_API} | |
| --lcov --output-path ../../coverage-reports/predictiq-api.lcov | |
| --html --output-dir ../../coverage-reports/predictiq-api-html | |
| - name: Upload HTML + LCOV artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-coverage | |
| path: | | |
| coverage-reports/*.lcov | |
| coverage-reports/predict-iq-html | |
| coverage-reports/predictiq-api-html | |
| if-no-files-found: error | |
| - name: Upload predict-iq LCOV to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage-reports/predict-iq.lcov | |
| flags: predict-iq | |
| fail_ci_if_error: true | |
| verbose: true | |
| - name: Upload predictiq-api LCOV to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage-reports/predictiq-api.lcov | |
| flags: predictiq-api | |
| fail_ci_if_error: true | |
| verbose: true | |
| security-audit: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Install cargo-audit | |
| run: cargo install cargo-audit | |
| - name: Run security audit | |
| run: cargo audit | |
| working-directory: contracts/predict-iq | |
| clippy: | |
| name: Clippy Lints | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| components: clippy | |
| - name: Run Clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| working-directory: contracts/predict-iq | |
| oracle-quality-gate: | |
| name: Oracle Module — Clippy + Warnings-as-Errors | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| components: clippy | |
| - name: Clippy (deny warnings) — oracle module | |
| env: | |
| RUSTFLAGS: -D warnings | |
| run: > | |
| cargo clippy | |
| --package predict-iq | |
| --all-features | |
| -- -D warnings | |
| working-directory: contracts/predict-iq | |
| - name: Build (deny warnings) — contract crate | |
| env: | |
| RUSTFLAGS: -D warnings | |
| run: cargo build --package predict-iq --all-features | |
| working-directory: contracts/predict-iq | |
| - name: Run oracle tests | |
| run: cargo test --package predict-iq --lib oracles | |
| working-directory: contracts/predict-iq | |
| format: | |
| name: Code Formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| components: rustfmt | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| working-directory: contracts/predict-iq | |
| build-optimized: | |
| name: Build Optimized Contract | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| target: wasm32-unknown-unknown | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli --features opt | |
| - name: Build optimized WASM | |
| run: cargo build --target wasm32-unknown-unknown --release | |
| working-directory: contracts/predict-iq | |
| - name: Optimize WASM | |
| run: | | |
| soroban contract optimize \ | |
| --wasm target/wasm32-unknown-unknown/release/predict_iq.wasm \ | |
| --wasm-out target/wasm32-unknown-unknown/release/predict_iq_optimized.wasm | |
| working-directory: contracts/predict-iq | |
| - name: Check WASM size | |
| run: | | |
| size=$(stat -f%z target/wasm32-unknown-unknown/release/predict_iq_optimized.wasm 2>/dev/null || stat -c%s target/wasm32-unknown-unknown/release/predict_iq_optimized.wasm) | |
| echo "Optimized WASM size: $size bytes" | |
| max_size=65536 # 64KB limit | |
| if [ $size -gt $max_size ]; then | |
| echo "WASM size $size exceeds limit of $max_size bytes" | |
| exit 1 | |
| fi | |
| working-directory: contracts/predict-iq | |
| all-tests-passed: | |
| name: All Tests Passed | |
| needs: | |
| - unit-tests | |
| - integration-tests | |
| - gas-benchmarks | |
| - backend-coverage | |
| - security-audit | |
| - clippy | |
| - oracle-quality-gate | |
| - format | |
| - build-optimized | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Success | |
| run: echo "All tests passed successfully!" |