Skip to content

Merge pull request #1527 from Emeka000/datasource #2

Merge pull request #1527 from Emeka000/datasource

Merge pull request #1527 from Emeka000/datasource #2

Workflow file for this run

# Three required checks: Backend, Frontend, Contract.
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: myfans_ci
POSTGRES_PASSWORD: myfans_ci
POSTGRES_DB: myfans_test
ports:
- 5432:5432
options: >
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: myfans_ci
DB_PASSWORD: myfans_ci
DB_NAME: myfans_test
JWT_SECRET: ci-test-secret-not-for-production
WEBHOOK_SECRET: ci-webhook-secret-not-for-production
NODE_ENV: test
STELLAR_NETWORK: testnet
SOROBAN_RPC_URL: https://soroban-testnet.stellar.org
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: npm
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: backend
- name: Run tests
run: npm test
working-directory: backend
- name: Build
run: npm run build
working-directory: backend
backend-e2e:
name: Backend E2E
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: myfans_ci
POSTGRES_PASSWORD: myfans_ci
POSTGRES_DB: myfans_test
ports:
- 5432:5432
options: >
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: myfans_ci
DB_PASSWORD: myfans_ci
DB_NAME: myfans_test
JWT_SECRET: ci-test-secret-not-for-production
WEBHOOK_SECRET: ci-webhook-secret-not-for-production
NODE_ENV: test
STELLAR_NETWORK: testnet
SOROBAN_RPC_URL: https://soroban-testnet.stellar.org
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: npm
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: backend
- name: Run e2e suite
run: npm run test:e2e
working-directory: backend
frontend:
name: Frontend
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20'
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: frontend
- name: Build
run: npm run build
working-directory: frontend
contract:
name: Contract
runs-on: ubuntu-latest
timeout-minutes: 30
env:
# Production contracts that must build to wasm32-unknown-unknown.
# Mirrors contract/scripts/snapshot-abi.sh PACKAGES.
PROD_PACKAGES: >-
myfans-token
creator-registry
creator-deposits
creator-earnings
subscription
content-access
content-likes
earnings
treasury
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
workspaces: contract -> target
- name: Check formatting
run: cargo fmt --all --check
working-directory: contract
- name: Run tests
run: cargo test
working-directory: contract
# Verify wasm release build independently from cargo test, which uses the host target.
# cargo test compiles for the native architecture, while the wasm build targets wasm32-unknown-unknown.
# This step ensures all production contracts compile correctly for deployment to Soroban.
# Package list mirrors contract/scripts/snapshot-abi.sh PACKAGES.
- name: Build all production contracts to wasm
run: |
for pkg in $PROD_PACKAGES; do
echo "::group::Building $pkg"
cargo build --release --target wasm32-unknown-unknown -p "$pkg"
echo "::endgroup::"
done
working-directory: contract
- name: Verify WASM artifacts (magic bytes + non-empty)
run: |
FAILED=0
for pkg in $PROD_PACKAGES; do
wasm_name="${pkg//-/_}.wasm"
wasm_path="target/wasm32-unknown-unknown/release/$wasm_name"
echo "::group::Verifying $pkg → $wasm_name"
if [[ ! -s "$wasm_path" ]]; then
echo "::error::WASM artifact not found or empty: $wasm_path"
FAILED=1
echo "::endgroup::"
continue
fi
magic="$(xxd -p -l 4 "$wasm_path" 2>/dev/null || od -A n -N 4 -t x1 "$wasm_path" | tr -d ' ')"
if [[ "$magic" != "0061736d" ]]; then
echo "::error::Invalid WASM magic bytes for $wasm_path (got: $magic)"
FAILED=1
else
echo "✅ $pkg verified ($wasm_name, $(du -h "$wasm_path" | cut -f1))"
fi
echo "::endgroup::"
done
if [[ "$FAILED" -ne 0 ]]; then
echo "::error::One or more WASM artifacts failed verification"
exit 1
fi
echo "::notice::All production WASM artifacts verified successfully"
working-directory: contract