Taskfile.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # https://taskfile.dev
  2. version: "3"
  3. vars:
  4. VERSION:
  5. sh: git describe --long 2>/dev/null || echo ""
  6. RACE:
  7. sh: test -f race.log && echo "1" || echo ""
  8. env:
  9. CGO_ENABLED: 0
  10. GOEXPERIMENT: greenteagc
  11. tasks:
  12. lint:install:
  13. desc: Install golangci-lint
  14. cmds:
  15. - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
  16. env:
  17. GOTOOLCHAIN: go1.25.0
  18. lint:
  19. desc: Run base linters
  20. cmds:
  21. - task: lint:log
  22. - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
  23. env:
  24. GOEXPERIMENT: null
  25. lint:log:
  26. desc: Check that log messages start with capital letters
  27. cmds:
  28. - ./scripts/check_log_capitalization.sh
  29. lint:fix:
  30. desc: Run base linters and fix issues
  31. cmds:
  32. - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
  33. env:
  34. GOEXPERIMENT: null
  35. build:
  36. desc: Run build
  37. vars:
  38. LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
  39. cmds:
  40. - "go build {{if .RACE}}-race{{end}} {{.LDFLAGS}} ."
  41. generates:
  42. - crush
  43. run:
  44. desc: Run build
  45. cmds:
  46. - task: build
  47. - "./crush {{.CLI_ARGS}} {{if .RACE}}2>race.log{{end}}"
  48. test:
  49. desc: Run tests
  50. cmds:
  51. - go test -race -failfast ./... {{.CLI_ARGS}}
  52. test:record:
  53. desc: Run tests and record all VCR cassettes again
  54. aliases: [record]
  55. cmds:
  56. - rm -r internal/agent/testdata
  57. - go test -v -count=1 -timeout=1h ./internal/agent
  58. fmt:
  59. desc: Run gofumpt
  60. cmds:
  61. - gofumpt -w .
  62. fmt:html:
  63. desc: Run prettier on HTML/CSS/JS files
  64. cmds:
  65. - prettier --write internal/cmd/stats/index.html internal/cmd/stats/index.css internal/cmd/stats/index.js
  66. dev:
  67. desc: Run with profiling enabled
  68. env:
  69. CRUSH_PROFILE: true
  70. cmds:
  71. - go run .
  72. install:
  73. desc: Install the application
  74. vars:
  75. LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
  76. cmds:
  77. - task: fetch-tags
  78. - go install {{.LDFLAGS}} -v .
  79. profile:cpu:
  80. desc: 10s CPU profile
  81. cmds:
  82. - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
  83. profile:heap:
  84. desc: Heap profile
  85. cmds:
  86. - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
  87. profile:allocs:
  88. desc: Allocations profile
  89. cmds:
  90. - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
  91. schema:
  92. desc: Generate JSON schema for configuration
  93. cmds:
  94. - go run main.go schema > schema.json
  95. - echo "Generated schema.json"
  96. generates:
  97. - schema.json
  98. hyper:
  99. desc: Update Hyper embedded provider.json
  100. cmds:
  101. - go generate ./internal/agent/hyper/...
  102. generates:
  103. - ./internal/agent/hyper/provider.json
  104. release:
  105. desc: Create and push a new tag following semver
  106. vars:
  107. NEXT:
  108. sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
  109. prompt: "This will release {{.NEXT}}. Continue?"
  110. preconditions:
  111. - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
  112. msg: Not on main branch
  113. - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
  114. msg: "Git is dirty"
  115. - sh: 'gh run list --workflow build.yml --commit $(git rev-parse HEAD) --status success --json conclusion -q ".[0].conclusion" | grep -q success'
  116. msg: "Test build for this commit failed or not present"
  117. - sh: 'gh run list --workflow snapshot.yml --commit $(git rev-parse HEAD) --status success --json conclusion -q ".[0].conclusion" | grep -q success'
  118. msg: "Snapshot build for this commit failed or not present"
  119. cmds:
  120. - task: fetch-tags
  121. - git commit --allow-empty -m "{{.NEXT}}"
  122. - git tag --annotate --sign -m "{{.NEXT}}" {{.NEXT}} {{.CLI_ARGS}}
  123. - echo "Pushing {{.NEXT}}..."
  124. - git push origin main --follow-tags
  125. fetch-tags:
  126. cmds:
  127. - git tag -d nightly || true
  128. - git fetch --tags
  129. deps:
  130. desc: Update Fantasy and Catwalk
  131. cmds:
  132. - go get charm.land/fantasy
  133. - go get charm.land/catwalk
  134. - go mod tidy