Taskfile.yaml

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