Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
abelanger5 committed Dec 27, 2023
2 parents a234f03 + 4ca785b commit da80ef7
Show file tree
Hide file tree
Showing 28 changed files with 218 additions and 107 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.Dockerfile \
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.dockerfile \
-t ghcr.io/hatchet-dev/hatchet/hatchet-api:${{steps.tag_name.outputs.tag}} \
--build-arg SERVER_TARGET=api \
--build-arg VERSION=${{steps.tag_name.outputs.tag}} \
Expand All @@ -44,7 +44,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.Dockerfile \
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.dockerfile \
-t ghcr.io/hatchet-dev/hatchet/hatchet-admin:${{steps.tag_name.outputs.tag}} \
--build-arg SERVER_TARGET=admin \
--build-arg VERSION=${{steps.tag_name.outputs.tag}} \
Expand All @@ -68,7 +68,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.Dockerfile \
DOCKER_BUILDKIT=1 docker build -f ./build/package/servers.dockerfile \
-t ghcr.io/hatchet-dev/hatchet/hatchet-engine:${{steps.tag_name.outputs.tag}} \
--build-arg SERVER_TARGET=engine \
--build-arg VERSION=${{steps.tag_name.outputs.tag}} \
Expand All @@ -92,7 +92,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build -f ./build/package/migrate.Dockerfile \
DOCKER_BUILDKIT=1 docker build -f ./build/package/migrate.dockerfile \
-t ghcr.io/hatchet-dev/hatchet/hatchet-migrate:${{steps.tag_name.outputs.tag}} \
.
- name: Push to GHCR
Expand All @@ -114,7 +114,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build -f ./build/package/frontend.Dockerfile \
DOCKER_BUILDKIT=1 docker build -f ./build/package/frontend.dockerfile \
-t ghcr.io/hatchet-dev/hatchet/hatchet-frontend:${{steps.tag_name.outputs.tag}} \
.
- name: Push to GHCR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM node:18-alpine as build

WORKDIR /app
COPY ./frontend/app/package.json ./frontend/app/package-lock.json ./
RUN npm install
RUN npm ci
COPY ./frontend/app ./
RUN npm run build

Expand Down
16 changes: 0 additions & 16 deletions build/package/migrate.Dockerfile

This file was deleted.

14 changes: 14 additions & 0 deletions build/package/migrate.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Base Go environment
# -------------------
FROM golang:1.21-alpine as base
WORKDIR /hatchet

COPY go.mod go.sum ./

RUN go mod download

RUN go run github.com/steebchen/prisma-client-go prefetch

COPY /prisma ./prisma

CMD go run github.com/steebchen/prisma-client-go migrate deploy
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ RUN go run github.com/steebchen/prisma-client-go generate --generator go
FROM node:16-alpine as build-openapi
WORKDIR /openapi

RUN npm install -g npm@8.1

RUN npm install -g @apidevtools/swagger-cli prisma
RUN npm install -g npm@8.1 @apidevtools/swagger-cli prisma

COPY /api-contracts/openapi ./openapi

Expand Down
3 changes: 2 additions & 1 deletion cmd/hatchet-admin/cli/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var seedCmd = &cobra.Command{
err = runSeed(configLoader)

if err != nil {
fmt.Printf("Fatal: could not load server config: %v\n", err)
fmt.Printf("Fatal: could not run seed command: %v\n", err)
os.Exit(1)
}
},
Expand Down Expand Up @@ -137,6 +137,7 @@ func seedDev(repo repository.Repository, tenantId string) error {
if !errors.Is(err, db.ErrNotFound) {
return err
}

wf, err := repo.Workflow().CreateNewWorkflow(tenantId, &repository.CreateWorkflowVersionOpts{
Name: "test-workflow",
Description: repository.StringPtr("This is a test workflow."),
Expand Down
10 changes: 10 additions & 0 deletions examples/schedule-timeout/.hatchet/schedule-timeout-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "test-schedule-timeout"
version: v0.1.0
triggers:
events:
- user:create
jobs:
timeout-job:
steps:
- id: timeout
action: timeout:timeout
47 changes: 47 additions & 0 deletions examples/schedule-timeout/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"context"
"fmt"
"time"

"github.com/hatchet-dev/hatchet/pkg/client"
"github.com/joho/godotenv"
)

type sampleEvent struct{}

type timeoutInput struct{}

func main() {
err := godotenv.Load()

if err != nil {
panic(err)
}

client, err := client.New(
client.InitWorkflows(),
)

if err != nil {
panic(err)
}

event := sampleEvent{}

// push an event
err = client.Event().Push(
context.Background(),
"user:create",
event,
)

if err != nil {
panic(err)
}

time.Sleep(35 * time.Second)

fmt.Println("step should have timed out")
}
2 changes: 1 addition & 1 deletion examples/timeout/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {

err = worker.RegisterAction("timeout:timeout", func(ctx context.Context, input *timeoutInput) (result any, err error) {
// wait for context done signal
timeStart := time.Now()
timeStart := time.Now().UTC()
<-ctx.Done()
fmt.Println("context cancelled in ", time.Since(timeStart).Seconds(), " seconds")

Expand Down
3 changes: 3 additions & 0 deletions frontend/app/src/pages/main/workflow-runs/$run/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ function StepStatusSection({ stepRun }: { stepRun: StepRun }) {
stepRun.step?.timeout || '60s'
}`;
break;
case 'SCHEDULING_TIMED_OUT':
statusText = `This step was cancelled because no workers were available to run ${stepRun.step?.action}`;
break;
case 'PREVIOUS_STEP_TIMED_OUT':
statusText = `This step was cancelled because the previous step timed out`;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export function RunStatus({
case 'TIMED_OUT':
text = 'Timed out';
break;
case 'SCHEDULING_TIMED_OUT':
text = 'No workers available';
break;
default:
break;
}
Expand Down
6 changes: 3 additions & 3 deletions internal/auth/cookie/sessionstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ func (store *UserSessionStore) save(session *sessions.Session) error {
var expiresOn time.Time

if exOn == nil {
expiresOn = time.Now().Add(time.Second * time.Duration(session.Options.MaxAge))
expiresOn = time.Now().UTC().Add(time.Second * time.Duration(session.Options.MaxAge))
} else {
expiresOn = exOn.(time.Time)
if expiresOn.Sub(time.Now().Add(time.Second*time.Duration(session.Options.MaxAge))) < 0 {
expiresOn = time.Now().Add(time.Second * time.Duration(session.Options.MaxAge))
if expiresOn.Sub(time.Now().UTC().Add(time.Second*time.Duration(session.Options.MaxAge))) < 0 {
expiresOn = time.Now().UTC().Add(time.Second * time.Duration(session.Options.MaxAge))
}
}

Expand Down
47 changes: 24 additions & 23 deletions internal/repository/prisma/dbsqlc/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/repository/prisma/dbsqlc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ CREATE TABLE "StepRun" (
"input" JSONB,
"output" JSONB,
"requeueAfter" TIMESTAMP(3),
"scheduleTimeoutAt" TIMESTAMP(3),
"error" TEXT,
"startedAt" TIMESTAMP(3),
"finishedAt" TIMESTAMP(3),
Expand Down
7 changes: 6 additions & 1 deletion internal/repository/prisma/dbsqlc/step_runs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ UPDATE
"StepRun"
SET
"requeueAfter" = COALESCE(sqlc.narg('requeueAfter')::timestamp, "requeueAfter"),
"scheduleTimeoutAt" = COALESCE(sqlc.narg('scheduleTimeoutAt')::timestamp, "scheduleTimeoutAt"),
"startedAt" = COALESCE(sqlc.narg('startedAt')::timestamp, "startedAt"),
"finishedAt" = COALESCE(sqlc.narg('finishedAt')::timestamp, "finishedAt"),
"status" = COALESCE(sqlc.narg('status'), "status"),
"status" = CASE
-- Final states are final, cannot be updated
WHEN "status" IN ('SUCCEEDED', 'FAILED', 'CANCELLED') THEN "status"
ELSE COALESCE(sqlc.narg('status'), "status")
END,
"input" = COALESCE(sqlc.narg('input')::jsonb, "input"),
"output" = COALESCE(sqlc.narg('output')::jsonb, "output"),
"error" = COALESCE(sqlc.narg('error')::text, "error"),
Expand Down
Loading

0 comments on commit da80ef7

Please sign in to comment.