Merge pull request #829 from Samuel1-ona/fix/issues-705-707-719-723 #262
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: Rust + WASM CI | |
| on: | |
| pull_request: | |
| paths: | |
| - "contracts/**" | |
| - "backend/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "contracts/**" | |
| - "backend/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| jobs: | |
| rust-test: | |
| name: Rust unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: clippy | |
| profile: minimal | |
| override: true | |
| - name: Cache Cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run cargo fmt check | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Run tests | |
| run: cargo test --all-features --workspace --locked --quiet | |
| working-directory: ./contracts | |
| env: | |
| PROPTEST_CASES: "10000" | |
| wasm-build: | |
| name: Build WASM artifacts | |
| runs-on: ubuntu-latest | |
| needs: rust-test | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Add WASM target | |
| run: rustup target add wasm32-unknown-unknown | |
| - name: Build all contract crates to WASM | |
| run: | | |
| cd contracts | |
| cargo build --all --target wasm32-unknown-unknown --release | |
| - name: Collect built WASM | |
| run: | | |
| mkdir -p artifacts/wasm | |
| find ./target/wasm32-unknown-unknown/release -name '*.wasm' -exec cp {} artifacts/wasm/ \; | |
| - name: Upload WASM artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-artifacts | |
| path: artifacts/wasm | |
| testnet-deploy: | |
| name: Testnet deploy & smoke test | |
| runs-on: ubuntu-latest | |
| needs: wasm-build | |
| # Only run on push to main — not on pull requests | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download WASM artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wasm-artifacts | |
| path: artifacts/wasm | |
| - name: Verify vault WASM is present | |
| run: ls -la artifacts/wasm/ | |
| - name: Install Stellar CLI | |
| uses: stellar/stellar-cli@v23.0.1 | |
| - name: Deploy contract and run smoke test | |
| env: | |
| TESTNET_SECRET_KEY: ${{ secrets.TESTNET_SECRET_KEY }} | |
| TESTNET_TOKEN_ADDRESS: ${{ secrets.TESTNET_TOKEN_ADDRESS }} | |
| GIT_SHA: ${{ github.sha }} | |
| run: bash contracts/vault/scripts/smoke-test.sh | |
| - name: Upload deployment artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: testnet-deployment | |
| path: deployment.json | |
| retention-days: 7 |