2024-07-23 11:29:12 +08:00
|
|
|
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-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..."
|
2024-07-23 16:45:03 +08:00
|
|
|
- GO_ENV=dev {{.BUILD_DIR}}/receiver
|
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..."
|
2024-07-23 16:45: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-07-31 11:05:23 +08:00
|
|
|
- GO_ENV=test {{.BUILD_DIR}}/receiver
|
|
|
|
|
|
|
|
|
|
upgrade:
|
|
|
|
|
desc: Upgrade go dependencies
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Upgrading go dependencies..."
|
|
|
|
|
- go get -u -d -v ./...
|
|
|
|
|
- go mod tidy
|
|
|
|
|
|
2024-07-23 11:29:12 +08:00
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
desc: Test the application
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Running tests..."
|
|
|
|
|
- ginkgo -r -v
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gen:
|
|
|
|
|
desc: Generate code using genqlient
|
|
|
|
|
cmds:
|
|
|
|
|
- echo "Generating code using genqlient..."
|
|
|
|
|
- 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 clean - Clean build artifacts"
|
|
|
|
|
- echo " task fmt - Format the code"
|
|
|
|
|
- echo " task deps - Install dependencies"
|
|
|
|
|
- echo " task lint - Lint the code"
|
2024-07-23 16:45:03 +08:00
|
|
|
- echo " task schema - Download the GraphQL schema from Hasura server"
|
|
|
|
|
- echo " task gen - Generate code using genqlient"
|
2024-07-23 11:29:12 +08:00
|
|
|
- echo " task help - Show this help message"
|