Taskfile.yaml

  1# https://taskfile.dev
  2
  3version: "3"
  4
  5env:
  6  CGO_ENABLED: 0
  7  TEA_DEBUG: 1
  8  GOEXPERIMENT: greenteagc
  9
 10tasks:
 11  lint:install:
 12    desc: Install golangci-lint
 13    cmds:
 14      - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
 15    env:
 16      GOTOOLCHAIN: go1.25.0
 17
 18  lint:
 19    desc: Run base linters
 20    cmds:
 21      - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
 22    env:
 23      GOEXPERIMENT: null
 24
 25  lint-fix:
 26    desc: Run base linters and fix issues
 27    cmds:
 28      - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
 29    env:
 30      GOEXPERIMENT: null
 31
 32  build:
 33    desc: Run build
 34    cmds:
 35      - go build .
 36    generates:
 37      - crush
 38
 39  run:
 40    desc: Run build
 41    cmds:
 42      - go run . {{.CLI_ARGS}}
 43
 44  test:
 45    desc: Run tests
 46    cmds:
 47      - go test ./... {{.CLI_ARGS}}
 48
 49  fmt:
 50    desc: Run gofumpt
 51    cmds:
 52      - gofumpt -w .
 53
 54  dev:
 55    desc: Run with profiling enabled
 56    env:
 57      CRUSH_PROFILE: true
 58    cmds:
 59      - go run .
 60
 61  install:
 62    desc: Install the application
 63    cmds:
 64      - go install -v .
 65
 66  profile:cpu:
 67    desc: 10s CPU profile
 68    cmds:
 69      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
 70
 71  profile:heap:
 72    desc: Heap profile
 73    cmds:
 74      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
 75
 76  profile:allocs:
 77    desc: Allocations profile
 78    cmds:
 79      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
 80
 81  schema:
 82    desc: Generate JSON schema for configuration
 83    cmds:
 84      - go run main.go schema > schema.json
 85      - echo "Generated schema.json"
 86    generates:
 87      - schema.json
 88
 89  release:
 90    desc: Create and push a new tag following semver
 91    vars:
 92      NEXT:
 93        sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
 94    prompt: "This will release {{.NEXT}}. Continue?"
 95    preconditions:
 96      - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
 97        msg: Not on main branch
 98      - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
 99        msg: "Git is dirty"
100    cmds:
101      - task: fetch-tags
102      - git commit --allow-empty -m "{{.NEXT}}"
103      - git tag --annotate --sign {{.NEXT}} {{.CLI_ARGS}}
104      - echo "Pushing {{.NEXT}}..."
105      - git push origin --tags
106
107  fetch-tags:
108    cmds:
109      - git tag -d nightly || true
110      - git fetch --tags