Skip to content

feat:(PRO-144) Add getPaymentInstruction SDK method #155

feat:(PRO-144) Add getPaymentInstruction SDK method

feat:(PRO-144) Add getPaymentInstruction SDK method #155

Workflow file for this run

name: Rust CI
on:
push:
branches: [main, "release/*"]
paths:
- "crates/**"
- "Cargo.*"
- "Makefile"
- ".github/workflows/rust.yml"
pull_request:
branches: [main, "release/*"]
paths:
- "crates/**"
- "Cargo.*"
- "Makefile"
- ".github/workflows/rust.yml"
env:
CARGO_TERM_COLOR: always
RUST_LOG: info
jobs:
test:
name: Rust Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy, llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: make check
- name: Run clippy
run: make lint
- name: Run tests
run: make test
- name: Build
run: make build
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: test
timeout-minutes: 30
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Setup Solana CLI
uses: ./.github/actions/setup-solana
- name: Setup Solana test validator
uses: ./.github/actions/setup-solana-validator
- name: Install cargo-llvm-cov for coverage
run: cargo install cargo-llvm-cov
- name: Initialize coverage
run: |
echo "🧪 Initializing coverage instrumentation..."
cargo llvm-cov clean --workspace
- name: Setup test environment
run: |
echo "🔧 Setting up test environment..."
# Create second signer key for multi-signer tests
if [ ! -f "tests/src/common/local-keys/signer2-local.json" ]; then
echo "Creating second signer key..."
solana-keygen new --outfile tests/src/common/local-keys/signer2-local.json --no-bip39-passphrase --silent
fi
cargo run -p tests --bin setup_test_env
- name: Setup Kora RPC server (regular config)
uses: ./.github/actions/setup-kora-rpc
with:
config-file: "tests/src/common/fixtures/kora-test.toml"
- name: Run all tests with coverage
run: |
echo "🧪 Running regular integration tests..."
cargo llvm-cov test --no-report -p tests --test integration
- name: Stop Kora RPC server
run: |
if [ ! -z "$KORA_PID" ]; then
kill $KORA_PID || true
fi
sleep 2
- name: Setup Kora RPC server (auth config)
uses: ./.github/actions/setup-kora-rpc
with:
config-file: "tests/src/common/fixtures/auth-test.toml"
- name: Run auth integration tests with coverage
run: |
echo "🧪 Running auth integration tests..."
cargo llvm-cov test --no-report -p tests --test auth
- name: Stop Kora RPC server
run: |
if [ ! -z "$KORA_PID" ]; then
kill $KORA_PID || true
fi
sleep 2
- name: Setup Kora RPC server (payment address config)
uses: ./.github/actions/setup-kora-rpc
with:
config-file: "tests/src/common/fixtures/paymaster-address-test.toml"
initialize-atas: "true"
- name: Run payment address integration tests with coverage
run: |
echo "🧪 Running payment address integration tests..."
cargo llvm-cov test --no-report -p tests --test payment-address
- name: Stop Kora RPC server
run: |
if [ ! -z "$KORA_PID" ]; then
kill $KORA_PID || true
fi
sleep 2
- name: Setup multi-signer test environment
run: |
echo "🔧 Setting up multi-signer test environment..."
export KORA_PRIVATE_KEY="$(cat tests/src/common/local-keys/fee-payer-local.json)"
export KORA_PRIVATE_KEY_2="$(cat tests/src/common/local-keys/signer2-local.json)"
cargo run -p tests --bin setup_test_env
- name: Setup Kora RPC server (multi-signer config)
uses: ./.github/actions/setup-kora-rpc
with:
config-file: "tests/src/common/fixtures/kora-test.toml"
signers-config: "tests/src/common/fixtures/multi-signers.toml"
- name: Run multi-signer integration tests with coverage
run: |
echo "🧪 Running multi-signer integration tests..."
cargo llvm-cov test --no-report -p tests --test multi-signers
- name: Generate coverage reports
run: |
echo "📊 Generating coverage reports..."
mkdir -p coverage
cargo llvm-cov report --lcov --output-path coverage/lcov.info
cargo llvm-cov report --html --output-dir coverage/html
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: rust-coverage-report
path: coverage/
retention-days: 30
- name: Post coverage comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
// Extract coverage percentage from lcov.info
const fs = require('fs');
let coverage = '0';
try {
const lcov = fs.readFileSync('coverage/lcov.info', 'utf8');
const linesFound = lcov.match(/^LF:(\d+)$/gm)?.reduce((sum, line) => sum + parseInt(line.split(':')[1]), 0) || 0;
const linesHit = lcov.match(/^LH:(\d+)$/gm)?.reduce((sum, line) => sum + parseInt(line.split(':')[1]), 0) || 0;
coverage = linesFound > 0 ? ((linesHit / linesFound) * 100).toFixed(1) : '0';
} catch (error) {
console.log('Error reading coverage:', error);
}
const comment = `## 📊 Rust Coverage Report
**Coverage:** ${coverage}%
<details>
<summary>View detailed report</summary>
Coverage artifacts have been uploaded to this workflow run.
[View Artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
</details>`;
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('## 📊 Rust Coverage Report')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}
- name: Cleanup test environment
uses: ./.github/actions/cleanup-test-env
- name: Show failure logs
uses: ./.github/actions/show-failure-logs
with:
test-type: "Rust integration"