Various functions#5
Conversation
|
timed out while running ci |
|
Couple of more notes. You wont be able to run all the functions together in the. You need spread them out so each function is tested separately. Maybe one after the other? But also parrelizable, so we need to fine tune each deployment in the current ci runner to the max cpus and resources we use. GH action runner will have 2 cpu and 4gb. So you need to comeup with a testing strategy. |
|
We need to test one function at a time. |
|
yea currently we do: which runs: |
| @@ -0,0 +1,13 @@ | |||
| #!/bin/bash | |||
| console.log(`[Runner] Running in ALL mode`); | ||
| const dirs = fs.readdirSync(FUNCTIONS_DIR); | ||
|
|
||
| for (const dir of dirs) { |
There was a problem hiding this comment.
which runs this on every function dir essentially
|
Yea makes sense, I'll break it out, because the timeout will keep happening. its weird, because it runs faster on my local, maybe because i already have some images or something. Will check and break them out. The original testing strategy was to test them all through a central test runner... but ci doesnt like that lol @Anmol1696 |
|
added copilot too @Anmol1696 |
There was a problem hiding this comment.
Pull request overview
This PR introduces a comprehensive testing and runtime infrastructure for serverless functions, centralizing test execution through Kubernetes and standardizing function patterns across multiple languages and frameworks.
Changes:
- Added centralized K8s test runner using KubernetesJS for orchestrating function tests in pods
- Implemented standardized Node.js runtime wrapper (
runner.js) to abstract server boilerplate from function logic - Added 15+ new function implementations (hello-world, llm-internal-calvin, crypto-login, etc.) with integration tests
Reviewed changes
Copilot reviewed 118 out of 124 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/test-runner.ts | Centralized K8s test orchestration using KubernetesJS client |
| functions/_runtimes/node/runner.js | Universal Node.js runtime wrapper for function execution |
| functions/hello-world/src/index.ts | Example function using new runtime pattern |
| k8s/scripts/scaffold-function.sh | Script for scaffolding new functions from templates |
| package.json | Added testing dependencies (jest, kubernetesjs, ts-jest) |
| Makefile | Added test-k8s-all and build-test-runner targets |
Files not reviewed (1)
- functions/simple-bash/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (8)
scripts/test-runner.ts:1
- Duplicate comment on lines 7 and 9. Remove one to reduce redundancy.
scripts/test-runner.ts:1 - The image tag 'v4' is hardcoded in multiple places (also in Makefile line 59). Consider extracting this to a constant at the top of the file to ensure consistency when the version needs to be updated.
k8s/scripts/scaffold-function.sh:1 - The variable
TARGET_FILEis referenced before being defined. This will cause the script to fail.TARGET_FILEshould be defined before this check, likely as$BASE_DIR/$FUNCTION_NAME.yaml.
functions/simple-email/tests/index.test.ts:1 - Trailing space in the template literal after the random number. This creates database names with trailing spaces which could cause issues. Remove the trailing space.
functions/send-email-link/tests/index.test.ts:1 - Trailing space in the template literal after the random number. This creates database names with trailing spaces which could cause issues. Remove the trailing space.
k8s/base/functions/runtime-script.yaml:1 - The image uses a specific commit hash (07dd24c) rather than a semantic version tag. While this ensures reproducibility, consider using tagged releases for better traceability and update management.
k8s/base/functions/hello-world.yaml:1 - The image uses a specific commit hash (07dd24c) rather than a semantic version tag. While this ensures reproducibility, consider using tagged releases for better traceability and update management.
functions/opencode-headless/scripts/build-calvin.sh:1 - Hard-coded line numbers (81-95) in sed command make this script fragile. If the upstream file changes, this will break. Consider using pattern matching instead of line numbers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // 4. Setup GraphQL Client | ||
| const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT || 'http://constructive-server:3000/graphql'); |
There was a problem hiding this comment.
The hardcoded fallback URL 'http://constructive-server:3000/graphql' may not be appropriate for all environments. Consider making this required or using a more environment-agnostic default.
| const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT || 'http://constructive-server:3000/graphql'); | |
| const graphqlEndpoint = process.env.GRAPHQL_ENDPOINT; | |
| if (!graphqlEndpoint) { | |
| console.error('[runner] GRAPHQL_ENDPOINT environment variable is required but was not set.'); | |
| process.exit(1); | |
| } | |
| const client = new GraphQLClient(graphqlEndpoint); |
There was a problem hiding this comment.
this should prob stay the domain via kns
| imagePullPolicy: "IfNotPresent", | ||
| command: ["npx", "ts-node", "functions/_runtimes/node/runner.js", "functions/llm-internal-calvin/src/index.ts"], | ||
| env: [ | ||
| { name: "CALVIN_API_KEY", value: "42ee96e2cf9c616c81f5b361b36c899d7bda0e1495fb4b98b46a208c923c35e7" }, |
There was a problem hiding this comment.
API key is hardcoded in the test file. While this may be a test key, consider using environment variables or test fixtures to avoid accidentally committing real credentials.
There was a problem hiding this comment.
yup, good catch forgot to take this out

No description provided.