Follow-up to the test_api.sh fix. Same Phase 30.1 + 30.6 staleness existed in the other E2E scripts; same pattern applied. ## New tests/e2e/_lib.sh Shared bash helpers so future scripts don't reimplement: - e2e_extract_token — parse auth_token from register response - e2e_register — register + echo token - e2e_heartbeat — heartbeat with bearer auth - e2e_cleanup_all_workspaces — pre-test state reset ## test_comprehensive_e2e.sh (14 fail -> 0 fail) Root cause was deeper than test_api.sh: the script creates workspaces at Section 2 but doesn't register them until Section 3. In between, the platform provisioner spawns the Docker container, whose main.py calls /registry/register first and claims the single-issue token. The script's later register gets no auth_token back. Fix: register each workspace immediately after POST /workspaces, beating the container to the token. Empirically 5/5 wins in a tight loop. PM/Dev/QA tokens captured at creation time; bearer auth threaded through all heartbeat/update-card/discover/peers calls. Removed the duplicate register calls in Section 3/4 that followed (tokens already captured). Result: 53/68 -> 67/67 (one duplicate check dropped). ## test_activity_e2e.sh Same pattern applied on faith. Script still SKIPs cleanly when no online agent is present; when an agent IS online, it now re-registers it to mint a fresh bearer token and threads Authorization: Bearer on the 3 heartbeat calls. ## test_api.sh refactor Now sources _lib.sh and uses the shared helpers. No behavior change, still 62/62. ## .github/workflows/ci.yml — new e2e-api job Spins up Postgres 16 + Redis 7 as GitHub Actions services, builds the platform binary, runs it in background with DATABASE_URL/REDIS_URL, polls /health for 30s, then runs tests/e2e/test_api.sh. On failure dumps platform.log for triage. 10-min job timeout. This is the watchdog that would have caught Phase 30.1 auth drift the day it landed. Picks test_api.sh not test_comprehensive_e2e.sh because the latter depends on Docker-in-Docker for container provisioning which is heavier than a PR gate should carry. ## Verification - bash tests/e2e/test_api.sh -> 62/62 - bash tests/e2e/test_comprehensive_e2e.sh -> 67/67 - bash tests/e2e/test_activity_e2e.sh -> cleanly SKIPs (no agent) - go build ./... -> clean - .github/workflows/ci.yml -> valid YAML, new job added Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
173 lines
5.2 KiB
YAML
173 lines
5.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
platform-build:
|
|
name: Platform (Go)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: platform
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 'stable'
|
|
- run: go mod download
|
|
- run: go build ./cmd/server
|
|
- run: go build -o molecli ./cmd/cli
|
|
- run: go vet ./...
|
|
- name: Run golangci-lint
|
|
uses: golangci/golangci-lint-action@v4
|
|
with:
|
|
version: latest
|
|
working-directory: platform
|
|
args: --timeout 3m
|
|
continue-on-error: true # Warn but don't block until codebase is clean
|
|
- name: Run tests with race detection and coverage
|
|
run: go test -race -coverprofile=coverage.out ./...
|
|
- name: Check coverage baseline
|
|
run: |
|
|
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
|
|
echo "Total coverage: ${COVERAGE}%"
|
|
THRESHOLD=25
|
|
awk "BEGIN{if ($COVERAGE < $THRESHOLD) exit 1}" || {
|
|
echo "::error::Coverage ${COVERAGE}% is below the ${THRESHOLD}% threshold"
|
|
exit 1
|
|
}
|
|
|
|
canvas-build:
|
|
name: Canvas (Next.js)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: canvas
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
- run: rm -f package-lock.json && npm install
|
|
- run: npm run build
|
|
- name: Run tests
|
|
run: npx vitest run
|
|
|
|
mcp-server-build:
|
|
name: MCP Server (Node.js)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: mcp-server
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: npm
|
|
cache-dependency-path: mcp-server/package-lock.json
|
|
- run: npm ci
|
|
- run: npm run build
|
|
|
|
e2e-api:
|
|
name: E2E API Smoke Test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: molecule
|
|
POSTGRES_PASSWORD: molecule
|
|
POSTGRES_DB: molecule
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U molecule"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
redis:
|
|
image: redis:7
|
|
ports:
|
|
- 6379:6379
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
env:
|
|
DATABASE_URL: postgres://molecule:molecule@localhost:5432/molecule?sslmode=disable
|
|
REDIS_URL: redis://localhost:6379
|
|
PORT: "8080"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 'stable'
|
|
- name: Build platform
|
|
working-directory: platform
|
|
run: go build -o platform-server ./cmd/server
|
|
- name: Start platform (background)
|
|
working-directory: platform
|
|
run: |
|
|
./platform-server > platform.log 2>&1 &
|
|
echo $! > platform.pid
|
|
- name: Wait for /health
|
|
run: |
|
|
for i in $(seq 1 30); do
|
|
if curl -sf http://localhost:8080/health > /dev/null; then
|
|
echo "Platform up after ${i}s"
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo "::error::Platform did not become healthy in 30s"
|
|
cat platform/platform.log || true
|
|
exit 1
|
|
- name: Run E2E API tests
|
|
run: bash tests/e2e/test_api.sh
|
|
- name: Dump platform log on failure
|
|
if: failure()
|
|
run: cat platform/platform.log || true
|
|
- name: Stop platform
|
|
if: always()
|
|
run: |
|
|
if [ -f platform/platform.pid ]; then
|
|
kill "$(cat platform/platform.pid)" 2>/dev/null || true
|
|
fi
|
|
|
|
python-lint:
|
|
name: Python Lint & Test
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: workspace-template
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
cache: pip
|
|
cache-dependency-path: workspace-template/requirements.txt
|
|
- run: pip install -r requirements.txt pytest pytest-asyncio pytest-cov
|
|
- run: python -m pytest --tb=short -q --cov=. --cov-report=term-missing
|
|
|
|
# Lint first-party plugins. The validator checks each plugin
|
|
# against the format it declares — currently agentskills.io for all
|
|
# of ours, but the same command covers any future shape that lands
|
|
# under a sibling adapter (MCP, DeepAgents sub-agent, etc.).
|
|
- name: Install molecule-plugin SDK
|
|
working-directory: sdk/python
|
|
run: pip install -e .
|
|
- name: Lint first-party plugins
|
|
working-directory: ${{ github.workspace }}
|
|
run: python -m molecule_plugin validate plugins/molecule-dev plugins/superpowers plugins/ecc
|
|
- name: Run SDK tests
|
|
working-directory: sdk/python
|
|
run: python -m pytest --tb=short -q
|