Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 17 additions & 30 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
version: 2

# The Go templates use go.mod.embed, which Dependabot cannot target. Their
# updates come from the Go examples through the sync-go-template-deps command.
multi-ecosystem-groups:
hatchet-sdk-examples:
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 1

# Only examples/ pin dependencies; templates resolve SDK versions at scaffold time.
updates:
- package-ecosystem: "github-actions"
directory: "/"
Expand Down Expand Up @@ -42,28 +34,23 @@ updates:
- package-ecosystem: "pip"
directories:
- "/examples/simple-python"
- "/templates/python/poetry"
- "/templates/python/pip"
multi-ecosystem-group: "hatchet-sdk-examples"
patterns: ["*"]

- package-ecosystem: "uv"
directories:
- "/templates/python/uv"
multi-ecosystem-group: "hatchet-sdk-examples"
patterns: ["*"]
- "/examples/use-cases/scheduled/python"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 2
groups:
python-examples:
patterns: ["*"]

- package-ecosystem: "npm"
directories:
- "/examples/simple-typescript"
- "/templates/typescript/npm"
- "/templates/typescript/pnpm"
- "/templates/typescript/yarn"
multi-ecosystem-group: "hatchet-sdk-examples"
patterns: ["*"]

- package-ecosystem: "bun"
directories:
- "/templates/typescript/bun"
multi-ecosystem-group: "hatchet-sdk-examples"
patterns: ["*"]
- "/examples/use-cases/scheduled/typescript"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 2
groups:
typescript-examples:
patterns: ["*"]
18 changes: 18 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: auto-merge

on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge once required checks pass
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
with:
go-version-file: go.mod

- name: Go template dependencies are in sync
run: go run ./cmd/sync-go-template-deps --check

- name: Generated examples are up to date
run: go run ./cmd/generate-examples --check

Expand Down
67 changes: 64 additions & 3 deletions cmd/generate-examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
type data struct {
Name string
PackageManager string
HatchetVersion string
}

type variant struct {
Expand All @@ -39,8 +40,23 @@ type variant struct {
outputDir string // path under examples/, e.g. "simple-go" or "use-cases/scheduled/go"
}

// dependencyFiles live only in examples/, maintained by dependabot; generation
// neither writes nor checks them.
var dependencyFiles = map[string]bool{
"go.mod": true,
"go.sum": true,
"poetry.lock": true,
"uv.lock": true,
"requirements.lock": true,
"package-lock.json": true,
"pnpm-lock.yaml": true,
"yarn.lock": true,
"bun.lock": true,
"bun.lockb": true,
}

// poetry and pnpm are the generated package-manager variants because their
// templates carry lockfiles.
// examples carry lockfiles.
var variants = []variant{
{name: "simple-go", language: "go", packageManager: "go", outputDir: "simple-go"},
{name: "simple-python", language: "python", packageManager: "poetry", outputDir: "simple-python"},
Expand Down Expand Up @@ -110,13 +126,51 @@ func runCheck(fsys fs.FS) error {
}

func generateVariant(fsys fs.FS, v variant, dst string) error {
if err := os.RemoveAll(dst); err != nil {
if err := clearGenerated(dst); err != nil {
return err
}
d := data{Name: v.name, PackageManager: v.packageManager}
d := data{Name: v.name, PackageManager: v.packageManager, HatchetVersion: "v0.0.0-local"}
return processMultiSource(fsys, v.useCase, v.language, v.packageManager, dst, d)
}

// clearGenerated removes generated output under dst, keeping dependency files.
func clearGenerated(dst string) error {
var files, dirs []string
err := filepath.WalkDir(dst, func(path string, entry fs.DirEntry, err error) error {
if err != nil {
return err
}
if path == dst {
return nil
}
if entry.IsDir() {
dirs = append(dirs, path)
return nil
}
if !dependencyFiles[entry.Name()] {
files = append(files, path)
}
return nil
})
if os.IsNotExist(err) {
return nil
}
if err != nil {
return err
}

for _, f := range files {
if err := os.Remove(f); err != nil {
return err
}
}
sort.Sort(sort.Reverse(sort.StringSlice(dirs)))
for _, d := range dirs {
os.Remove(d)
}
return nil
}

// templateRoot is the embedded path under which a use case's templates live.
// The default simple templates live under templates; use-case templates live
// under templates/use-cases/<use-case>.
Expand Down Expand Up @@ -169,6 +223,10 @@ func process(fsys fs.FS, srcDir, dstDir string, d data) error {
return os.MkdirAll(dstPath, 0755)
}

if dependencyFiles[filepath.Base(dstPath)] {
return nil
}

content, err := fs.ReadFile(subFS, srcPath)
if err != nil {
return err
Expand Down Expand Up @@ -237,6 +295,9 @@ func snapshot(root string) (map[string][]byte, error) {
if entry.IsDir() {
return nil
}
if dependencyFiles[entry.Name()] {
return nil
}
rel, err := filepath.Rel(root, path)
if err != nil {
return err
Expand Down
98 changes: 0 additions & 98 deletions cmd/sync-go-template-deps/main.go

This file was deleted.

11 changes: 2 additions & 9 deletions examples/simple-go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ FROM golang:1.26-alpine AS builder

WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy source code
COPY . .

# Build the application
RUN go mod tidy

RUN go build -o worker ./cmd/worker

FROM alpine:latest

WORKDIR /app

# Copy the binary from builder
COPY --from=builder /app/worker .

CMD ["./worker"]
Loading