Skip to content
Merged
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
103 changes: 91 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,116 @@
name: Rust CI
name: Kolo Backend CI

on: [push, pull_request]
permissions:
contents: read

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]

env:
CARGO_TERM_COLOR: always
WORKING_DIR: contracts

jobs:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
targets: wasm32-unknown-unknown
- name: Install Rust and wasm32 target
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add wasm32v1-none

- 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: Build (native)
run: cargo build

- name: Run tests
run: cargo test --verbose

- 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 Soroban CLI
run: cargo install --locked soroban-cli
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Run unit tests
run: cargo test
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.WORKING_DIR }}

- name: Install Stellar CLI
run: |
cargo install stellar-cli --locked
stellar --version

- 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: |
stellar 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

--source-account "$STELLAR_SOURCE_ACCOUNT" expands the raw deployer secret key directly into the soroban process's command-line arguments, which are visible to any other process on the runner via /proc/<pid>/cmdline or ps for the process lifetime. Prefer importing the key into a local identity (soroban keys add ... --secret-key, reading the secret from stdin/env inside that command) and referencing the identity alias with --source instead of interpolating the raw secret onto the command line.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/rust.yml around lines 102 - 109, Update the “Deploy
contract to testnet” step so the deployer secret is imported into a local
Soroban identity using soroban keys add with secret input supplied via stdin or
the environment, then invoke soroban contract deploy with the identity alias
through --source rather than passing the raw key via --source-account.

- name: Build contract for wasm (release)
run: cargo build --target wasm32v1-none --release
Loading