Run sigma-api integration tests in CI against Postgres + Redis#19
Merged
Conversation
The recent RBAC, rate-limit, and audit-log work added a real integration suite under sigma-api/tests/, but build-api.yml only ran a Docker image build — the tests were compile-checked at best and never executed on PRs. A regression in any of those security-sensitive paths would land green. This adds a test-api job that spins up postgres:16 and redis:7 as service containers, exposes DATABASE_URL/REDIS_URL matching what tests/common/mod.rs expects, and runs `cargo test -p sigma-api`. Migrations are applied by the tests themselves, so the workflow just provides empty services. The Docker image build now gates on tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
build-api.ymlpreviously only randocker buildx buildfor the API image. The integration tests added in Gate /api/ai/triage on admin or operator role #13–Audit-log /api/ai/triage requests #17 (RBAC for/api/ai/triage, per-user LLM rate limiting, audit logging) were compile-checked at best — and not even that, since the Docker build wasn't runningcargo buildagainst the test target. A regression in any of those security-sensitive paths would have merged green.test-apijob that runs before the Docker build, withpostgres:16andredis:7as GitHub Actions service containers, health-checked and exposed onlocalhost:5432/localhost:6379.DATABASE_URL=postgres://sigma:sigma@localhost:5432/sigma_testandREDIS_URL=redis://localhost:6379— matching whatsigma-api/tests/common/mod.rs::setup_with_llm_limitreads. Migrations are run by the tests themselves viasqlx::migrate::Migrator::new("./migrations"), so the workflow just provides empty services.cargo test -p sigma-api -- --test-threads=1. Single-threaded because every test callssetup()whichTRUNCATEs shared tables and re-seeds the admin user — parallel runs would race on the shared DB.build-apiDocker job is preserved and nowneeds: test-api, so a red test suite blocks the image build.Swatinem/rust-cache@v2scoped tosigma-apito keep the test job fast on subsequent runs.Test plan
build-apijob still produces the API image aftertest-apipassescargo test -p sigma-apioutput shows theai_triage_test,audit_logs_test,auth_test,providers_test,tickets_test, andusers_testtargets executing🤖 Generated with Claude Code