Taskfile.yaml 2.7 KB

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