Taskfile.yaml 4.0 KB

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