# yaml-language-server: $schema=https://taskfile.dev/schema.json version: "3" vars: LOCALBIN: sh: echo "$(pwd)/bin" MIGRATE: "{{.LOCALBIN}}/migrate" tasks: build: desc: Build go code cmd: go build -o ./build/softplayer silent: true run-migrations-dev: desc: Execute database migrations env: SOFTPLAYER_DB_CONNECTION_STRING: postgres://softplayer:qwertyu9@localhost:30432/softplayer?sslmode=disable cmd: go run main.go migrate --migrations-path=file://migrations run-server-dev: desc: Run the local dev server deps: - run-migrations-dev env: SOFTPLAYER_DB_CONNECTION_STRING: postgres://softplayer:qwertyu9@localhost:30432/softplayer?sslmode=disable SOFTPLAYER_REDIS_HOST: localhost:30379 cmd: go run main.go serve --dev-mode --reflection deploy-local-env: desc: Run a kind cluster and deploy deps deps: - kind-cluster - helmfile-deploy kind-cluster: desc: Run a kind cluster cmd: kind create cluster --config ./kind-config.yaml kind-cluster-remove: desc: Remove the kind cluster cmd: kind delete cluster helmfile-deploy: desc: Deploy the helmfile for the local dev cmd: helmfile apply get-proto-from-branch: desc: Get the latest version of generated protobuf code from the branch silent: true vars: WORKDIR: sh: mktemp -d cmds: - git clone git@gitea.badhouseplants.net:softplayer/softplayer-go-proto.git '{{ .WORKDIR }}' - git -C '{{ .WORKDIR }}' checkout '{{ .CLI_ARGS }}' - go get gitea.badhouseplants.net/softplayer/softplayer-go-proto@$(git -C '{{ .WORKDIR }}' rev-parse HEAD) - rm -rf '{{ .WORKDIR }}' - go mod tidy add-migration: desc: Add a new database migration silent: true cmd: "{{.MIGRATE}} create -dir migrations -ext sql {{.CLI_ARGS}}" # Install required tools localbin: desc: Create local bin directory silent: true cmds: - mkdir -p "{{.LOCALBIN}}" migrate: desc: Download migrate if necessary silent: true deps: - localbin cmds: - task: go-install-tool vars: TARGET: "{{.MIGRATE}}" PACKAGE: github.com/golang-migrate/migrate/v4/cmd/migrate VERSION: latest go-install-tool: internal: true silent: true cmd: |- set -e TARGET="{{.TARGET}}" PACKAGE="{{.PACKAGE}}@{{.VERSION}}" VERSIONED="${TARGET}-{{.VERSION}}" if [ -f "$VERSIONED" ] && [ "$(readlink -- "$TARGET" 2>/dev/null)" = "$VERSIONED" ]; then echo "$PACKAGE already installed" exit 0 fi echo "Downloading $PACKAGE" rm -f "$TARGET" GOBIN="{{.LOCALBIN}}" go install "$PACKAGE" mv "{{.LOCALBIN}}/$(basename "$TARGET")" "$VERSIONED" ln -sf "$(realpath "$VERSIONED")" "$TARGET"