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    env:
 42      CRUSH_PROFILE: true
 43    cmds:
 44      - go run . {{.CLI_ARGS}}
 45
 46  test:
 47    desc: Run tests
 48    cmds:
 49      - go test ./... {{.CLI_ARGS}}
 50
 51  fmt:
 52    desc: Run gofumpt
 53    cmds:
 54      - gofumpt -w .
 55
 56  install:
 57    desc: Install the application
 58    cmds:
 59      - go install -v .
 60
 61  profile:cpu:
 62    desc: 10s CPU profile
 63    cmds:
 64      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
 65
 66  profile:heap:
 67    desc: Heap profile
 68    cmds:
 69      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
 70
 71  profile:allocs:
 72    desc: Allocations profile
 73    cmds:
 74      - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
 75
 76  schema:
 77    desc: Generate JSON schema for configuration
 78    cmds:
 79      - go run main.go schema > schema.json
 80      - echo "Generated schema.json"
 81    generates:
 82      - schema.json
 83
 84  release:
 85    desc: Create and push a new tag following semver
 86    vars:
 87      NEXT:
 88        sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
 89    prompt: "This will release {{.NEXT}}. Continue?"
 90    preconditions:
 91      - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
 92        msg: Not on main branch
 93      - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
 94        msg: "Git is dirty"
 95    cmds:
 96      - task: fetch-tags
 97      - git commit --allow-empty -m "{{.NEXT}}"
 98      - git tag --annotate --sign {{.NEXT}} {{.CLI_ARGS}}
 99      - echo "Pushing {{.NEXT}}..."
100      - git push origin --tags
101
102  fetch-tags:
103    cmds:
104      - git tag -d nightly || true
105      - git fetch --tags