Skip to content

comprehensive cross-chain bridge protocol #50

comprehensive cross-chain bridge protocol

comprehensive cross-chain bridge protocol #50

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-contract
run: cargo install cargo-contract --locked
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run unit tests
run: cargo test --all-features
- name: Run PropertyRegistry unit tests
working-directory: contracts/lib
run: cargo test --lib
- name: Run PropertyToken unit tests
working-directory: contracts/property-token
run: cargo test --lib
- name: Run Bridge unit tests
working-directory: contracts/bridge
run: cargo test --lib
- name: Run integration tests
run: cargo test --test integration_property_token --test integration_tests --test property_registry_tests --test property_token_tests
- name: Build contracts
run: |
cd contracts
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
cd "$dir"
cargo contract build
cd ..
fi
done
- name: Run contract tests
run: |
cd contracts
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
cd "$dir"
cargo contract test
cd ..
fi
done
bridge-specific-tests:
name: Bridge Integration Tests
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-contract
run: cargo install cargo-contract --locked
- name: Run bridge-specific integration tests
run: |
cargo test --test integration_property_token test_bridge_multisig_workflow
cargo test --test integration_property_token test_bridge_gas_estimation
cargo test --test integration_property_token test_bridge_recovery_mechanisms
cargo test --test integration_property_token test_bridge_configuration_management
cargo test --test integration_property_token test_bridge_operator_management
cargo test --test integration_property_token test_bridge_transaction_verification
cargo test --test integration_property_token test_cross_chain_metadata_preservation
cargo test --test integration_property_token test_bridge_error_handling
cargo test --test integration_property_token test_bridge_history_tracking
- name: Build bridge contracts
working-directory: contracts/bridge
run: cargo contract build --release
- name: Verify bridge contract size
working-directory: contracts/bridge
run: |
CONTRACT_SIZE=$(wc -c < target/ink/propchain_bridge.contract)
MAX_SIZE=$((1024 * 1024)) # 1MB limit
if [ $CONTRACT_SIZE -gt $MAX_SIZE ]; then
echo "Contract size $CONTRACT_SIZE exceeds limit $MAX_SIZE"
exit 1
fi
echo "Contract size: $CONTRACT_SIZE bytes (within limit)"
security:
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
- name: Run cargo-deny
uses: EmbarkStudios/cargo-deny-action@v1
- name: Check for security vulnerabilities in dependencies
working-directory: contracts/bridge
run: cargo audit
- name: Check for security vulnerabilities in property-token
working-directory: contracts/property-token
run: cargo audit
build:
name: Build Release
runs-on: ubuntu-latest
needs: [test, bridge-specific-tests, security]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-contract
run: cargo install cargo-contract --locked
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Build contracts in release mode
run: |
cd contracts
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
cd "$dir"
cargo contract build --release
cd ..
fi
done
- name: Verify all contracts built successfully
run: |
cd contracts
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
if [ ! -f "$dir/target/ink/${dir%?}.contract" ]; then
echo "Contract $dir failed to build"
exit 1
fi
fi
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: contracts
path: |
contracts/*/target/ink/*.contract
contracts/*/target/ink/*.wasm
deploy-testnet:
name: Deploy to Testnet
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
environment: testnet
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
- name: Install cargo-contract
run: cargo install cargo-contract --locked
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: contracts
path: artifacts/
- name: Deploy to Westend testnet
env:
SURI: ${{ secrets.WESTEND_SURI }}
run: |
./scripts/deploy.sh --network westend
continue-on-error: true
docs:
name: Documentation
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: Generate documentation
run: cargo doc --all-features --no-deps
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: target/doc
pr-validation:
name: PR Validation
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: [test, bridge-specific-tests, security]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for required documentation
run: |
# Check if bridge documentation exists
if ! grep -q "Cross-chain bridge protocol" README.md; then
echo "Bridge protocol documentation missing from README.md"
exit 1
fi
# Check if bridge tests exist
if ! find tests/ -name "*bridge*" -type f | grep -q .; then
echo "Bridge integration tests missing"
exit 1
fi
- name: Verify bridge module structure
run: |
if [ ! -d "contracts/bridge" ]; then
echo "Bridge module directory missing"
exit 1
fi
if [ ! -f "contracts/bridge/Cargo.toml" ]; then
echo "Bridge Cargo.toml missing"
exit 1
fi
if [ ! -f "contracts/bridge/src/lib.rs" ]; then
echo "Bridge lib.rs missing"
exit 1
fi
- name: Check workspace configuration
run: |
if ! grep -q "contracts/bridge" Cargo.toml; then
echo "Bridge module not included in workspace"
exit 1
fi