Skip to content

Commit f19a4e8

Browse files
committed
refactor(tasks): flatten test tasks into mise.toml
Simplifies test task structure by moving all task definitions from separate files into main mise.toml. Fixes CI "unbound variable" error by using environment variable instead of MISE USAGE flags. Changes: - Move test, test:legacy, test:sqlx tasks to mise.toml - Remove tasks/test-all.sh, tasks/test.toml, tasks/rust.toml - Update mise.toml includes (remove rust.toml, test.toml) - Use POSTGRES_VERSION environment variable (set by CI) - Remove --postgres flag from CI workflow (uses env var) Variable handling: - Before: usage_postgres from MISE USAGE syntax (didn't work in TOML) - After: ${POSTGRES_VERSION:-17} from environment (works everywhere) - CI sets: POSTGRES_VERSION=${{ matrix.postgres-version }} - Local defaults to: 17 Structure: mise.toml (all tasks inline) ├─ test → inline script ├─ test:legacy → tasks/test-legacy.sh └─ test:sqlx → inline script Benefits: ✓ All tasks visible in one file ✓ No MISE USAGE parsing issues ✓ Works with CI environment variables ✓ Simpler structure (3 files removed) ✓ No unbound variable errors
1 parent 3935a3a commit f19a4e8

File tree

4 files changed

+77
-79
lines changed

4 files changed

+77
-79
lines changed

mise.toml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
# "./tests/mise.tls.toml",
88
# ]
99
[task_config]
10-
includes = ["tasks", "tasks/postgres.toml", "tasks/rust.toml", "tasks/test.toml"]
10+
includes = [
11+
"tasks",
12+
"tasks/postgres.toml",
13+
]
1114

1215
[env]
1316
POSTGRES_DB = "cipherstash"
@@ -27,4 +30,76 @@ run = """
2730
[tasks."test"]
2831
description = "Run all tests (legacy SQL + SQLx Rust)"
2932
sources = ["src/**/*_test.sql", "tests/**/*.sql", "tests/sqlx/**/*.rs"]
30-
run = "{{config_root}}/tasks/test-all.sh"
33+
run = """
34+
#!/bin/bash
35+
set -euo pipefail
36+
37+
POSTGRES_VERSION="${POSTGRES_VERSION:-17}"
38+
39+
echo "=========================================="
40+
echo "Running Complete EQL Test Suite"
41+
echo "PostgreSQL Version: $POSTGRES_VERSION"
42+
echo "=========================================="
43+
echo ""
44+
45+
# Check PostgreSQL is running
46+
{{config_root}}/tasks/check-postgres.sh ${POSTGRES_VERSION}
47+
48+
# Build first
49+
echo "Building EQL..."
50+
mise run build --force
51+
52+
# Run legacy SQL tests
53+
echo ""
54+
echo "=========================================="
55+
echo "1/2: Running Legacy SQL Tests"
56+
echo "=========================================="
57+
mise run test:legacy --postgres ${POSTGRES_VERSION}
58+
59+
# Run SQLx Rust tests
60+
echo ""
61+
echo "=========================================="
62+
echo "2/2: Running SQLx Rust Tests"
63+
echo "=========================================="
64+
mise run test:sqlx
65+
66+
echo ""
67+
echo "=========================================="
68+
echo "✅ ALL TESTS PASSED"
69+
echo "=========================================="
70+
echo ""
71+
echo "Summary:"
72+
echo " ✓ Legacy SQL tests"
73+
echo " ✓ SQLx Rust tests"
74+
echo ""
75+
"""
76+
77+
[tasks."test:legacy"]
78+
description = "Run legacy SQL tests (inline test files)"
79+
sources = ["src/**/*_test.sql", "tests/*.sql"]
80+
run = "{{config_root}}/tasks/test-legacy.sh"
81+
82+
[tasks."test:sqlx"]
83+
description = "Run SQLx tests with hybrid migration approach"
84+
dir = "{{config_root}}"
85+
env = { DATABASE_URL = "postgresql://{{get_env(name='POSTGRES_USER', default='cipherstash')}}:{{get_env(name='POSTGRES_PASSWORD', default='password')}}@{{get_env(name='POSTGRES_HOST', default='localhost')}}:{{get_env(name='POSTGRES_PORT', default='7432')}}/{{get_env(name='POSTGRES_DB', default='cipherstash')}}" }
86+
run = """
87+
# Copy built SQL to SQLx migrations (EQL install is generated, not static)
88+
echo "Updating SQLx migrations with built EQL..."
89+
cp release/cipherstash-encrypt.sql tests/sqlx/migrations/001_install_eql.sql
90+
91+
# Run SQLx migrations and tests
92+
echo "Running SQLx migrations..."
93+
cd tests/sqlx
94+
sqlx migrate run
95+
96+
echo "Running Rust tests..."
97+
cargo test
98+
"""
99+
100+
[tasks."test:sqlx:watch"]
101+
description = "Run SQLx tests in watch mode (rebuild EQL on changes)"
102+
dir = "{{config_root}}/tests/sqlx"
103+
run = """
104+
cargo watch -x test
105+
"""

tasks/rust.toml

Lines changed: 0 additions & 24 deletions
This file was deleted.

tasks/test-all.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

tasks/test.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)