|
| 1 | +name: examples |
| 2 | + |
| 3 | +# Runs every example end-to-end against the live fc-spawn control plane. |
| 4 | +# Each example is a one-shot `bun index.ts` that creates a sandbox, verifies |
| 5 | +# it, and destroys it in a `finally` block — so a green job means the example |
| 6 | +# worked against production. |
| 7 | +# |
| 8 | +# Cost note: every run spawns real microVMs and makes paid LLM API calls. |
| 9 | +# Triggers are kept deliberate: nightly, manual, and on SDK source changes. |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + schedule: |
| 14 | + - cron: "17 3 * * *" # nightly 03:17 UTC |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - "src/**" |
| 19 | + - ".github/workflows/examples.yml" |
| 20 | + pull_request: |
| 21 | + paths: |
| 22 | + - "src/**" |
| 23 | + - ".github/workflows/examples.yml" |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: examples-${{ github.ref }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: read # checkout only; no write scope needed |
| 31 | + |
| 32 | +jobs: |
| 33 | + # Build the example matrix from the examples/ directory so new examples are |
| 34 | + # picked up automatically — no edits to this file when one is added. |
| 35 | + discover: |
| 36 | + runs-on: arc-runner-set |
| 37 | + outputs: |
| 38 | + examples: ${{ steps.list.outputs.examples }} |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 41 | + - id: list |
| 42 | + run: | |
| 43 | + json=$(cd examples && for d in [0-9]*/; do printf '%s\n' "${d%/}"; done \ |
| 44 | + | grep . | sed 's/.*/"&"/' | paste -sd, -) |
| 45 | + echo "examples=[$json]" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + run: |
| 48 | + needs: discover |
| 49 | + runs-on: arc-runner-set |
| 50 | + timeout-minutes: 20 |
| 51 | + strategy: |
| 52 | + # No max-parallel: GitHub runs as many matrix jobs in parallel as the |
| 53 | + # runner pool allows (unlimited by request). The fc-spawn control plane |
| 54 | + # is the backstop that queues sandbox creation under load. |
| 55 | + fail-fast: false # one failing example must not cancel the others |
| 56 | + matrix: |
| 57 | + example: ${{ fromJson(needs.discover.outputs.examples) }} |
| 58 | + name: ${{ matrix.example }} |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 61 | + |
| 62 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 63 | + with: |
| 64 | + bun-version: latest |
| 65 | + |
| 66 | + # The SDK is consumed by examples via `file:../`, whose `main` points at |
| 67 | + # dist/. Build it before installing/running any example. |
| 68 | + - name: Build SDK |
| 69 | + run: | |
| 70 | + bun install --frozen-lockfile |
| 71 | + bun run build |
| 72 | +
|
| 73 | + - name: Install example dependencies |
| 74 | + working-directory: examples |
| 75 | + run: bun install --frozen-lockfile |
| 76 | + |
| 77 | + - name: Run ${{ matrix.example }} |
| 78 | + working-directory: examples/${{ matrix.example }} |
| 79 | + env: |
| 80 | + # --- fc-spawn control plane (read by the SDK + most examples) --- |
| 81 | + FC_API_KEY: ${{ secrets.FC_API_KEY }} |
| 82 | + FC_BASE_URL: ${{ secrets.FC_BASE_URL }} |
| 83 | + # --- OpenAI / OpenAI-compatible --- |
| 84 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 85 | + OPENAI_API_URL: ${{ secrets.OPENAI_API_URL }} |
| 86 | + OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }} |
| 87 | + OPENAI_MODEL: ${{ secrets.OPENAI_MODEL }} |
| 88 | + # OPENAI_USE_CHAT_COMPLETIONS: ${{ secrets.OPENAI_USE_CHAT_COMPLETIONS }} |
| 89 | + # OPENAI_AGENTS_DISABLE_TRACING: ${{ secrets.OPENAI_AGENTS_DISABLE_TRACING }} |
| 90 | + LLM_MODEL: ${{ secrets.LLM_MODEL }} |
| 91 | + # --- Anthropic --- |
| 92 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 93 | + ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_AUTH_TOKEN }} |
| 94 | + ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }} |
| 95 | + ANTHROPIC_MODEL: ${{ secrets.ANTHROPIC_MODEL }} |
| 96 | + # --- third-party integrations (per-example) --- |
| 97 | + # BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }} |
| 98 | + # BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }} |
| 99 | + # FIRECRAWL_API_KEY: ${{ secrets.FIRECRAWL_API_KEY }} |
| 100 | + # FIRECRAWL_API_URL: ${{ secrets.FIRECRAWL_API_URL }} |
| 101 | + # OPENCLAW_GATEWAY_TOKEN: ${{ secrets.OPENCLAW_GATEWAY_TOKEN }} |
| 102 | + # SCRAPE_URL: ${{ secrets.SCRAPE_URL }} |
| 103 | + run: bun index.ts |
0 commit comments