Files
go-caatsm/Taskfile.yml
T

182 lines
5.3 KiB
YAML

version: '3'
vars:
app_name: tele-proc
go_files:
sh: find . -name '*.go' -type f
config_dir: configs
build_dir: build
main_receiver: ./cmd/main/main.go
hasura_endpoint: http://localhost:8080/v1/graphql
schema_file: ./internal/repository/schema.graphql
hasura_secret: # Set your Hasura admin secret here
tasks:
all:
desc: Default target
cmds:
- task: build
build:
desc: Build the receiver application
cmds:
- task: build-receiver
build-receiver:
desc: Build the receiver application
cmds:
- echo "Building receiver..."
- go build -o {{.build_dir}}/receiver {{.main_receiver}}
run:
desc: Run the receiver application with different configurations
cmds:
- task: run-dev
run-prod:
desc: Run the receiver in production mode
cmds:
- task: build-receiver
- echo "Running receiver in production mode..."
- GO_ENV=prod {{.build_dir}}/receiver
run-test:
desc: Run the receiver in test mode
cmds:
- task: build-receiver
- echo "Running receiver in test mode..."
- GO_ENV=test {{.build_dir}}/receiver
upgrade:
desc: Upgrade go dependencies
cmds:
- echo "Upgrading go dependencies..."
- go get -u -v ./...
- go mod tidy
install-test:
desc: Install ginkgo for testing
cmds:
- echo "Installing ginkgo..."
- go install github.com/onsi/ginkgo/v2/ginkgo
- go get github.com/onsi/gomega/...
test:
desc: Test the application
cmds:
- echo "Running tests..."
- ginkgo -r -v
coverage:
desc: Generate test coverage report
cmds:
- echo "Generating test coverage report..."
- ginkgo --json-report ./ginkgo.report -coverpkg=./... -coverprofile=./coverage/coverage.out -r
- go tool cover -html=./coverage/coverage.out -o ./coverage/coverage.html
clean:
desc: Clean build artifacts
cmds:
- echo "Cleaning build artifacts..."
- rm -rf {{.build_dir}}
fmt:
desc: Format the code
cmds:
- echo "Formatting code..."
- go fmt ./...
deps:
desc: Install dependencies
cmds:
- echo "Installing dependencies..."
- go mod tidy
lint:
desc: Lint the code
cmds:
- echo "Linting code..."
- golangci-lint run
run-dev:
desc: Run the receiver in development mode (binary)
cmds:
- task: build-receiver
- echo "Running receiver in development mode..."
- GO_ENV=dev {{.build_dir}}/receiver listen
up:
desc: Start TimescaleDB + NATS dev stack (docker compose)
cmds:
- echo "Starting dev infrastructure..."
- docker compose -f docker-compose.dev.yml up -d postgres nats nats-box
- docker compose -f docker-compose.dev.yml up -d otel-collector jaeger prometheus grafana
down:
desc: Stop dev compose stack and remove containers
cmds:
- echo "Stopping dev infrastructure..."
- docker compose -f docker-compose.dev.yml down -v
dev-run:
desc: Run receiver locally against dev stack
deps:
- up
env:
CAATSM_NATS_URL: nats://localhost:4222
CAATSM_NATS_MODE: jetstream
CAATSM_POSTGRES_URL: postgres://caatsm:caatsm@localhost:5432/aviation?sslmode=disable
CAATSM_TELEMETRY_ENABLED: "true"
CAATSM_TELEMETRY_ENDPOINT: localhost:4318
CAATSM_TELEMETRY_INSECURE: "true"
GO_ENV: dev
cmds:
- |
echo "Ensuring observability stack is healthy (Jaeger @ http://localhost:16686)"
docker compose -f docker-compose.dev.yml ps jaeger otel-collector >/dev/null
echo "Running receiver with telemetry (mode=${CAATSM_NATS_MODE:-core})"
CAATSM_NATS_MODE=${CAATSM_NATS_MODE:-core} \
go run ./cmd/main listen
seed:
desc: Generate sample telegrams (publish to NATS)
cmds:
- |
GO_ENV=dev \
NATS_URL=${CAATSM_NATS_URL:-nats://localhost:4222} \
SUBJECT=${CAATSM_NATS_SUBJECT:-telegram.serial} \
COUNT=${COUNT:-10} \
CATEGORY=${CATEGORY:-mixed} \
STATUS=${STATUS:-random} \
bash -c '
set -euo pipefail
cmd=(go run ./cmd/seed-telegrams)
if [ -n "$NATS_URL" ]; then
cmd+=("--nats-url" "$NATS_URL")
fi
cmd+=(
--subject "$SUBJECT"
--count "$COUNT"
--category "$CATEGORY"
--status "$STATUS"
)
exec "${cmd[@]}"
'
help:
desc: Show this help message
cmds:
- echo "Taskfile usage:"
- echo " task build - Build the application"
- echo " task run - Run the receiver in development mode"
- echo " task run-dev - Run the receiver in development mode"
- echo " task run-prod - Run the receiver in production mode"
- echo " task run-test - Run the receiver in test mode"
- echo " task test - Run tests"
- echo " task coverage - Generate test coverage report"
- echo " task install-test - Install ginkgo for testing"
- echo " task clean - Clean build artifacts"
- echo " task fmt - Format the code"
- echo " task deps - Install dependencies"
- echo " task lint - Lint the code"
- echo " task upgrade - Upgrade go dependencies"
- echo " task help - Show this help message"