Files
go-caatsm/Taskfile.yml
T

148 lines
4.3 KiB
YAML
Raw Normal View History

2024-07-23 11:29:12 +08:00
version: '3'
vars:
app_name: tele-proc
go_files:
2024-07-23 11:29:12 +08:00
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
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..."
- 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-dev:
desc: Run the receiver in development 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 development mode..."
- GO_ENV=dev {{.build_dir}}/receiver listen
2024-07-23 11:29:12 +08:00
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..."
- 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..."
- GO_ENV=test {{.build_dir}}/receiver
upgrade:
desc: Upgrade go dependencies
cmds:
- echo "Upgrading go dependencies..."
- go get -u -d -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/...
2024-07-23 11:29:12 +08:00
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
2024-07-23 11:29:12 +08:00
clean:
desc: Clean build artifacts
cmds:
- echo "Cleaning build artifacts..."
- 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
install-gq:
desc: Install hasura graphql engine introspection tool
cmds:
- echo "Installing gq..."
- pnpm add -g graphqurl
2024-07-23 11:29:12 +08:00
schema:
desc: Download the GraphQL schema from Hasura server
cmds:
- echo "Downloading GraphQL schema..."
- >
gq {{.hasura_endpoint}} -H 'X-Hasura-Admin-Secret: {{.hasura_secret}}' --introspect > {{.schema_file}}
2024-07-23 11:29:12 +08:00
generate:
2024-07-23 11:29:12 +08:00
desc: Generate code using genqlient
cmds:
- echo "Generating code using genqlient..."
- go get github.com/Khan/genqlient/generate
2024-07-23 11:29:12 +08:00
- cd internal/repository && go run github.com/Khan/genqlient && cd ../..
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"
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"
- echo " task install-gq - Install hasura graphql engine introspection tool"
- echo " task schema - Download the GraphQL schema from Hasura server"
- echo " task generate - Generate code using genqlient"
- echo " task upgrade - Upgrade go dependencies"
2024-07-23 11:29:12 +08:00
- echo " task help - Show this help message"