Skip to content

Commit b0bbedb

Browse files
committed
refactor(tasks): flatten test tasks into mise.toml with inline usage
Moves all test task definitions into mise.toml using inline scripts and the usage field for flag definitions. This is the proper way to define flags in TOML tasks. Changes: - Define test task inline in mise.toml with usage field - Move test:legacy, test:sqlx tasks to mise.toml - Remove tasks/test.sh, tasks/rust.toml, tasks/test.toml - Update mise.toml includes (remove rust.toml, test.toml) Key fix: - Use "usage" field in TOML for flag definitions - Variables available as ${usage_postgres} in run script - No need for separate shell script files Structure: mise.toml (all task definitions inline) ├─ test (inline with usage field for --postgres flag) ├─ test:legacy → tasks/test-legacy.sh └─ test:sqlx (inline script) CI compatibility: ✓ Accepts --postgres flag: mise run test --postgres ${VERSION} ✓ TOML usage field properly sets usage_postgres variable ✓ Simpler structure (3 files removed)
1 parent 3935a3a commit b0bbedb

File tree

4 files changed

+80
-79
lines changed

4 files changed

+80
-79
lines changed

mise.toml

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

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)