feat: Institutional Reliability and Governance Suite (#97, #98, #99, #100) #71
Workflow file for this run
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: Smart Contract Tests | |
| on: | |
| push: | |
| branches: [ "main", "develop", "feature/*" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| jobs: | |
| smart-contract-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| override: true | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| contracts/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install Soroban CLI | |
| run: | | |
| curl -L https://github.com/stellar/soroban/releases/latest/download/soroban-cli-linux-x86_64.tar.gz | tar xz | |
| sudo mv soroban /usr/local/bin/ | |
| - name: Build smart contracts | |
| run: | | |
| cd contracts | |
| cargo build --target wasm32-unknown-unknown --release | |
| - name: Run smart contract tests | |
| run: | | |
| cd contracts | |
| cargo test --workspace | |
| - name: Run reentrancy tests specifically | |
| run: | | |
| cd contracts/reentrancy-tests | |
| cargo test -- --nocapture | |
| - name: Verify contract examples | |
| run: | | |
| cd contracts | |
| for contract in vesting-vault malicious-contract reentrancy-tests; do | |
| echo "Testing $contract contract..." | |
| cd $contract | |
| cargo test | |
| cd .. | |
| done | |
| backend-tests: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_USER: postgres | |
| POSTGRES_DB: vesting_vault_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./backend | |
| run: npm ci | |
| - name: Create environment file | |
| working-directory: ./backend | |
| run: cp .env.example .env | |
| - name: Create data directory | |
| working-directory: ./backend | |
| run: mkdir -p data | |
| - name: Run backend tests | |
| working-directory: ./backend | |
| run: npm test | |
| - name: Generate coverage report | |
| working-directory: ./backend | |
| run: npm run test:coverage | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| needs: [smart-contract-tests, backend-tests] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| override: true | |
| - name: Install dependencies | |
| working-directory: ./backend | |
| run: | | |
| npm ci | |
| curl -L https://github.com/stellar/soroban/releases/latest/download/soroban-cli-linux-x86_64.tar.gz | tar xz | |
| sudo mv soroban /usr/local/bin/ | |
| - name: Build contracts | |
| run: | | |
| cd contracts | |
| cargo build --target wasm32-unknown-unknown --release | |
| - name: Start backend server | |
| working-directory: ./backend | |
| run: | | |
| cp .env.example .env | |
| mkdir -p data | |
| export NODE_ENV=test | |
| export DB_HOST=localhost | |
| export DB_PORT=5432 | |
| export DB_NAME=vesting_vault_test | |
| export DB_USER=postgres | |
| export DB_PASSWORD=password | |
| npm start & | |
| sleep 15 | |
| - name: Run integration tests | |
| run: | | |
| echo "Testing backend API with smart contracts..." | |
| curl -f http://localhost:4000/ || exit 1 | |
| curl -f http://localhost:4000/api/audit/verify || exit 1 | |
| - name: Test reentrancy protection | |
| run: | | |
| cd contracts/reentrancy-tests | |
| cargo test test_comprehensive_reentrancy_protection -- --nocapture |