Skip to content

Commit cc82394

Browse files
committed
feat: add pgpm-dump function and standardize k8s test runner to v4
1 parent 8a1c52e commit cc82394

24 files changed

Lines changed: 678 additions & 105 deletions

File tree

.github/workflows/test-k8s-deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ jobs:
227227
- name: Install dependencies
228228
run: pnpm install --no-frozen-lockfile
229229

230+
- name: Build and Load Test Runner Image
231+
run: |
232+
make build-test-runner
233+
# The make target uses v3, but runner uses v4. Let's tag it v4 to match test-runner.ts
234+
docker tag constructive/function-test-runner:v3 constructive/function-test-runner:v4
235+
kind load docker-image constructive/function-test-runner:v4 --name local
236+
230237
- name: Run K8s Tests
231238
run: |
232239
# Ensure kubectl proxy port is available or managed by the runner

functions/_runtimes/node/Dockerfile.test

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ WORKDIR /app
99
# Ensure clean slate
1010
RUN rm -rf node_modules
1111

12-
# 3. Install Dependencies from NPM
13-
RUN npm install -g pnpm@9 && pnpm install --no-frozen-lockfile
12+
# 3. Configure PNPM Home
13+
ENV PNPM_HOME="/root/.local/share/pnpm"
14+
ENV PATH="$PNPM_HOME:$PATH"
15+
ENV SHELL="/bin/bash"
1416

15-
# 4. Build
16-
# 5. Install PGPM from NPM
17+
# 4. Install Dependencies from NPM
18+
RUN npm install -g pnpm@9 && \
19+
pnpm setup && \
20+
pnpm install --no-frozen-lockfile
21+
22+
# 5. Connect to global (not needed for pnpm v9+)
23+
# RUN pnpm route-global
24+
25+
# 6. Install PGPM from NPM
1726
RUN pnpm add -g pgpm
1827

1928
# Run as postgres user to avoid 'role root does not exist' in pgsql-test

functions/crypto-login/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('Crypto Login Function (Integration)', () => {
4646
restartPolicy: 'Never',
4747
containers: [{
4848
name: 'crypto-login',
49-
image: 'constructive/function-test-runner:v2',
49+
image: 'constructive/function-test-runner:v4',
5050
imagePullPolicy: "IfNotPresent",
5151
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/crypto-login/src/index.ts"],
5252
env: [

functions/github-repo-creator/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Github Repo Creator Function (Integration)', () => {
3737
restartPolicy: 'Never',
3838
containers: [{
3939
name: 'github-repo-creator',
40-
image: 'constructive/function-test-runner:v2',
40+
image: 'constructive/function-test-runner:v4',
4141
imagePullPolicy: "IfNotPresent",
4242
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/github-repo-creator/src/index.ts"],
4343
env: [{ name: "PORT", value: "8080" }]

functions/hello-world/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test-k8s:
2222
echo "Starting Proxy (PID: $$PID)..."; \
2323
sleep 2; \
2424
TEST_PGPASSWORD=$$(kubectl get secret pg-credentials -o jsonpath="{.data.PGPASSWORD}" | base64 --decode) \
25-
IMAGE_NAME="constructive/function-test-runner:v1" \
25+
IMAGE_NAME="constructive/function-test-runner:v4" \
2626
IS_IN_POD="false" \
2727
PGHOST=$(TEST_PGHOST) \
2828
PGUSER=postgres \

functions/hello-world/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Hello World Function (Integration)', () => {
7777
restartPolicy: 'Never',
7878
containers: [{
7979
name: 'hello-world',
80-
image: 'constructive/function-test-runner:v2',
80+
image: 'constructive/function-test-runner:v4',
8181
imagePullPolicy: "IfNotPresent",
8282
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/hello-world/src/index.ts"],
8383
env: [

functions/llm-external/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('LLM External Function (Integration)', () => {
3939
restartPolicy: 'Never',
4040
containers: [{
4141
name: 'llm-external',
42-
image: 'constructive/function-test-runner:v2',
42+
image: 'constructive/function-test-runner:v4',
4343
imagePullPolicy: "IfNotPresent",
4444
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/llm-external/src/index.ts"],
4545
env: [

functions/llm-internal-calvin/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('LLM Internal Calvin Function (Integration)', () => {
8282
restartPolicy: 'Never',
8383
containers: [{
8484
name: 'llm-internal-calvin',
85-
image: 'constructive/function-test-runner:v2',
85+
image: 'constructive/function-test-runner:v4',
8686
imagePullPolicy: "IfNotPresent",
8787
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/llm-internal-calvin/src/index.ts"],
8888
env: [

functions/opencode-headless/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Opencode Headless Function (Integration)', () => {
3434
restartPolicy: 'Never',
3535
containers: [{
3636
name: 'opencode-headless',
37-
image: 'constructive/function-test-runner:v2',
37+
image: 'constructive/function-test-runner:v4',
3838
imagePullPolicy: "IfNotPresent",
3939
command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/opencode-headless/src/index.ts"],
4040
env: [{ name: "PORT", value: "8080" }],

functions/pgpm-dump/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
IMAGE_NAME ?= constructive/pgpm-dump-test:v1
3+
KIND_CLUSTER_NAME ?= interweb-local
4+
KIND_BIN ?= $(shell which kind 2>/dev/null || echo "/opt/homebrew/bin/kind")
5+
6+
# Define Secrets and Env
7+
TEST_PGHOST ?= postgres
8+
TEST_PGPASSWORD ?= $(shell kubectl get secret --namespace default pg-credentials -o jsonpath="{.data.PGPASSWORD}" | base64 --decode)
9+
10+
.PHONY: vendor test clean test-k8s
11+
12+
test:
13+
pnpm test
14+
15+
clean:
16+
pnpm clean
17+
18+
# Test in K8s (In-Cluster)
19+
# Test in K8s (In-Cluster)
20+
test-k8s:
21+
# Use centralized test runner
22+
cd ../.. && pnpm exec ts-node scripts/test-runner.ts --function pgpm-dump

0 commit comments

Comments
 (0)