Skip to content

Commit 71befc8

Browse files
committed
Merge remote-tracking branch 'origin/main' into features/v3-docs
2 parents d6d8097 + 7b3ffe0 commit 71befc8

File tree

156 files changed

+6315
-2080
lines changed

Some content is hidden

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

156 files changed

+6315
-2080
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ COORDINATOR_SECRET=coordinator-secret # generate the actual secret with `openssl
5555
# ENABLE_REGISTRY_PROXY=true
5656
# DEPOT_TOKEN=<Depot org token>
5757
# DEPOT_PROJECT_ID=<Depot project id>
58+
# DEPLOY_REGISTRY_HOST=${APP_ORIGIN} # This is the host that the deploy CLI will use to push images to the registry
5859
# CONTAINER_REGISTRY_ORIGIN=<Container registry origin e.g. https://registry.digitalocean.com>
5960
# CONTAINER_REGISTRY_USERNAME=<Container registry username e.g. Digital ocean email address>
60-
# CONTAINER_REGISTRY_PASSWORD=<Container registry password e.g. Digital ocean PAT>
61+
# CONTAINER_REGISTRY_PASSWORD=<Container registry password e.g. Digital ocean PAT>
62+
# DEV_OTEL_EXPORTER_OTLP_ENDPOINT="http://0.0.0.0:4318"

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
jobs:
55
e2e:
66
name: "🧪 E2E Tests"
7-
runs-on: buildjet-4vcpu-ubuntu-2204
7+
runs-on: buildjet-16vcpu-ubuntu-2204
88
steps:
99
- name: 🐳 Login to Docker Hub
1010
uses: docker/login-action@v2

.github/workflows/publish-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
matrix:
4040
package: [coordinator, kubernetes-provider]
41-
runs-on: buildjet-4vcpu-ubuntu-2204
41+
runs-on: buildjet-16vcpu-ubuntu-2204
4242
env:
4343
DOCKER_BUILDKIT: "1"
4444
steps:

.github/workflows/publish-docker.yml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@ on:
33
workflow_call:
44
jobs:
55
publish:
6-
strategy:
7-
fail-fast: true # when a job fails, all remaining ones will be cancelled
8-
matrix:
9-
runs-on: [buildjet-4vcpu-ubuntu-2204, buildjet-4vcpu-ubuntu-2204-arm]
10-
name: ${{matrix.runs-on}}
11-
runs-on: ${{matrix.runs-on}}
6+
runs-on: ubuntu-latest
127
outputs:
138
version: ${{ steps.get_version.outputs.version }}
149
short_sha: ${{ steps.get_commit.outputs.sha_short }}
1510
steps:
16-
- name: 🐳 Login to Docker Hub
17-
uses: docker/login-action@v2
18-
with:
19-
username: ${{ secrets.DOCKERHUB_USERNAME }}
20-
password: ${{ secrets.DOCKERHUB_TOKEN }}
11+
- name: Setup Depot CLI
12+
uses: depot/setup-action@v1
13+
2114
- name: ⬇️ Checkout repo
2215
uses: actions/checkout@v3
2316
with:
@@ -43,44 +36,24 @@ jobs:
4336
echo "Invalid reference: ${GITHUB_REF}"
4437
exit 1
4538
fi
46-
if [[ ${{matrix.runs-on}} == *-arm ]]; then
47-
IMAGE_TAG="${IMAGE_TAG}-arm"
48-
fi
4939
echo "::set-output name=version::${IMAGE_TAG}"
5040
- name: 🔢 Get the commit hash
5141
id: get_commit
5242
run: |
5343
echo ::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c1-7)
5444
55-
- name: 🐳 Build Docker Image
56-
run: |
57-
docker build -t release_build_image -f ./docker/Dockerfile .
58-
5945
- name: 🐙 Login to GitHub Container Registry
6046
uses: docker/login-action@v2
6147
with:
6248
registry: ghcr.io
6349
username: ${{ github.repository_owner }}
6450
password: ${{ secrets.GITHUB_TOKEN }}
6551

66-
- name: 🐙 Push to GitHub Container Registry
67-
run: |
68-
docker tag release_build_image $REGISTRY/$REPOSITORY:$IMAGE_TAG
69-
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
70-
env:
71-
REGISTRY: ghcr.io/triggerdotdev
72-
REPOSITORY: trigger.dev
73-
IMAGE_TAG: ${{ steps.get_version.outputs.version }}
74-
75-
- name: 🐙 Push 'latest' to GitHub Container Registry
76-
if: startsWith(github.ref, 'refs/tags/v.docker')
77-
run: |
78-
LATEST=latest
79-
if [[ ${{matrix.runs-on}} == *-arm ]]; then
80-
LATEST="${LATEST}-arm"
81-
fi
82-
docker tag release_build_image $REGISTRY/$REPOSITORY:$LATEST
83-
docker push $REGISTRY/$REPOSITORY:$LATEST
84-
env:
85-
REGISTRY: ghcr.io/triggerdotdev
86-
REPOSITORY: trigger.dev
52+
- name: 🐳 Build image and push to GitHub Container Registry
53+
uses: depot/build-push-action@v1
54+
with:
55+
file: ./docker/Dockerfile
56+
platforms: linux/amd64,linux/arm64
57+
tags: |
58+
ghcr.io/triggerdotdev/trigger.dev:${{ steps.get_version.outputs.version }}
59+
push: true

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
release:
1414
name: 🦋 Changesets Release
15-
runs-on: buildjet-4vcpu-ubuntu-2204
15+
runs-on: buildjet-16vcpu-ubuntu-2204
1616
if: |
1717
github.repository == 'triggerdotdev/trigger.dev'
1818
outputs:

.github/workflows/typecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_call:
44
jobs:
55
typecheck:
6-
runs-on: buildjet-4vcpu-ubuntu-2204
6+
runs-on: buildjet-16vcpu-ubuntu-2204
77

88
steps:
99
- name: ⬇️ Checkout repo

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
jobs:
55
unitTests:
66
name: "🧪 Unit Tests"
7-
runs-on: buildjet-4vcpu-ubuntu-2204
7+
runs-on: buildjet-16vcpu-ubuntu-2204
88
steps:
99
- name: ⬇️ Checkout repo
1010
uses: actions/checkout@v3

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"type": "node-terminal",
3434
"request": "launch",
3535
"name": "Debug V3 Dev CLI",
36-
"command": "pnpm exec trigger.dev dev",
36+
"command": "pnpm exec trigger.dev dev --log-level debug",
3737
"cwd": "${workspaceFolder}/references/v3-catalog",
3838
"sourceMaps": true
3939
},

apps/coordinator/src/index.ts

Lines changed: 87 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ class TaskCoordinator {
349349
setSocketDataFromHeader("podName", "x-pod-name");
350350
setSocketDataFromHeader("contentHash", "x-trigger-content-hash");
351351
setSocketDataFromHeader("projectRef", "x-trigger-project-ref");
352+
setSocketDataFromHeader("runId", "x-trigger-run-id");
352353
setSocketDataFromHeader("attemptId", "x-trigger-attempt-id");
353354
setSocketDataFromHeader("envId", "x-trigger-env-id");
354355
setSocketDataFromHeader("deploymentId", "x-trigger-deployment-id");
@@ -363,7 +364,7 @@ class TaskCoordinator {
363364
next();
364365
},
365366
onConnection: async (socket, handler, sender) => {
366-
const logger = new SimpleLogger(`[task][${socket.id}]`);
367+
const logger = new SimpleLogger(`[prod-worker][${socket.id}]`);
367368

368369
this.#platformSocket?.send("LOG", {
369370
metadata: {
@@ -391,6 +392,7 @@ class TaskCoordinator {
391392
const executionAck = await this.#platformSocket?.sendWithAck("READY_FOR_EXECUTION", {
392393
version: "v1",
393394
attemptId: message.attemptId,
395+
runId: message.runId,
394396
});
395397

396398
if (!executionAck) {
@@ -404,7 +406,7 @@ class TaskCoordinator {
404406
}
405407

406408
if (!executionAck.success) {
407-
logger.error("execution unsuccessful", { attemptId: socket.data.attemptId });
409+
logger.error("failed to get execution payload", { attemptId: socket.data.attemptId });
408410

409411
socket.emit("REQUEST_EXIT", {
410412
version: "v1",
@@ -424,26 +426,87 @@ class TaskCoordinator {
424426
this.#platformSocket?.send("READY_FOR_RESUME", message);
425427
});
426428

427-
socket.on("TASK_RUN_COMPLETED", async (message, callback) => {
428-
logger.log("completed task", { completionId: message.completion.id });
429+
socket.on("TASK_RUN_COMPLETED", async ({ completion, execution }, callback) => {
430+
logger.log("completed task", { completionId: completion.id });
429431

430-
this.#platformSocket?.send("TASK_RUN_COMPLETED", {
432+
const sendCompletionToPlatform = () => {
433+
this.#platformSocket?.send("TASK_RUN_COMPLETED", {
434+
version: "v1",
435+
execution,
436+
completion,
437+
});
438+
};
439+
440+
const confirmCompletion = ({
441+
didCheckpoint,
442+
shouldExit,
443+
}: {
444+
didCheckpoint: boolean;
445+
shouldExit: boolean;
446+
}) => {
447+
sendCompletionToPlatform();
448+
callback({ didCheckpoint, shouldExit });
449+
};
450+
451+
if (completion.ok) {
452+
confirmCompletion({ didCheckpoint: false, shouldExit: true });
453+
return;
454+
}
455+
456+
if (
457+
completion.error.type === "INTERNAL_ERROR" &&
458+
completion.error.code === "TASK_RUN_CANCELLED"
459+
) {
460+
confirmCompletion({ didCheckpoint: false, shouldExit: true });
461+
return;
462+
}
463+
464+
if (completion.retry === undefined) {
465+
confirmCompletion({ didCheckpoint: false, shouldExit: true });
466+
return;
467+
}
468+
469+
const { canCheckpoint, willSimulate } = await this.#checkpointer.initialize();
470+
471+
const willCheckpointAndRestore = canCheckpoint || willSimulate;
472+
473+
if (!willCheckpointAndRestore) {
474+
confirmCompletion({ didCheckpoint: false, shouldExit: false });
475+
return;
476+
}
477+
478+
const checkpoint = await this.#checkpointer.checkpointAndPush(socket.data.podName);
479+
480+
if (!checkpoint) {
481+
logger.error("Failed to checkpoint", { podName: socket.data.podName });
482+
confirmCompletion({ didCheckpoint: false, shouldExit: false });
483+
return;
484+
}
485+
486+
this.#platformSocket?.send("CHECKPOINT_CREATED", {
431487
version: "v1",
432-
execution: message.execution,
433-
completion: message.completion,
488+
attemptId: socket.data.attemptId,
489+
docker: checkpoint.docker,
490+
location: checkpoint.destination,
491+
reason: {
492+
type: "RETRYING_AFTER_FAILURE",
493+
attemptNumber: execution.attempt.number,
494+
},
434495
});
435496

436-
callback();
497+
confirmCompletion({ didCheckpoint: true, shouldExit: false });
437498
});
438499

439500
socket.on("WAIT_FOR_DURATION", async (message, callback) => {
440501
logger.log("[WAIT_FOR_DURATION]", message);
441502

442503
const { canCheckpoint, willSimulate } = await this.#checkpointer.initialize();
443504

444-
callback({ willCheckpointAndRestore: canCheckpoint || willSimulate });
505+
const willCheckpointAndRestore = canCheckpoint || willSimulate;
506+
507+
callback({ willCheckpointAndRestore });
445508

446-
if (!canCheckpoint) {
509+
if (!willCheckpointAndRestore) {
447510
return;
448511
}
449512

@@ -476,7 +539,13 @@ class TaskCoordinator {
476539

477540
const { canCheckpoint, willSimulate } = await this.#checkpointer.initialize();
478541

479-
callback({ willCheckpointAndRestore: canCheckpoint || willSimulate });
542+
const willCheckpointAndRestore = canCheckpoint || willSimulate;
543+
544+
callback({ willCheckpointAndRestore });
545+
546+
if (!willCheckpointAndRestore) {
547+
return;
548+
}
480549

481550
const checkpoint = await this.#checkpointer.checkpointAndPush(socket.data.podName);
482551

@@ -502,7 +571,13 @@ class TaskCoordinator {
502571

503572
const { canCheckpoint, willSimulate } = await this.#checkpointer.initialize();
504573

505-
callback({ willCheckpointAndRestore: canCheckpoint || willSimulate });
574+
const willCheckpointAndRestore = canCheckpoint || willSimulate;
575+
576+
callback({ willCheckpointAndRestore });
577+
578+
if (!willCheckpointAndRestore) {
579+
return;
580+
}
506581

507582
const checkpoint = await this.#checkpointer.checkpointAndPush(socket.data.podName);
508583

apps/coordinator/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"target": "es2016",
66
"module": "commonjs",
77
"esModuleInterop": true,
8+
"resolveJsonModule": true,
89
"forceConsistentCasingInFileNames": true,
910
"strict": true,
1011
"skipLibCheck": true,

0 commit comments

Comments
 (0)