---
version: "3"

vars:
  BRANCH:
    sh: ./scripts/version-data-generator.sh branch
  BUILD_DATE:
    sh: date '+%Y-%m-%d %H:%M:%S %z'
  BUILD_NUMBER:
    sh: ./scripts/version-data-generator.sh build_number
  COMMIT:
    sh: ./scripts/version-data-generator.sh commit
  VERSION:
    sh: ./scripts/version-data-generator.sh version
  BASIC_LDFLAGS: "-X 'go.dev.pztrn.name/featurer/server/internal/application.Version={{ .VERSION }}' -X 'go.dev.pztrn.name/featurer/server/internal/application.Branch={{ .BRANCH }}' -X 'go.dev.pztrn.name/featurer/server/internal/application.Commit={{ .COMMIT }}' -X 'go.dev.pztrn.name/featurer/server/internal/application.Build={{ .BUILD_NUMBER }}' -X 'go.dev.pztrn.name/featurer/server/internal/application.BuildDate={{ .BUILD_DATE }}'"
  LDFLAGS: "{{ .BASIC_LDFLAGS }}"

includes:
  server: ./server

tasks:
  cleanup:
    desc: "Cleanup _build directory."
    cmds:
      - task: server:cmd:cms:cleanup
      - task: server:cmd:featurer:cleanup

  default:
    desc: "Default help."
    cmds:
      - echo "Run \"task -l\" for list of available tasks."

  lint:
    desc: "Runs linters."
    cmds:
      - golangci-lint run ./...
      - go vet ./...

  pre-commit:
    desc: "Runs some tasks before comitting."
    cmds:
      - task: lint
      - task: test

  test:
    desc: "Run tests."
    cmds:
      - go test ./...

  vars:
    desc: "Show vars which will be used for building or running."
    silent: true
    cmds:
      - echo "BRANCH={{ .BRANCH }}"
      - echo "BUILD_DATE={{ .BUILD_DATE }}"
      - echo "BUILD_NUMBER={{ .BUILD_NUMBER }}"
      - echo "COMMIT={{ .COMMIT }}"
      - echo "VERSION={{ .VERSION }}"
