Skip to content

Various functions#5

Merged
Jovonni merged 18 commits into
mainfrom
dev/various-functions-2
Jan 11, 2026
Merged

Various functions#5
Jovonni merged 18 commits into
mainfrom
dev/various-functions-2

Conversation

@Jovonni
Copy link
Copy Markdown
Contributor

@Jovonni Jovonni commented Jan 9, 2026

No description provided.

@Jovonni Jovonni requested a review from Anmol1696 January 9, 2026 16:37
@Jovonni Jovonni self-assigned this Jan 9, 2026
@Jovonni Jovonni added the enhancement New feature or request label Jan 9, 2026
@Jovonni
Copy link
Copy Markdown
Contributor Author

Jovonni commented Jan 9, 2026

timed out while running ci

@Anmol1696
Copy link
Copy Markdown
Contributor

Yo, image build error. Check the action logs: image.

@Anmol1696
Copy link
Copy Markdown
Contributor

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.

@Anmol1696
Copy link
Copy Markdown
Contributor

We need to test one function at a time.

@Jovonni
Copy link
Copy Markdown
Contributor Author

Jovonni commented Jan 10, 2026

yea currently we do:

- name: Run K8s Tests
        run: |
          # Ensure kubectl proxy port is available or managed by the runner
          make test-k8s-all

which runs:

constructive-functions/scripts/test-runner.ts

@@ -0,0 +1,13 @@
#!/bin/bash
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then this runs

Comment thread scripts/test-runner.ts
console.log(`[Runner] Running in ALL mode`);
const dirs = fs.readdirSync(FUNCTIONS_DIR);

for (const dir of dirs) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which runs this on every function dir essentially

@Jovonni
Copy link
Copy Markdown
Contributor Author

Jovonni commented Jan 10, 2026

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

@Jovonni Jovonni requested review from Copilot and removed request for Anmol1696 January 10, 2026 04:13
@Jovonni
Copy link
Copy Markdown
Contributor Author

Jovonni commented Jan 10, 2026

added copilot too @Anmol1696

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_FILE is referenced before being defined. This will cause the script to fail. TARGET_FILE should 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.

Comment thread functions/_runtimes/node/runner.js Outdated
}

// 4. Setup GraphQL Client
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT || 'http://constructive-server:3000/graphql');
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" },
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, good catch forgot to take this out

@Jovonni Jovonni merged commit 2c6fe8f into main Jan 11, 2026
0 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants