Fix: Facilitator should validate user balance before sending settlement transaction #532
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
| name: Build and Test | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| # Cancel in-progress runs for the same branch and workflow | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Path filter job to detect what changed | |
| changes: | |
| name: Detect changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| contracts: ${{ steps.filter.outputs.contracts }} | |
| packages: ${{ steps.filter.outputs.packages }} | |
| examples: ${{ steps.filter.outputs.examples }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| contracts: | |
| - 'contracts/**' | |
| packages: | |
| - 'typescript/packages/**' | |
| - 'facilitator/**' | |
| examples: | |
| - 'examples/**' | |
| - 'typescript/packages/**' # Examples depend on packages | |
| # Contract build, test, and coverage job | |
| contracts: | |
| name: Contracts | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: needs.changes.outputs.contracts == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: nightly | |
| - name: Build contracts | |
| working-directory: contracts | |
| run: forge build | |
| - name: Run contract tests | |
| working-directory: contracts | |
| run: forge test -vv | |
| - name: Generate contract coverage | |
| # Only run coverage on main branch | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| working-directory: contracts | |
| run: forge coverage --report lcov --ir-minimum | |
| continue-on-error: true | |
| - name: Upload contract coverage | |
| # Only upload coverage on main branch | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./contracts/lcov.info | |
| flags: contracts | |
| fail_ci_if_error: false | |
| # SDK and facilitator build and test job | |
| packages: | |
| name: Packages | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: needs.changes.outputs.packages == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.7.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| - name: Build x402x SDK | |
| run: pnpm run build:sdk | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| - name: Run tests (unit tests only) | |
| run: pnpm -r --filter "@x402x/*" test | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| SKIP_E2E: "true" | |
| # Temporarily skip E2E tests via SKIP_E2E env var | |
| # E2E tests will be re-enabled in a follow-up PR | |
| - name: Run tests with coverage (unit tests only) | |
| # Only run coverage on main branch | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| run: pnpm -r --filter "@x402x/*" test:coverage | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| SKIP_E2E: "true" | |
| # Temporarily skip E2E tests via SKIP_E2E env var | |
| # E2E tests will be re-enabled in a follow-up PR | |
| - name: Upload coverage reports | |
| # Only upload coverage on main branch | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: | | |
| ./typescript/packages/core/coverage/coverage-final.json | |
| ./typescript/packages/express/coverage/coverage-final.json | |
| ./typescript/packages/fetch/coverage/coverage-final.json | |
| ./typescript/packages/hono/coverage/coverage-final.json | |
| ./typescript/packages/react/coverage/coverage-final.json | |
| ./facilitator/coverage/coverage-final.json | |
| fail_ci_if_error: false | |
| # Examples build job | |
| examples: | |
| name: Examples | |
| runs-on: ubuntu-latest | |
| needs: [changes, packages] | |
| if: always() && needs.changes.outputs.examples == 'true' && (needs.packages.result == 'success' || needs.packages.result == 'skipped') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.7.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| - name: Build x402x SDK | |
| run: pnpm run build:sdk | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| - name: Build all examples | |
| run: pnpm run build:examples | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 |