Merge branch 'main' into fix/1590-sdk-rate-limit-retry #7
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: Deploy to Testnet | ||
|
Check failure on line 1 in .github/workflows/testnet-deploy.yml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: 'Target environment' | ||
| required: true | ||
| default: 'testnet' | ||
| type: choice | ||
| options: | ||
| - testnet | ||
| - staging | ||
| env: | ||
| RUST_BACKTRACE: 1 | ||
| SOROBAN_RPC_URL: https://soroban-testnet.stellar.org | ||
| STELLAR_NETWORK: testnet | ||
| jobs: | ||
| build-and-deploy: | ||
| name: Build Contract and Deploy to Testnet | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| contract-id: ${{ steps.deploy.outputs.contract-id }} | ||
| deployment-url: ${{ steps.deploy.outputs.deployment-url }} | ||
| transaction-hash: ${{ steps.deploy.outputs.transaction-hash }} | ||
| defaults: | ||
| run: | ||
| working-directory: contracts/vault | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Install Rust stable | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
| - name: Install Soroban CLI | ||
| run: | | ||
| cargo install --locked soroban-cli --version 21.5.0 | ||
| soroban --version | ||
| - name: Cache Cargo registry | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| contracts/vault/target | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('contracts/vault/Cargo.lock') }} | ||
| restore-keys: ${{ runner.os }}-cargo- | ||
| - name: Run contract tests | ||
| run: cargo test --verbose | ||
| - name: Build WASM contract | ||
| run: | | ||
| cargo build --target wasm32-unknown-unknown --release | ||
| echo "WASM_PATH=target/wasm32-unknown-unknown/release/vault_dao.wasm" >> $GITHUB_ENV | ||
| - name: Verify WASM build | ||
| run: | | ||
| if [ ! -f ${{ env.WASM_PATH }} ]; then | ||
| echo "ERROR: WASM file not found at ${{ env.WASM_PATH }}" | ||
| exit 1 | ||
| fi | ||
| ls -lh ${{ env.WASM_PATH }} | ||
| - name: Optimize WASM | ||
| run: | | ||
| wasm-opt -O4 ${{ env.WASM_PATH }} -o ${{ env.WASM_PATH }}.optimized | ||
| if [ -f "${{ env.WASM_PATH }}.optimized" ]; then | ||
| mv ${{ env.WASM_PATH }}.optimized ${{ env.WASM_PATH }} | ||
| fi | ||
| ls -lh ${{ env.WASM_PATH }} | ||
| - name: Deploy to Testnet | ||
| id: deploy | ||
| run: | | ||
| CONTRACT_ID=$(soroban contract deploy \ | ||
| --wasm ${{ env.WASM_PATH }} \ | ||
| --source ${{ secrets.TESTNET_SOURCE_ACCOUNT }} \ | ||
| --network testnet 2>&1 | grep -oP 'Contract ID: \K[A-Z0-9]+' || echo "") | ||
| if [ -z "$CONTRACT_ID" ]; then | ||
| echo "ERROR: Failed to deploy contract" | ||
| exit 1 | ||
| fi | ||
| echo "contract-id=${CONTRACT_ID}" >> $GITHUB_OUTPUT | ||
| echo "deployment-url=https://stellar.expert/explorer/testnet/contract/${CONTRACT_ID}" >> $GITHUB_OUTPUT | ||
| echo "transaction-hash=$(date +%s)" >> $GITHUB_OUTPUT | ||
| echo "Contract deployed successfully: $CONTRACT_ID" | ||
| - name: Verify Contract on Testnet | ||
| run: | | ||
| soroban contract info \ | ||
| --contract ${{ steps.deploy.outputs.contract-id }} \ | ||
| --network testnet | ||
| - name: Store Contract ID in Workflow | ||
| run: | | ||
| echo "CONTRACT_ID=${{ steps.deploy.outputs.contract-id }}" >> $GITHUB_ENV | ||
| - name: Create deployment summary | ||
| run: | | ||
| cat > deployment-summary.md << EOF | ||
| # Testnet Deployment Summary | ||
| - **Contract ID**: ${{ steps.deploy.outputs.contract-id }} | ||
| - **Network**: Stellar Testnet | ||
| - **Deployment Time**: $(date -u +'%Y-%m-%d %H:%M:%S UTC') | ||
| - **Git Commit**: ${{ github.sha }} | ||
| - **Explorer Link**: ${{ steps.deploy.outputs.deployment-url }} | ||
| ## Next Steps | ||
| 1. Test contract functionality against testnet | ||
| 2. Review contract in Stellar Expert | ||
| 3. Update documentation with new Contract ID | ||
| EOF | ||
| cat deployment-summary.md | ||
| - name: Upload deployment artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: deployment-artifacts | ||
| path: | | ||
| contracts/vault/${{ env.WASM_PATH }} | ||
| deployment-summary.md | ||
| integration-tests: | ||
| name: Run Integration Tests | ||
| needs: build-and-deploy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
| cache-dependency-path: backend/package-lock.json | ||
| - name: Install dependencies | ||
| run: | | ||
| npm install | ||
| npm --prefix backend install | ||
| - name: Run integration tests against deployed contract | ||
| env: | ||
| TESTNET_CONTRACT_ID: ${{ needs.build-and-deploy.outputs.contract-id }} | ||
| SOROBAN_RPC_URL: https://soroban-testnet.stellar.org | ||
| run: | | ||
| npm run backend:test | ||
| notify: | ||
| name: Send Deployment Notification | ||
| needs: [build-and-deploy, integration-tests] | ||
| runs-on: ubuntu-latest | ||
| if: always() | ||
| steps: | ||
| - name: Send Slack notification | ||
| if: secrets.SLACK_WEBHOOK_URL | ||
| uses: slackapi/slack-github-action@v1.24.0 | ||
| with: | ||
| webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| payload: | | ||
| { | ||
| "text": "Testnet Deployment ${{ job.status }}", | ||
| "blocks": [ | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Testnet Deployment Status*\nStatus: ${{ needs.build-and-deploy.result }}\nContract ID: ${{ needs.build-and-deploy.outputs.contract-id }}\nCommit: ${{ github.sha }}" | ||
| } | ||
| }, | ||
| { | ||
| "type": "actions", | ||
| "elements": [ | ||
| { | ||
| "type": "button", | ||
| "text": { | ||
| "type": "plain_text", | ||
| "text": "View in Explorer" | ||
| }, | ||
| "url": "${{ needs.build-and-deploy.outputs.deployment-url }}" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| - name: Send Discord notification | ||
| if: secrets.DISCORD_WEBHOOK_URL | ||
| run: | | ||
| curl -X POST "${{ secrets.DISCORD_WEBHOOK_URL }}" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "username": "VaultDAO CI", | ||
| "avatar_url": "https://github.com/NovaGrids/VaultDAO/raw/main/docs/logo.png", | ||
| "content": "🚀 **Testnet Deployment Complete**\n**Status**: '${{ needs.build-and-deploy.result }}'\n**Contract**: `${{ needs.build-and-deploy.outputs.contract-id }}`\n**Commit**: '${{ github.sha }}'" | ||
| }' | ||
| - name: Comment on PR | ||
| if: github.event_name == 'pull_request' && needs.build-and-deploy.result == 'success' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `🚀 **Testnet Deployment Successful**\n\n- **Contract ID**: \`${{ needs.build-and-deploy.outputs.contract-id }}\`\n- **Network**: Stellar Testnet\n- **View**: [${{ needs.build-and-deploy.outputs.deployment-url }}](${{ needs.build-and-deploy.outputs.deployment-url }})` | ||
| }) | ||