Taskfile.yaml 2.9 KB

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