Merge pull request #1316 from christabel888/issue-972-myfans-lib-prim… #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| 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 | |
| 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 the contract compiles correctly for deployment to Soroban. | |
| - name: Build wasm release for earnings contract | |
| run: cargo build --release --target wasm32-unknown-unknown -p earnings | |
| working-directory: contract | |
| - name: Verify earnings.wasm artifact exists | |
| run: test -f target/wasm32-unknown-unknown/release/earnings.wasm | |
| working-directory: contract | |
| # Verifies the test-consumer WASM builds cleanly — cargo test uses the host target and does not catch wasm-only build errors. | |
| - name: Build wasm release for test-consumer contract | |
| run: cargo build --release --target wasm32-unknown-unknown -p test-consumer | |
| working-directory: contract | |
| - name: Verify test-consumer.wasm artifact exists | |
| run: test -f target/wasm32-unknown-unknown/release/test_consumer.wasm | |
| working-directory: contract | |
| - name: Verify creator-registry wasm | |
| run: | | |
| wasm_path="target/wasm32-unknown-unknown/release/creator_registry.wasm" | |
| test -s "$wasm_path" | |
| magic="$(xxd -p -l 4 "$wasm_path" 2>/dev/null || od -A n -N 4 -t x1 "$wasm_path" | tr -d ' ')" | |
| test "$magic" = "0061736d" | |
| working-directory: contract | |
| - name: Build wasm release for myfans-lib | |
| run: cargo build --release --target wasm32-unknown-unknown -p myfans-lib | |
| working-directory: contract | |
| - name: Verify myfans_lib.wasm artifact exists | |
| run: test -f target/wasm32-unknown-unknown/release/myfans_lib.wasm | |
| working-directory: contract | |
| - name: Verify myfans_lib wasm | |
| run: | | |
| wasm_path="target/wasm32-unknown-unknown/release/myfans_lib.wasm" | |
| test -s "$wasm_path" | |
| magic="$(xxd -p -l 4 "$wasm_path" 2>/dev/null || od -A n -N 4 -t x1 "$wasm_path" | tr -d ' ')" | |
| test "$magic" = "0061736d" | |
| working-directory: contract |