140 lines
3.7 KiB
YAML
140 lines
3.7 KiB
YAML
version: '3'
|
|
|
|
vars:
|
|
BINARY: renewcms
|
|
DIST_DIR: internal/infrastructure/assets/dist
|
|
VERSION:
|
|
sh: git describe --tags --always --dirty
|
|
LDFLAGS: -s -w -X main.version={{.VERSION}}
|
|
RELEASE_TARGETS: [windows/amd64, windows/arm64, linux/amd64, linux/arm64, darwin/amd64, darwin/arm64]
|
|
|
|
env:
|
|
CGO_ENABLED: '0'
|
|
|
|
tasks:
|
|
default:
|
|
cmds:
|
|
- task --list
|
|
silent: true
|
|
|
|
setup:
|
|
desc: Install dev tools, Go modules and frontend dependencies
|
|
cmds:
|
|
- go install github.com/air-verse/air@latest
|
|
- go install github.com/go-gremlins/gremlins/cmd/gremlins@latest
|
|
- go mod download
|
|
- task: web:install
|
|
|
|
dev:
|
|
desc: Run the API (air, hot reload) and the SPA (Vite, HMR) together → http://localhost:5173
|
|
deps: [dev:api, dev:web]
|
|
|
|
dev:api:
|
|
desc: Run the API with hot reload on :8080 (SPA not embedded)
|
|
cmds:
|
|
- air
|
|
|
|
dev:web:
|
|
desc: Run the Vite dev server on :5173, proxying /v1 to the API
|
|
dir: web
|
|
deps: [web:install]
|
|
cmds:
|
|
- bun dev
|
|
|
|
test:
|
|
desc: Run the Go tests
|
|
cmds:
|
|
- go test -tags nofrontend ./test/... -count=1 {{.CLI_ARGS}}
|
|
|
|
cover:
|
|
desc: Go test coverage of the use cases → tmp/coverage.out
|
|
cmds:
|
|
- mkdir -p tmp
|
|
- go test -tags nofrontend ./test/... -count=1 -coverpkg=./internal/infrastructure/useCases/... -coverprofile=tmp/coverage.out
|
|
- go tool cover -func=tmp/coverage.out
|
|
|
|
mutate:
|
|
desc: Gremlins mutation testing of the use cases → tmp/gremlins.json
|
|
cmds:
|
|
- mkdir -p tmp
|
|
- gremlins unleash --integration --tags nofrontend --coverpkg=./internal/infrastructure/useCases/...,./api/middleware/...,./api/pkg/claims/... --timeout-coefficient 10 --output tmp/gremlins.json ./internal/infrastructure/useCases ./api/middleware ./api/pkg/claims
|
|
|
|
lint:
|
|
desc: gofmt check, go vet, eslint (--fix) and vue-tsc
|
|
cmds:
|
|
- task: lint:go
|
|
- task: lint:web
|
|
|
|
lint:go:
|
|
cmds:
|
|
- cmd: test -z "$(gofmt -l .)" || (gofmt -l . && echo "unformatted Go files, run 'task fmt'" && exit 1)
|
|
silent: true
|
|
- go vet -tags nofrontend ./...
|
|
|
|
lint:web:
|
|
dir: web
|
|
deps: [web:install]
|
|
cmds:
|
|
- bun lint
|
|
- bun run type-check
|
|
|
|
fmt:
|
|
desc: Format Go and frontend sources
|
|
cmds:
|
|
- gofmt -w .
|
|
- bun run --cwd web format
|
|
|
|
web:install:
|
|
internal: true
|
|
dir: web
|
|
sources: [package.json, bun.lock]
|
|
generates: ['node_modules/.bin/vite*']
|
|
cmds:
|
|
- bun install --frozen-lockfile
|
|
|
|
build:web:
|
|
desc: Type-check and build the SPA into {{.DIST_DIR}}
|
|
dir: web
|
|
deps: [web:install]
|
|
sources: [src/**/*, public/**/*, index.html, vite.config.ts, tsconfig*.json, package.json, bun.lock]
|
|
generates: ['../{{.DIST_DIR}}/index.html']
|
|
cmds:
|
|
- bun run build
|
|
|
|
build:
|
|
desc: Production binary for this machine → bin/{{.BINARY}}
|
|
deps: [build:web]
|
|
cmds:
|
|
- go build -trimpath -ldflags "{{.LDFLAGS}}" -o bin/{{.BINARY}}{{exeExt}} ./cmd/server
|
|
|
|
release:
|
|
desc: Cross-compile production binaries for all release targets → bin/
|
|
deps: [build:web]
|
|
cmds:
|
|
- for: { var: RELEASE_TARGETS }
|
|
task: build:target
|
|
vars:
|
|
GOOS: '{{index (splitList "/" .ITEM) 0}}'
|
|
GOARCH: '{{index (splitList "/" .ITEM) 1}}'
|
|
|
|
build:target:
|
|
internal: true
|
|
vars:
|
|
EXT: '{{if eq .GOOS "windows"}}.exe{{end}}'
|
|
env:
|
|
GOOS: '{{.GOOS}}'
|
|
GOARCH: '{{.GOARCH}}'
|
|
cmds:
|
|
- go build -trimpath -ldflags "{{.LDFLAGS}}" -o bin/{{.BINARY}}_{{.VERSION}}_{{.GOOS}}_{{.GOARCH}}{{.EXT}} ./cmd/server
|
|
|
|
run:
|
|
desc: Build and run the production binary locally
|
|
deps: [build]
|
|
cmds:
|
|
- ./bin/{{.BINARY}}{{exeExt}}
|
|
|
|
clean:
|
|
desc: Remove build output, the built SPA and tmp/
|
|
cmds:
|
|
- rm -rf bin tmp {{.DIST_DIR}}
|