Skip to content
Latchkey

Test Platforms workflow (VRSEN/OpenSwarm)

The Test Platforms workflow from VRSEN/OpenSwarm, explained and optimized by Latchkey.

D

CI health: D - needs work

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: VRSEN/OpenSwarm.github/workflows/test-mac.ymlLicense MITView source

What it does

This is the Test Platforms workflow from the VRSEN/OpenSwarm repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Test Platforms
on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/build-tui.yml'
      - '.github/workflows/test-mac.yml'
      - 'bin/openswarm'
      - 'openswarm.config.mjs'
      - 'openswarm.marketplace.json'
      - 'package.json'
      - 'package-lock.json'
      - 'run_utils.py'
      - 'scripts/extract-agentswarm-binaries.mjs'
      - 'scripts/platform-assets.mjs'
      - 'scripts/smoke-bootstrap.py'
      - 'scripts/smoke-openswarm-launcher.js'
      - 'scripts/smoke-wheel-bootstrap.py'
      - 'scripts/package-platform-binaries.mjs'
      - 'scripts/write-product-env.mjs'

jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: Smoke-test launcher platform resolution
        run: node scripts/smoke-openswarm-launcher.js
      - name: Load OpenSwarm product env
        run: node -e "const fs=require('fs');const cp=require('child_process');fs.appendFileSync(process.env.GITHUB_ENV,cp.execFileSync(process.execPath,['scripts/write-product-env.mjs'],{encoding:'utf8'}));"
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install Python package dependencies
        run: python -m pip install -e .
      - name: Smoke-test Python bootstrap fallback
        shell: bash
        run: |
          set -euo pipefail
          python -m py_compile run_utils.py scripts/smoke-bootstrap.py scripts/smoke-wheel-bootstrap.py
          python scripts/smoke-bootstrap.py
          python scripts/smoke-wheel-bootstrap.py
      - name: Extract pinned AgentSwarm macOS TUI binary
        shell: bash
        run: |
          set -euo pipefail
          version="$(node -p "require('./package.json').dependencies['@vrsen/agentswarm']")"
          node scripts/extract-agentswarm-binaries.mjs "$version" dist agentswarm-darwin-arm64
          test "$(./dist/agentswarm-darwin-arm64 --version)" = "$version"
      - name: Test startup
        shell: bash
        run: |
          python - <<'EOF'
          import os
          import pathlib
          import subprocess
          import sys
          import tempfile

          def run_version(binary, cwd, env):
              return subprocess.run(
                  [str(binary), "--version"],
                  cwd=cwd,
                  capture_output=True,
                  text=True,
                  env=env,
                  timeout=120,
              )

          def resolve_launcher(root):
              candidates = [
                  root / "node_modules" / ".bin" / "openswarm",
                  root / "node_modules" / "@vrsen" / "openswarm" / "bin" / "openswarm",
              ]
              for candidate in candidates:
                  if candidate.exists():
                      return candidate
              return None

          def install_platform_package(root, repo):
              binary = repo / "dist" / "agentswarm-darwin-arm64"
              if not binary.exists():
                  raise RuntimeError(f"pinned AgentSwarm binary is missing at {binary}")
              target = (
                  root
                  / "node_modules"
                  / "@vrsen"
                  / "openswarm"
                  / "node_modules"
                  / "@vrsen"
                  / "openswarm-cli-darwin-arm64"
                  / "bin"
              )
              target.mkdir(parents=True, exist_ok=True)
              installed = target / "agentswarm"
              installed.write_bytes(binary.read_bytes())
              installed.chmod(0o755)

          repo = pathlib.Path.cwd()
          root = pathlib.Path(tempfile.mkdtemp(prefix="openswarm-smoke-"))
          env = {**os.environ, "OPENSWARM_DEMO_SILENCE_CONSOLE": "0"}
          package_version = subprocess.run(
              ["node", "-p", "require('./package.json').version"],
              cwd=repo,
              check=True,
              capture_output=True,
              text=True,
              env=env,
          ).stdout.strip()

          pack = subprocess.run(["npm", "pack"], cwd=repo, check=True, capture_output=True, text=True, env=env)
          tarball = repo / next(line.strip() for line in reversed(pack.stdout.splitlines()) if line.strip())

          subprocess.run(["npm", "init", "-y"], cwd=root, check=True, capture_output=True, text=True, env=env)
          install = subprocess.run(
              ["npm", "install", str(tarball)],
              cwd=root,
              capture_output=True,
              text=True,
              env=env,
          )

          binary = resolve_launcher(root)

          if binary is None:
              listing = subprocess.run(
                  ["find", "node_modules", "-maxdepth", "4", "-name", "openswarm"],
                  cwd=root,
                  capture_output=True,
                  text=True,
                  env=env,
              )
          else:
              listing = None

          version_runs = []
          if binary is not None:
              install_platform_package(root, repo)
              ignored_url_env = {**env, "OPENSWARM_TUI_URL": "https://127.0.0.1:9/should-not-be-read"}
              version_runs = [run_version(binary, root, ignored_url_env) for _ in range(2)]

          output = "\n".join(
              [
                  "=== pack stdout ===",
                  pack.stdout,
                  "=== pack stderr ===",
                  pack.stderr,
                  "=== install stdout ===",
                  install.stdout,
                  "=== install stderr ===",
                  install.stderr,
                  "=== launcher ===",
                  str(binary),
                  "=== launcher listing stdout ===",
                  "" if listing is None else listing.stdout,
                  "=== launcher listing stderr ===",
                  "" if listing is None else listing.stderr,
              ]
              + [
                  f"=== dependency binary run {idx} stdout ===\n{run.stdout}\n=== dependency binary run {idx} stderr ===\n{run.stderr}"
                  for idx, run in enumerate(version_runs, start=1)
              ]
          )
          print(output)

          if install.returncode != 0:
              print(f"FAILED: npm install exited with {install.returncode}")
              sys.exit(1)

          if binary is None:
              print("FAILED: expected launcher not found after npm install")
              sys.exit(1)

          config = root / "node_modules" / "@vrsen" / "openswarm" / "openswarm.config.mjs"
          if not config.exists():
              print("FAILED: openswarm.config.mjs was not included in the npm package")
              sys.exit(1)

          for idx, run in enumerate(version_runs, start=1):
              if run.returncode != 0:
                  print(f"FAILED: dependency binary run {idx} exited with {run.returncode}")
                  sys.exit(1)
              version = next((line.strip() for line in reversed(run.stdout.splitlines()) if line.strip()), "")
              if version != package_version:
                  print(f"FAILED: dependency binary run {idx} returned {version!r}, expected {package_version!r}")
                  sys.exit(1)
              if "Downloading OpenSwarm TUI" in run.stdout or "Downloading OpenSwarm TUI" in run.stderr:
                  print(f"FAILED: dependency binary run {idx} attempted a runtime TUI download")
                  sys.exit(1)

          banned = [
              "Installing Node.js dependencies...",
              "npm install failed",
              "EACCES",
              "Traceback",
          ]
          lower_output = output.lower()
          for needle in banned:
              if needle.lower() in lower_output:
                  print(f"FAILED: found unexpected output: {needle}")
                  sys.exit(1)
          EOF

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: Test Platforms
on:
  workflow_dispatch:
  push:
    paths:
      - '.github/workflows/build-tui.yml'
      - '.github/workflows/test-mac.yml'
      - 'bin/openswarm'
      - 'openswarm.config.mjs'
      - 'openswarm.marketplace.json'
      - 'package.json'
      - 'package-lock.json'
      - 'run_utils.py'
      - 'scripts/extract-agentswarm-binaries.mjs'
      - 'scripts/platform-assets.mjs'
      - 'scripts/smoke-bootstrap.py'
      - 'scripts/smoke-openswarm-launcher.js'
      - 'scripts/smoke-wheel-bootstrap.py'
      - 'scripts/package-platform-binaries.mjs'
      - 'scripts/write-product-env.mjs'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          cache: 'npm'
          node-version: 20
      - name: Smoke-test launcher platform resolution
        run: node scripts/smoke-openswarm-launcher.js
      - name: Load OpenSwarm product env
        run: node -e "const fs=require('fs');const cp=require('child_process');fs.appendFileSync(process.env.GITHUB_ENV,cp.execFileSync(process.execPath,['scripts/write-product-env.mjs'],{encoding:'utf8'}));"
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install Python package dependencies
        run: python -m pip install -e .
      - name: Smoke-test Python bootstrap fallback
        shell: bash
        run: |
          set -euo pipefail
          python -m py_compile run_utils.py scripts/smoke-bootstrap.py scripts/smoke-wheel-bootstrap.py
          python scripts/smoke-bootstrap.py
          python scripts/smoke-wheel-bootstrap.py
      - name: Extract pinned AgentSwarm macOS TUI binary
        shell: bash
        run: |
          set -euo pipefail
          version="$(node -p "require('./package.json').dependencies['@vrsen/agentswarm']")"
          node scripts/extract-agentswarm-binaries.mjs "$version" dist agentswarm-darwin-arm64
          test "$(./dist/agentswarm-darwin-arm64 --version)" = "$version"
      - name: Test startup
        shell: bash
        run: |
          python - <<'EOF'
          import os
          import pathlib
          import subprocess
          import sys
          import tempfile
 
          def run_version(binary, cwd, env):
              return subprocess.run(
                  [str(binary), "--version"],
                  cwd=cwd,
                  capture_output=True,
                  text=True,
                  env=env,
                  timeout=120,
              )
 
          def resolve_launcher(root):
              candidates = [
                  root / "node_modules" / ".bin" / "openswarm",
                  root / "node_modules" / "@vrsen" / "openswarm" / "bin" / "openswarm",
              ]
              for candidate in candidates:
                  if candidate.exists():
                      return candidate
              return None
 
          def install_platform_package(root, repo):
              binary = repo / "dist" / "agentswarm-darwin-arm64"
              if not binary.exists():
                  raise RuntimeError(f"pinned AgentSwarm binary is missing at {binary}")
              target = (
                  root
                  / "node_modules"
                  / "@vrsen"
                  / "openswarm"
                  / "node_modules"
                  / "@vrsen"
                  / "openswarm-cli-darwin-arm64"
                  / "bin"
              )
              target.mkdir(parents=True, exist_ok=True)
              installed = target / "agentswarm"
              installed.write_bytes(binary.read_bytes())
              installed.chmod(0o755)
 
          repo = pathlib.Path.cwd()
          root = pathlib.Path(tempfile.mkdtemp(prefix="openswarm-smoke-"))
          env = {**os.environ, "OPENSWARM_DEMO_SILENCE_CONSOLE": "0"}
          package_version = subprocess.run(
              ["node", "-p", "require('./package.json').version"],
              cwd=repo,
              check=True,
              capture_output=True,
              text=True,
              env=env,
          ).stdout.strip()
 
          pack = subprocess.run(["npm", "pack"], cwd=repo, check=True, capture_output=True, text=True, env=env)
          tarball = repo / next(line.strip() for line in reversed(pack.stdout.splitlines()) if line.strip())
 
          subprocess.run(["npm", "init", "-y"], cwd=root, check=True, capture_output=True, text=True, env=env)
          install = subprocess.run(
              ["npm", "install", str(tarball)],
              cwd=root,
              capture_output=True,
              text=True,
              env=env,
          )
 
          binary = resolve_launcher(root)
 
          if binary is None:
              listing = subprocess.run(
                  ["find", "node_modules", "-maxdepth", "4", "-name", "openswarm"],
                  cwd=root,
                  capture_output=True,
                  text=True,
                  env=env,
              )
          else:
              listing = None
 
          version_runs = []
          if binary is not None:
              install_platform_package(root, repo)
              ignored_url_env = {**env, "OPENSWARM_TUI_URL": "https://127.0.0.1:9/should-not-be-read"}
              version_runs = [run_version(binary, root, ignored_url_env) for _ in range(2)]
 
          output = "\n".join(
              [
                  "=== pack stdout ===",
                  pack.stdout,
                  "=== pack stderr ===",
                  pack.stderr,
                  "=== install stdout ===",
                  install.stdout,
                  "=== install stderr ===",
                  install.stderr,
                  "=== launcher ===",
                  str(binary),
                  "=== launcher listing stdout ===",
                  "" if listing is None else listing.stdout,
                  "=== launcher listing stderr ===",
                  "" if listing is None else listing.stderr,
              ]
              + [
                  f"=== dependency binary run {idx} stdout ===\n{run.stdout}\n=== dependency binary run {idx} stderr ===\n{run.stderr}"
                  for idx, run in enumerate(version_runs, start=1)
              ]
          )
          print(output)
 
          if install.returncode != 0:
              print(f"FAILED: npm install exited with {install.returncode}")
              sys.exit(1)
 
          if binary is None:
              print("FAILED: expected launcher not found after npm install")
              sys.exit(1)
 
          config = root / "node_modules" / "@vrsen" / "openswarm" / "openswarm.config.mjs"
          if not config.exists():
              print("FAILED: openswarm.config.mjs was not included in the npm package")
              sys.exit(1)
 
          for idx, run in enumerate(version_runs, start=1):
              if run.returncode != 0:
                  print(f"FAILED: dependency binary run {idx} exited with {run.returncode}")
                  sys.exit(1)
              version = next((line.strip() for line in reversed(run.stdout.splitlines()) if line.strip()), "")
              if version != package_version:
                  print(f"FAILED: dependency binary run {idx} returned {version!r}, expected {package_version!r}")
                  sys.exit(1)
              if "Downloading OpenSwarm TUI" in run.stdout or "Downloading OpenSwarm TUI" in run.stderr:
                  print(f"FAILED: dependency binary run {idx} attempted a runtime TUI download")
                  sys.exit(1)
 
          banned = [
              "Installing Node.js dependencies...",
              "npm install failed",
              "EACCES",
              "Traceback",
          ]
          lower_output = output.lower()
          for needle in banned:
              if needle.lower() in lower_output:
                  print(f"FAILED: found unexpected output: {needle}")
                  sys.exit(1)
          EOF
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow