-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add CI/CD pipeline for Kolo Soroban smart contract #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
399913a
f391cf6
0ac43dd
d504b48
7a202e7
eed2367
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,109 @@ | ||
| name: Rust CI | ||
| name: Kolo Backend CI | ||
|
|
||
| on: [push, pull_request] | ||
| on: | ||
| push: | ||
| branches: [ "main", "develop" ] | ||
| pull_request: | ||
| branches: [ "main", "develop" ] | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| WORKING_DIR: contracts | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| name: Build & Test Soroban Contract | ||
| name: Build & Test | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: contracts | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Rust and wasm32 target | ||
| run: | | ||
| rustup toolchain install stable --profile minimal | ||
| rustup default stable | ||
| rustup target add wasm32-unknown-unknown | ||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: rustfmt, clippy | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Install system dependencies for Soroban CLI | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libdbus-1-dev libudev-dev pkg-config | ||
| - name: Cache Cargo dependencies | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: ${{ env.WORKING_DIR }} | ||
|
|
||
| - name: Check formatting | ||
| run: cargo fmt --all -- --check | ||
|
|
||
| - name: Lint with Clippy | ||
| run: cargo clippy --all-targets --all-features -- -D warnings | ||
|
|
||
| - name: Install Soroban CLI | ||
| run: cargo install --locked soroban-cli | ||
| - name: Build (native) | ||
| run: cargo build | ||
|
|
||
| - name: Run unit tests | ||
| run: cargo test | ||
| - name: Run tests | ||
| run: cargo test --verbose | ||
|
|
||
| - name: Build contract for wasm (release) | ||
| - name: Build WebAssembly (release) | ||
| run: cargo build --target wasm32-unknown-unknown --release | ||
|
|
||
| - name: Upload WASM artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: kolo-savings-group-wasm | ||
| path: ${{ env.WORKING_DIR }}/target/wasm32-unknown-unknown/release/kolo_savings_group.wasm | ||
| retention-days: 14 | ||
|
|
||
| deploy: | ||
| name: Deploy to Testnet | ||
| runs-on: ubuntu-latest | ||
| needs: build-and-test | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ env.WORKING_DIR }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Cache Cargo dependencies | ||
| uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: ${{ env.WORKING_DIR }} | ||
|
|
||
| - name: Install Stellar CLI | ||
| run: | | ||
| mkdir -p "$HOME/.local/bin" | ||
| curl -sSL https://github.com/stellar/soroban-tools/releases/download/v21.2.0/soroban-cli-21.2.0-x86_64-unknown-linux-gnu.tar.gz | tar -xz | ||
| mv soroban "$HOME/.local/bin/soroban" | ||
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | ||
| soroban --version | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Build and optimize WASM | ||
| run: | | ||
| RUSTFLAGS="-C target-cpu=mvp" cargo build \ | ||
| --target wasm32-unknown-unknown \ | ||
| --release | ||
| cargo install wasm-opt --locked | ||
| wasm-opt \ | ||
| target/wasm32-unknown-unknown/release/kolo_savings_group.wasm \ | ||
| -o target/wasm32-unknown-unknown/release/kolo_savings_group.optimized.wasm | ||
|
|
||
| - name: Deploy contract to testnet | ||
| env: | ||
| STELLAR_SOURCE_ACCOUNT: ${{ secrets.STELLAR_DEPLOYER_KEY }} | ||
| run: | | ||
| soroban contract deploy \ | ||
| --wasm target/wasm32-unknown-unknown/release/kolo_savings_group.optimized.wasm \ | ||
| --source-account "$STELLAR_SOURCE_ACCOUNT" \ | ||
| --network testnet | ||
|
Comment on lines
+107
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Secret key is passed as a literal CLI argument.
🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.