Skip to content

Add CI workflow and API sync test to catch command drift#18

Merged
cahaseler merged 2 commits intomainfrom
feat/smoke-testing
Mar 23, 2026
Merged

Add CI workflow and API sync test to catch command drift#18
cahaseler merged 2 commits intomainfrom
feat/smoke-testing

Conversation

@cahaseler
Copy link
Contributor

Summary

  • Adds .github/workflows/ci.yml — runs lint + tests on every PR and push to main (previously only release tags triggered any CI)
  • Adds src/api-sync.test.ts — fetches the live OpenAPI spec and hard-fails if client.ts has stale commands (not in API) or is missing commands (in API but not in client)
  • Cleans up additional stale/missing commands found by the new test

How the API sync test works

Fetches https://game.spacemolt.com/api/openapi.json and diffs it against the COMMANDS block in client.ts. Two failure modes:

  • Stale commands: in client.ts but not in the server API → hard fail
  • Missing commands: in the server API but not in client.ts → hard fail

Undocumented-but-verified endpoints (v2 state commands, drone commands, get_location, storage, etc.) are tracked in a named UNDOCUMENTED_IN_SPEC set so they don't spuriously fail.

Skips gracefully on HTTP 429 (rate limiting) rather than failing CI. Set SKIP_API_SYNC=1 to skip locally.

Additional command fixes found by the test

Removed (all confirmed 404 or explicitly deprecated by server):

  • buy_ship — server says "use browse_ships or commission_ship"
  • get_ships — server returns explicit deprecation message
  • get_recipes, shipyard_showroom, set_anonymous

Added (in spec but missing from client):

  • fleet — coordinated movement/combat
  • get_notifications — fetch queued notifications
  • name_ship — set a custom ship name

Inspired by PR #16

PR #16 by @rsned tried to build a similar thing but compared CLI output to raw API responses (wrong approach — the client intentionally formats data). This takes the right approach: structural comparison between client command list and API spec.

Adds a GitHub Actions CI workflow that runs lint and tests on every PR
and push to main — previously only release tags triggered any CI.

Adds src/api-sync.test.ts which fetches the live OpenAPI spec and
hard-fails if:
- client.ts has commands the server no longer exposes (stale)
- the server has endpoints not yet in client.ts (missing)

Undocumented-but-confirmed endpoints are tracked in UNDOCUMENTED_IN_SPEC
(get_location, storage, deposit_credits, withdraw_credits, drone commands,
v2 state commands).

Running the test found and fixes several more stale/missing commands:
- Removed: buy_ship, get_ships (explicitly deprecated by server), get_recipes,
  shipyard_showroom, set_anonymous (all 404)
- Added: fleet, get_notifications, name_ship (in spec but missing from client)

Skips gracefully on 429 (rate limiting) rather than failing CI.
Set SKIP_API_SYNC=1 to skip locally.
@cahaseler cahaseler merged commit 7df6364 into main Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant