Skip to content

Commit b9c4fe5

Browse files
authored
Merge pull request #328 from cipherstash/feat/port-searchable-json-tests
test: port missing searchable JSON tests to stack package
2 parents 06e3bd5 + db3563b commit b9c4fe5

4 files changed

Lines changed: 1247 additions & 6 deletions

File tree

.github/workflows/tests.yml

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ on:
1010

1111
jobs:
1212
run-tests:
13-
name: Run Tests
13+
name: Run Tests (Node ${{ matrix.node-version }})
1414
runs-on: blacksmith-4vcpu-ubuntu-2404
15+
strategy:
16+
matrix:
17+
node-version: [22, 24]
1518

1619
# Postgres + EQL for the integration tests. Official EQL image —
1720
# PostgreSQL 17 with EQL pre-installed via /docker-entrypoint-initdb.d.
@@ -44,7 +47,7 @@ jobs:
4447
- name: Install Node.js
4548
uses: actions/setup-node@v6
4649
with:
47-
node-version: 22
50+
node-version: ${{ matrix.node-version }}
4851
cache: 'pnpm'
4952

5053
# node-pty's install hook falls back to `node-gyp rebuild` when no
@@ -152,3 +155,94 @@ jobs:
152155
# job above; we filter to the new workspace here to avoid duplication.
153156
- name: Run E2E tests
154157
run: pnpm exec turbo run test:e2e --filter @cipherstash/e2e
158+
159+
run-tests-bun:
160+
name: Run Tests (Bun)
161+
runs-on: blacksmith-4vcpu-ubuntu-2404
162+
continue-on-error: true
163+
164+
services:
165+
postgres:
166+
image: ghcr.io/cipherstash/postgres-eql:17-2.3.1
167+
env:
168+
POSTGRES_USER: cipherstash
169+
POSTGRES_PASSWORD: password
170+
POSTGRES_DB: cipherstash
171+
ports:
172+
- 5432:5432
173+
options: >-
174+
--health-cmd "pg_isready -U cipherstash -d cipherstash"
175+
--health-interval 2s
176+
--health-timeout 5s
177+
--health-retries 20
178+
179+
steps:
180+
- name: Checkout Repo
181+
uses: actions/checkout@v6
182+
183+
- uses: oven-sh/setup-bun@v2
184+
185+
- uses: pnpm/action-setup@v6.0.8
186+
name: Install pnpm
187+
with:
188+
run_install: false
189+
190+
- name: Install Node.js
191+
uses: actions/setup-node@v6
192+
with:
193+
node-version: 22
194+
cache: 'pnpm'
195+
196+
- name: Install node-gyp
197+
run: npm install -g node-gyp
198+
199+
- name: Install dependencies
200+
run: pnpm install --frozen-lockfile
201+
202+
- name: Create .env file in ./packages/protect/
203+
run: |
204+
touch ./packages/protect/.env
205+
echo "CS_WORKSPACE_CRN=${{ secrets.CS_WORKSPACE_CRN }}" >> ./packages/protect/.env
206+
echo "CS_CLIENT_ID=${{ secrets.CS_CLIENT_ID }}" >> ./packages/protect/.env
207+
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./packages/protect/.env
208+
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./packages/protect/.env
209+
echo "DATABASE_URL=postgres://cipherstash:password@localhost:5432/cipherstash" >> ./packages/protect/.env
210+
211+
- name: Create .env file in ./packages/stack/
212+
run: |
213+
touch ./packages/stack/.env
214+
echo "CS_WORKSPACE_CRN=${{ secrets.CS_WORKSPACE_CRN }}" >> ./packages/stack/.env
215+
echo "CS_CLIENT_ID=${{ secrets.CS_CLIENT_ID }}" >> ./packages/stack/.env
216+
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./packages/stack/.env
217+
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./packages/stack/.env
218+
echo "DATABASE_URL=postgres://cipherstash:password@localhost:5432/cipherstash" >> ./packages/stack/.env
219+
220+
- name: Create .env file in ./packages/protect-dynamodb/
221+
run: |
222+
touch ./packages/protect-dynamodb/.env
223+
echo "CS_WORKSPACE_CRN=${{ secrets.CS_WORKSPACE_CRN }}" >> ./packages/protect-dynamodb/.env
224+
echo "CS_CLIENT_ID=${{ secrets.CS_CLIENT_ID }}" >> ./packages/protect-dynamodb/.env
225+
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./packages/protect-dynamodb/.env
226+
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./packages/protect-dynamodb/.env
227+
228+
- name: Create .env file in ./packages/drizzle/
229+
run: |
230+
touch ./packages/drizzle/.env
231+
echo "CS_WORKSPACE_CRN=${{ secrets.CS_WORKSPACE_CRN }}" >> ./packages/drizzle/.env
232+
echo "CS_CLIENT_ID=${{ secrets.CS_CLIENT_ID }}" >> ./packages/drizzle/.env
233+
echo "CS_CLIENT_KEY=${{ secrets.CS_CLIENT_KEY }}" >> ./packages/drizzle/.env
234+
echo "CS_CLIENT_ACCESS_KEY=${{ secrets.CS_CLIENT_ACCESS_KEY }}" >> ./packages/drizzle/.env
235+
echo "DATABASE_URL=postgres://cipherstash:password@localhost:5432/cipherstash" >> ./packages/drizzle/.env
236+
237+
# Build with Node (turbo/tsup need Node), then run tests with Bun
238+
- name: Build packages
239+
run: pnpm turbo build --filter './packages/*'
240+
241+
- name: Run tests with Bun
242+
run: |
243+
for dir in packages/schema packages/protect packages/stack packages/protect-dynamodb packages/drizzle packages/stack-forge; do
244+
if [ -f "$dir/vitest.config.ts" ] || [ -f "$dir/package.json" ]; then
245+
echo "--- Testing $dir ---"
246+
(cd "$dir" && bunx --bun vitest run) || true
247+
fi
248+
done

e2e/tests/supply-chain.e2e.test.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ describe('supply chain — pnpm-lock.yaml integrity', () => {
8686

8787
describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
8888
const workflow = readYaml('.github/workflows/tests.yml') as {
89-
jobs: Record<string, { steps: Array<{ run?: string; uses?: string; with?: Record<string, unknown> }> }>
89+
jobs: Record<
90+
string,
91+
{
92+
strategy?: { matrix?: Record<string, unknown> }
93+
steps: Array<{ run?: string; uses?: string; with?: Record<string, unknown> }>
94+
}
95+
>
9096
}
9197

9298
it('every `pnpm install` invocation uses --frozen-lockfile', () => {
@@ -104,7 +110,7 @@ describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
104110
}
105111
})
106112

107-
it('every pnpm-using job runs on Node 22', () => {
113+
it('every pnpm-using job runs on Node 22 (literal or matrix incl. 22)', () => {
108114
for (const [jobName, job] of Object.entries(workflow.jobs)) {
109115
const usesPnpm = job.steps.some(
110116
(s) =>
@@ -116,7 +122,21 @@ describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
116122
(s) => typeof s.uses === 'string' && s.uses.startsWith('actions/setup-node'),
117123
)
118124
expect(setup, `${jobName} uses pnpm but lacks actions/setup-node`).toBeTruthy()
119-
expect(String(setup?.with?.['node-version']), `${jobName} node version`).toBe('22')
125+
const nv = String(setup?.with?.['node-version'])
126+
if (nv === '22') continue
127+
// Allow `${{ matrix.<key> }}` only when that matrix key resolves to
128+
// an array of versions that includes 22 — so the matrix can broaden
129+
// coverage without ever dropping the Node 22 hardening baseline.
130+
const matrixRef = nv.match(/^\$\{\{\s*matrix\.([\w-]+)\s*\}\}$/)
131+
expect(matrixRef, `${jobName} node version: expected '22' or matrix expression, got '${nv}'`).toBeTruthy()
132+
const matrixKey = matrixRef![1]
133+
const versions = job.strategy?.matrix?.[matrixKey]
134+
expect(
135+
Array.isArray(versions),
136+
`${jobName} references matrix.${matrixKey} but no such array on strategy.matrix`,
137+
).toBe(true)
138+
const versionStrings = (versions as unknown[]).map((v) => String(v))
139+
expect(versionStrings, `${jobName} matrix.${matrixKey} must include 22`).toContain('22')
120140
}
121141
})
122142
})

0 commit comments

Comments
 (0)