Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/deploy-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Deploy to Testnet

on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual deployment'
required: false
default: 'Manual deployment trigger'

jobs:
deploy:
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: Install soroban-cli
run: cargo install --locked soroban-cli --version 22.0.0

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}

- name: Cache target directory
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}

- name: Run tests
run: |
cd contracts/ephemeral_account
cargo test --verbose
cd ../sweep_controller
cargo test --verbose
cd ../reserve_contract
cargo test --verbose

- name: Check format
run: |
cd contracts/ephemeral_account
cargo fmt -- --check
cd ../sweep_controller
cargo fmt -- --check
cd ../reserve_contract
cargo fmt -- --check

- name: Run clippy
run: |
cd contracts/ephemeral_account
cargo clippy -- -D warnings
cd ../sweep_controller
cargo clippy -- -D warnings
cd ../reserve_contract
cargo clippy -- -D warnings

- name: Build all contracts
run: |
cd contracts/ephemeral_account
cargo build --target wasm32-unknown-unknown --release
cd ../sweep_controller
cargo build --target wasm32-unknown-unknown --release
cd ../reserve_contract
cargo build --target wasm32-unknown-unknown --release

- name: Deploy to Stellar Testnet
env:
DEPLOYER_SECRET_KEY: ${{ secrets.TESTNET_DEPLOYER_SECRET_KEY }}
run: |
chmod +x scripts/deploy-testnet.sh
./scripts/deploy-testnet.sh

- name: Upload contract IDs as artifacts
uses: actions/upload-artifact@v4
with:
name: contract-ids
path: deployment-artifacts/contract-ids.txt
retention-days: 90

- name: Post deployment summary
run: |
echo "## 🚀 Testnet Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Contracts have been successfully deployed to Stellar Testnet!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Contract IDs" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat deployment-artifacts/contract-ids.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

jobs:
test:
name: Test Contracts
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -45,16 +46,28 @@ jobs:
run: |
cd contracts/ephemeral_account
cargo test --verbose
cd ../sweep_controller
cargo test --verbose
cd ../reserve_contract
cargo test --verbose

- name: Check format
run: |
cd contracts/ephemeral_account
cargo fmt -- --check
cd ../sweep_controller
cargo fmt -- --check
cd ../reserve_contract
cargo fmt -- --check

- name: Run clippy
run: |
cd contracts/ephemeral_account
cargo clippy -- -D warnings
cd ../sweep_controller
cargo clippy -- -D warnings
cd ../reserve_contract
cargo clippy -- -D warnings

- name: Build all contracts
run: |
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@ cargo test --test integration
./scripts/test-local.sh
```

## CI/CD

### Automated Testing
- **Test Workflow** (`.github/workflows/test.yml`): Runs on every push to `main`/`develop` and on PRs to `main`
- Runs cargo tests for all contracts
- Checks code formatting with `cargo fmt`
- Runs clippy for linting
- Builds all contracts for wasm32-unknown-unknown target
- Uploads WASM artifacts for deployment

### Automated Testnet Deployment
- **Deploy Workflow** (`.github/workflows/deploy-testnet.yml`): Automatically deploys to Stellar Testnet on merge to `main`
- Runs tests, format checks, clippy, and builds before deployment
- Deploys all three contracts: `ephemeral_account`, `sweep_controller`, `reserve_contract`
- Stores contract IDs as CI artifacts (90-day retention)
- Posts deployment summary with contract IDs to GitHub Actions summary
- Can also be triggered manually via `workflow_dispatch`

#### Required GitHub Secrets
To enable automated deployments, add the following secret to your GitHub repository:
- `TESTNET_DEPLOYER_SECRET_KEY`: Stellar testnet deployer secret key (S... format)

#### Manual Deployment
To trigger a manual deployment:
1. Go to Actions tab in GitHub
2. Select "Deploy to Testnet" workflow
3. Click "Run workflow"
4. Optionally provide a reason for the deployment

## Contract Interfaces

### EphemeralAccount
Expand Down
2 changes: 1 addition & 1 deletion contracts/reserve_contract/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum DataKey {
/// # Arguments
/// * `env` – Soroban environment handle.
/// * `amount` – Base reserve in stroops. Must already be validated as
/// positive by the caller.
/// positive by the caller.
pub fn set_base_reserve(env: &Env, amount: i128) {
env.storage().instance().set(&DataKey::BaseReserve, &amount);
}
Expand Down
Loading
Loading