Skip to content

Commit b5c1df7

Browse files
authored
Merge branch 'main' into update-pricing-page-style
2 parents 0e0b8d7 + c63559f commit b5c1df7

File tree

47 files changed

+1082
-2034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1082
-2034
lines changed

.changeset/lazy-panthers-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Improve structured logs

.changeset/rare-beds-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Add verbose structured log level

AGENTS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Guidance for Coding Agents
2+
3+
This repository is a pnpm monorepo managed with Turbo. It contains multiple apps and packages that make up the Trigger.dev platform and SDK.
4+
5+
## Repository layout
6+
- `apps/webapp` – Remix application that serves as the main API and dashboard.
7+
- `apps/supervisor` – Node application for executing built tasks.
8+
- `packages/*` – Published packages such as `@trigger.dev/sdk`, the CLI (`trigger.dev`), and shared libraries.
9+
- `internal-packages/*` – Internal-only packages used by the webapp and other apps.
10+
- `references/*` – Example projects for manual testing and development of new features.
11+
- `ai/references` – Contains additional documentation including an overview (`repo.md`) and testing guidelines (`tests.md`).
12+
13+
See `ai/references/repo.md` for a more complete explanation of the workspaces.
14+
15+
## Development setup
16+
1. Install dependencies with `pnpm i` (pnpm `8.15.5` and Node.js `20.11.1` are required).
17+
2. Copy `.env.example` to `.env` and generate a random 16 byte hex string for `ENCRYPTION_KEY` (`openssl rand -hex 16`). Update other secrets if needed.
18+
3. Start the local services with Docker:
19+
```bash
20+
pnpm run docker
21+
```
22+
4. Run database migrations:
23+
```bash
24+
pnpm run db:migrate
25+
```
26+
5. Build the webapp, CLI and SDK packages:
27+
```bash
28+
pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk
29+
```
30+
6. Launch the development server:
31+
```bash
32+
pnpm run dev --filter webapp
33+
```
34+
The webapp runs on <http://localhost:3030>.
35+
36+
For full setup instructions see `CONTRIBUTING.md`.
37+
38+
## Running tests
39+
- Unit tests use **vitest**. Run all tests:
40+
```bash
41+
pnpm run test
42+
```
43+
- Run tests for a specific workspace (example for `webapp`):
44+
```bash
45+
pnpm run test --filter webapp
46+
```
47+
- Prefer running a single test file from within its directory:
48+
```bash
49+
cd apps/webapp
50+
pnpm run test ./src/components/Button.test.ts
51+
```
52+
If packages in that workspace need to be built first, run `pnpm run build --filter webapp`.
53+
54+
Refer to `ai/references/tests.md` for details on writing tests. Tests should avoid mocks or stubs and use the helpers from `@internal/testcontainers` when Redis or Postgres are needed.
55+
56+
## Coding style
57+
- Formatting is enforced using Prettier. Run `pnpm run format` before committing.
58+
- Follow the existing project conventions. Test files live beside the files under test and use descriptive `describe` and `it` blocks.
59+
- Do not commit directly to the `main` branch. All changes should be made in a separate branch and go through a pull request.
60+
61+
## Additional docs
62+
- The root `README.md` describes Trigger.dev and links to documentation.
63+
- The `docs` workspace contains our documentation site, which can be run locally with:
64+
```bash
65+
pnpm run dev --filter docs
66+
```
67+
- `references/README.md` explains how to create new reference projects for manual testing.
68+

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ branch are tagged into a release periodically.
6868
```
6969
pnpm run db:migrate
7070
```
71-
10. Build the server app
71+
10. Build everything
7272
```
73-
pnpm run build --filter webapp
73+
pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk
7474
```
7575
11. Run the app. See the section below.
7676

apps/supervisor/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MANAGED_WORKER_SECRET=managed-secret
77
# Point this at the webapp in prod
88
TRIGGER_API_URL=http://localhost:3030
99

10-
# Point this at the OTel collector in prod
10+
# Point this at the webapp or an OTel collector in prod
1111
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:3030/otel
1212
# Use this on macOS
1313
# OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:3030/otel

apps/supervisor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TRIGGER_WORKER_TOKEN=tr_wgt_...
3636
pnpm dev
3737
```
3838

39-
4. Build CLI, then deploy a reference project
39+
4. Build CLI, then deploy a test project
4040

4141
```sh
4242
pnpm exec trigger deploy --self-hosted

apps/supervisor/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616
"@kubernetes/client-node": "^1.0.0",
1717
"@trigger.dev/core": "workspace:*",
1818
"dockerode": "^4.0.3",
19-
"nanoid": "^5.0.9",
2019
"prom-client": "^15.1.0",
2120
"socket.io": "4.7.4",
2221
"std-env": "^3.8.0",
23-
"tinyexec": "^0.3.1",
2422
"zod": "3.23.8"
2523
},
2624
"devDependencies": {
2725
"@types/dockerode": "^3.3.33",
28-
"docker-api-ts": "^0.2.2",
2926
"vitest": "^1.4.0"
3027
}
3128
}

apps/supervisor/src/clients/kubernetes.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import { Informer } from "@kubernetes/client-node";
33
import { ListPromise } from "@kubernetes/client-node";
44
import { KubernetesObject } from "@kubernetes/client-node";
55
import { assertExhaustive } from "@trigger.dev/core/utils";
6+
import { SimpleStructuredLogger } from "@trigger.dev/core/v3/utils/structuredLogger";
67

78
export const RUNTIME_ENV = process.env.KUBERNETES_PORT ? "kubernetes" : "local";
89

10+
const logger = new SimpleStructuredLogger("kubernetes-client");
11+
912
export function createK8sApi() {
1013
const kubeConfig = getKubeConfig();
1114

@@ -31,7 +34,7 @@ export function createK8sApi() {
3134
export type K8sApi = ReturnType<typeof createK8sApi>;
3235

3336
function getKubeConfig() {
34-
console.log("getKubeConfig()", { RUNTIME_ENV });
37+
logger.debug("getKubeConfig()", { RUNTIME_ENV });
3538

3639
const kubeConfig = new k8s.KubeConfig();
3740

apps/supervisor/src/env.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ const Env = z.object({
2929
RUNNER_SNAPSHOT_POLL_INTERVAL_SECONDS: z.coerce.number().optional(),
3030
RUNNER_ADDITIONAL_ENV_VARS: AdditionalEnvVars, // optional (csv)
3131
RUNNER_DOCKER_AUTOREMOVE: BoolEnv.default(true),
32+
/**
33+
* Network mode to use for all runners. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`.
34+
* Any other value is taken as a custom network's name to which all runners should connect to.
35+
*
36+
* Accepts a list of comma-separated values to attach to multiple networks. Additional networks are interpreted as network names and will be attached after container creation.
37+
*
38+
* **WARNING**: Specifying multiple networks will slightly increase startup times.
39+
*
40+
* @default "host"
41+
*/
42+
RUNNER_DOCKER_NETWORKS: z.string().default("host"),
3243

3344
// Dequeue settings (provider mode)
3445
TRIGGER_DEQUEUE_ENABLED: BoolEnv.default("true"),
@@ -43,14 +54,14 @@ const Env = z.object({
4354
TRIGGER_METADATA_URL: z.string().optional(),
4455

4556
// Used by the workload manager, e.g docker/k8s
46-
DOCKER_NETWORK: z.string().default("host"),
4757
OTEL_EXPORTER_OTLP_ENDPOINT: z.string().url(),
4858
ENFORCE_MACHINE_PRESETS: z.coerce.boolean().default(false),
4959
KUBERNETES_IMAGE_PULL_SECRETS: z.string().optional(), // csv
5060

5161
// Used by the resource monitor
52-
OVERRIDE_CPU_TOTAL: z.coerce.number().optional(),
53-
OVERRIDE_MEMORY_TOTAL_GB: z.coerce.number().optional(),
62+
RESOURCE_MONITOR_ENABLED: BoolEnv.default(false),
63+
RESOURCE_MONITOR_OVERRIDE_CPU_TOTAL: z.coerce.number().optional(),
64+
RESOURCE_MONITOR_OVERRIDE_MEMORY_TOTAL_GB: z.coerce.number().optional(),
5465

5566
// Kubernetes specific settings
5667
KUBERNETES_FORCE_ENABLED: BoolEnv.default(false),

apps/supervisor/src/envUtil.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { z } from "zod";
2+
import { SimpleStructuredLogger } from "@trigger.dev/core/v3/utils/structuredLogger";
3+
4+
const logger = new SimpleStructuredLogger("env-util");
25

36
export const BoolEnv = z.preprocess((val) => {
47
if (typeof val !== "string") {
@@ -33,7 +36,7 @@ export const AdditionalEnvVars = z.preprocess((val) => {
3336
// Return undefined if no valid key-value pairs were found
3437
return Object.keys(result).length === 0 ? undefined : result;
3538
} catch (error) {
36-
console.warn("Failed to parse additional env vars", { error, val });
39+
logger.warn("Failed to parse additional env vars", { error, val });
3740
return undefined;
3841
}
3942
}, z.record(z.string(), z.string()).optional());

0 commit comments

Comments
 (0)