2024-07-23 11:29:12 +08:00
|
|
|
version: '3'
|
|
|
|
|
vars:
|
2024-08-05 10:11:33 +08:00
|
|
|
app_name: tele-proc
|
|
|
|
|
go_files:
|
2024-07-23 11:29:12 +08:00
|
|
|
sh: find . -name '*.go' -type f
|
2024-08-05 10:11:33 +08:00
|
|
|
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
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
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..."
|
2024-08-05 10:11:33 +08:00
|
|
|
- go build -o {{.build_dir}}/receiver {{.main_receiver}}
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
run:
|
|
|
|
|
desc: Run the receiver application with different configurations
|
|
|
|
|
cmds:
|
|
|
|
|
- task: run-dev
|
|
|
|
|
|
|
|
|
|
run-prod:
|
|
|
|
|
desc: Run the receiver in production mode
|
|
|
|
|
cmds:
|
2024-07-23 16:45:03 +08:00
|
|
|
- task: build-receiver
|
2024-07-23 11:29:12 +08:00
|
|
|
- echo "Running receiver in production mode..."
|
2024-08-07 14:10:03 +08:00
|
|
|
- GO_ENV=prod {{.build_dir}}/receiver
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
run-test:
|
|
|
|
|
desc: Run the receiver in test mode
|
|
|
|
|
cmds:
|
2024-07-23 16:45:03 +08:00
|
|
|
- task: build-receiver
|
2024-07-23 11:29:12 +08:00
|
|
|
- echo "Running receiver in test mode..."
|
2024-08-05 10:11:33 +08:00
|
|
|
- GO_ENV=test {{.build_dir}}/receiver
|
2024-07-31 11:05:23 +08:00
|
|
|
|
|
|
|
|
upgrade:
|
|
|
|
|
desc: Upgrade go dependencies
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Upgrading go dependencies..."
|
2025-11-14 23:42:39 +08:00
|
|
|
- go get -u -v ./...
|
2024-07-31 11:05:23 +08:00
|
|
|
- go mod tidy
|
|
|
|
|
|
2024-08-02 19:45:49 +08:00
|
|
|
install-test:
|
2024-08-05 10:11:33 +08:00
|
|
|
desc: Install ginkgo for testing
|
2024-08-02 19:45:49 +08:00
|
|
|
cmds:
|
|
|
|
|
- echo "Installing ginkgo..."
|
|
|
|
|
- go install github.com/onsi/ginkgo/v2/ginkgo
|
|
|
|
|
- go get github.com/onsi/gomega/...
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
desc: Test the application
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Running tests..."
|
|
|
|
|
- ginkgo -r -v
|
|
|
|
|
|
2024-08-07 20:05:43 +08:00
|
|
|
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
|
|
|
|
|
|
2024-07-23 11:29:12 +08:00
|
|
|
clean:
|
|
|
|
|
desc: Clean build artifacts
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Cleaning build artifacts..."
|
2024-08-05 10:11:33 +08:00
|
|
|
- rm -rf {{.build_dir}}
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2025-11-15 12:08:26 +08:00
|
|
|
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
|
|
|
|
|
|
2025-11-15 09:46:29 +08:00
|
|
|
up:
|
2025-11-15 12:08:26 +08:00
|
|
|
desc: Start TimescaleDB + NATS dev stack (docker compose)
|
2025-11-15 09:46:29 +08:00
|
|
|
cmds:
|
|
|
|
|
- echo "Starting dev infrastructure..."
|
2025-11-15 14:24:11 +08:00
|
|
|
- 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
|
2025-11-15 09:46:29 +08:00
|
|
|
|
|
|
|
|
down:
|
|
|
|
|
desc: Stop dev compose stack and remove containers
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Stopping dev infrastructure..."
|
2025-11-15 14:24:11 +08:00
|
|
|
- docker compose -f docker-compose.dev.yml down -v
|
2025-11-15 09:46:29 +08:00
|
|
|
|
|
|
|
|
dev-run:
|
|
|
|
|
desc: Run receiver locally against dev stack
|
2025-11-15 14:42:33 +08:00
|
|
|
deps:
|
|
|
|
|
- up
|
2025-11-15 12:08:26 +08:00
|
|
|
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
|
2025-11-15 09:46:29 +08:00
|
|
|
cmds:
|
2025-11-15 12:08:26 +08:00
|
|
|
- |
|
2025-11-15 14:42:33 +08:00
|
|
|
echo "Ensuring observability stack is healthy (Jaeger @ http://localhost:16686)"
|
|
|
|
|
docker compose -f docker-compose.dev.yml ps jaeger otel-collector >/dev/null
|
2025-11-15 12:08:26 +08:00
|
|
|
echo "Running receiver with telemetry (mode=${CAATSM_NATS_MODE:-core})"
|
|
|
|
|
CAATSM_NATS_MODE=${CAATSM_NATS_MODE:-core} \
|
2025-11-15 09:46:29 +08:00
|
|
|
go run ./cmd/main listen
|
|
|
|
|
|
2025-11-15 12:08:26 +08:00
|
|
|
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[@]}"
|
|
|
|
|
'
|
2024-07-23 11:29:12 +08:00
|
|
|
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"
|
2024-08-07 20:37:34 +08:00
|
|
|
- echo " task coverage - Generate test coverage report"
|
2024-08-02 19:45:49 +08:00
|
|
|
- echo " task install-test - Install ginkgo for testing"
|
2024-07-23 11:29:12 +08:00
|
|
|
- echo " task clean - Clean build artifacts"
|
|
|
|
|
- echo " task fmt - Format the code"
|
|
|
|
|
- echo " task deps - Install dependencies"
|
|
|
|
|
- echo " task lint - Lint the code"
|
2024-07-31 16:04:52 +08:00
|
|
|
- echo " task upgrade - Upgrade go dependencies"
|
2024-07-23 11:29:12 +08:00
|
|
|
- echo " task help - Show this help message"
|