Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ jobs:

env:
POSTGRES_VERSION: ${{ matrix.postgres-version }}
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
CS_WORKSPACE_CRN: ${{ secrets.CS_WORKSPACE_CRN }}
CS_CLIENT_ID: ${{ secrets.CS_CLIENT_ID }}
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}

steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -126,4 +130,3 @@ jobs:
mise run --output prefix test:splinter --postgres ${POSTGRES_VERSION}



9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ web_modules/
.env.local
.envrc

# Local mise overrides (CipherStash credentials, etc.)
mise.local.toml
.mise.local.toml

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache
Expand Down Expand Up @@ -215,6 +219,10 @@ eql--*.sql
# Generated SQLx migration (built from src/, never commit)
tests/sqlx/migrations/001_install_eql.sql

# Generated SQLx fixtures (regenerated via `mise run fixture:generate`,
# never commit — stale fixtures hide bugs)
tests/sqlx/fixtures/eql_v2_int4.sql

# Large generated test data files
tests/ste_vec_vast.sql
tests/ste_vec_*M.sql*
Expand All @@ -225,6 +233,7 @@ tests/sqlx/target/
# Work files (agent-generated, not for version control)
.work/
.serena/
docs/superpowers/

# Build variants - protect variant deps
src/deps-protect.txt
Expand Down
18 changes: 17 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"python" = "3.13"

[task_config]
includes = ["tasks", "tasks/postgres.toml"]
includes = ["tasks", "tasks/postgres.toml", "tasks/fixtures.toml"]

[env]
POSTGRES_DB = "cipherstash"
Expand All @@ -34,6 +34,11 @@ run = """

[tasks."test:sqlx"]
description = "Run SQLx tests with hybrid migration approach"
# `build` produces release/cipherstash-encrypt.sql, which is then cp'd into
# tests/sqlx/migrations/001_install_eql.sql below. Without this dep, a stale
# release artifact silently ships an old EQL extension into the test DB and
# regression-guard migrations (e.g. 003_install_ste_vec_data.sql) fail.
depends = ["build"]
dir = "{{config_root}}"
run = """
# Copy built SQL to SQLx migrations (EQL install is generated, not static)
Expand All @@ -45,7 +50,18 @@ echo "Running SQLx migrations..."
cd tests/sqlx
sqlx migrate run

# Regenerate fixtures every run — they are not committed (see .gitignore).
# Generator encrypts via cipherstash-client directly, which needs BOTH a
# ZeroKMS auth credential (CS_CLIENT_ACCESS_KEY + CS_WORKSPACE_CRN, via
# AutoStrategy) AND a client key (CS_CLIENT_ID + CS_CLIENT_KEY, via
# EnvKeyProvider) in the shell environment. Auth and key material are
# separate roles — the two pairs are not alternatives.
echo "Regenerating SQLx fixtures..."
cd "{{config_root}}"
mise run fixture:generate eql_v2_int4

Comment on lines +53 to +62
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

test:sqlx now hard-requires CS credentials and breaks the default CI test path.

This step is unconditional, so SQLx tests fail in environments without CS_* secrets (already visible in current pipeline failures). Make fixture regeneration opt-in or conditional, and keep test:sqlx runnable without external credentials.

Suggested adjustment
 # Regenerate fixtures every run — they are not committed (see .gitignore).
 # Generator encrypts via cipherstash-client directly; CS_* credentials must
 # be present in the shell environment (CS_CLIENT_ACCESS_KEY +
 # CS_WORKSPACE_CRN, or the legacy CS_CLIENT_ID/CS_CLIENT_KEY pair).
 echo "Regenerating SQLx fixtures..."
 cd "{{config_root}}"
-mise run fixture:generate eql_v2_int4
+if { [ -n "${CS_CLIENT_ACCESS_KEY:-}" ] && [ -n "${CS_WORKSPACE_CRN:-}" ]; } || \
+   { [ -n "${CS_CLIENT_ID:-}" ] && [ -n "${CS_CLIENT_KEY:-}" ]; }; then
+  mise run fixture:generate eql_v2_int4
+else
+  echo "Skipping fixture regeneration (CS_* credentials not present)."
+fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@mise.toml` around lines 53 - 60, The CI step in mise.toml unconditionally
runs the fixture regeneration command (mise run fixture:generate eql_v2_int4)
which requires CS_* credentials and breaks test:sqlx in environments without
those secrets; update the script so fixture regeneration is opt-in or
conditional by checking for required env vars (e.g. CS_CLIENT_ACCESS_KEY ||
CS_CLIENT_ID) or a flag like REGENERATE_FIXTURES before invoking mise run
fixture:generate eql_v2_int4, and ensure test:sqlx remains runnable when those
vars/flag are absent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage requires the fixtures. This is a hard requirement.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobyhede, understood — if the fixtures are a mandatory test dependency and CI is already provisioned with the required credentials, keeping regeneration unconditional makes sense. I'll withdraw the suggestion.


✏️ Learnings added
Learnt from: tobyhede
Repo: cipherstash/encrypt-query-language PR: 238
File: mise.toml:53-62
Timestamp: 2026-05-28T06:51:22.350Z
Learning: In the `cipherstash/encrypt-query-language` repository, `mise run fixture:generate eql_v2_int4` in `mise.toml`'s `test:sqlx` task is an unconditional hard requirement — fixture regeneration must always run because the generated SQLx fixtures (e.g. `tests/sqlx/fixtures/eql_v2_int4.sql`) are not committed and test coverage depends on them being present. CI is wired with the necessary CS_CLIENT_ACCESS_KEY and CS_WORKSPACE_CRN secrets. Do not suggest making this step conditional or opt-in.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

echo "Running Rust tests..."
cd tests/sqlx
cargo test
"""

Expand Down
25 changes: 25 additions & 0 deletions tasks/fixtures.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
["fixture:generate"]
description = "Generate a SQLx fixture script via cipherstash-client"
# Runs the gated generator for the named fixture. Writes
# tests/sqlx/fixtures/<fixture>.sql. Must run inside the crate — there is no
# root Cargo.toml — matching test:schema / test:sqlx:watch.
#
# Prerequisites:
# - mise run postgres:up (Postgres with EQL installed)
# - CS_* credentials in the shell environment. The generator needs BOTH
# pairs — they are not alternatives:
# CS_CLIENT_ACCESS_KEY + CS_WORKSPACE_CRN ZeroKMS auth (AutoStrategy)
# CS_CLIENT_ID + CS_CLIENT_KEY client key (EnvKeyProvider)
#
# Usage: mise run fixture:generate eql_v2_int4
dir = "{{config_root}}/tests/sqlx"
run = """
fixture="{{arg(name="fixture")}}"
case "$fixture" in
(*[!a-z0-9_]*|'') echo "Invalid fixture name: $fixture (expected [a-z0-9_]+)" >&2; exit 1 ;;
esac

cargo test --features fixture-gen --lib \
"fixtures::${fixture}::generate" \
-- --ignored --exact --nocapture
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"""
Loading