diff --git a/Taskfile.yml b/Taskfile.yml index 521a2c15..45a28661 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,174 +1,61 @@ version: '3' vars: - DETECTED_LANGUAGES: Go, Bun/Node + DETECTED_LANGUAGE: Go tasks: default: - desc: List common tasks for detected language targets. + desc: List available tasks. cmds: - task --list build: - desc: Build every detected language target ({{.DETECTED_LANGUAGES}}). - cmds: - - task: build:go - - task: build:chat - - task: build:docs - - build:go: - internal: true - status: - - test ! -f go.mod + desc: Build the {{.DETECTED_LANGUAGE}} binary. cmds: - | bash -euo pipefail -c ' export GOCACHE="$PWD/.cache/go-build" - export GOTMPDIR="$PWD/.cache/go-tmp" mkdir -p "$GOCACHE" - mkdir -p "$GOTMPDIR" go build -o ./agentapi ./main.go ' - build:chat: - internal: true - status: - - test ! -f package.json - dir: chat - cmds: - - | - bash -euo pipefail -c ' - if [ ! -d node_modules ]; then - bun install --frozen-lockfile - fi - rm -f .next/lock - bun run build - ' - - build:docs: - internal: true - status: - - test ! -f package.json || test ! -d ../vendor/phenodocs/packages/docs - dir: docs - cmds: - - | - bash -euo pipefail -c ' - npm ci --ignore-scripts - node ./node_modules/vitepress/dist/node/cli.js build . - ' - test: - desc: Run tests for detected language targets ({{.DETECTED_LANGUAGES}}). - cmds: - - task: test:go - - test:go: - internal: true - status: - - test ! -f go.mod + desc: Run the {{.DETECTED_LANGUAGE}} test suite. cmds: - | bash -euo pipefail -c ' export GOCACHE="$PWD/.cache/go-build" - export GOTMPDIR="$PWD/.cache/go-tmp" mkdir -p "$GOCACHE" - mkdir -p "$GOTMPDIR" go test -short ./... ' lint: - desc: Run linters for detected language targets ({{.DETECTED_LANGUAGES}}). - cmds: - - task: lint:go - - task: lint:chat - - lint:go: - internal: true - status: - - test ! -f go.mod + desc: Run {{.DETECTED_LANGUAGE}} vet checks. cmds: + - task --list >/dev/null - | bash -euo pipefail -c ' export GOCACHE="$PWD/.cache/go-build" - export GOTMPDIR="$PWD/.cache/go-tmp" mkdir -p "$GOCACHE" - mkdir -p "$GOTMPDIR" - git ls-files "*.go" ":!:agentapi-plusplus/**" | xargs gofmt -l | tee /tmp/agentapi-gofmt.out - test ! -s /tmp/agentapi-gofmt.out - go list ./... | xargs go vet - ' - - lint:chat: - internal: true - status: - - test ! -f chat/package.json - cmds: - - | - bash -euo pipefail -c ' - cd chat - if [ ! -d node_modules ]; then - bun install --frozen-lockfile - fi - bun run lint + go list ./... | grep -Ev "/agentapi-plusplus($|/)" | xargs go vet ' clean: - desc: Remove generated build artifacts for detected language targets ({{.DETECTED_LANGUAGES}}). - cmds: - - task: clean:go - - task: clean:chat - - task: clean:docs - - clean:go: - internal: true - status: - - test ! -f go.mod + desc: Remove generated {{.DETECTED_LANGUAGE}} build artifacts. cmds: - | python3 - <<'PY' - from pathlib import Path import os + from pathlib import Path import shutil import subprocess os.environ["GOCACHE"] = str(Path(".cache/go-build").resolve()) - os.environ["GOTMPDIR"] = str(Path(".cache/go-tmp").resolve()) Path(os.environ["GOCACHE"]).mkdir(parents=True, exist_ok=True) - Path(os.environ["GOTMPDIR"]).mkdir(parents=True, exist_ok=True) - subprocess.run(["go", "clean", "-cache", "-testcache"], check=True) - for path in [Path("agentapi"), Path(".cache/go-build"), Path(".cache/go-tmp")]: + subprocess.run(["go", "clean", "-cache", "-testcache"], check=False) + for path in [Path("agentapi"), Path(".cache/go-build")]: if path.is_file() or path.is_symlink(): path.unlink() elif path.is_dir(): - shutil.rmtree(path) - PY - - clean:chat: - internal: true - status: - - test ! -f chat/package.json - cmds: - - | - python3 - <<'PY' - from pathlib import Path - import shutil - - for path in [Path("chat/.next"), Path("chat/out"), Path("chat/.turbo")]: - if path.exists(): - shutil.rmtree(path) - PY - - clean:docs: - internal: true - status: - - test ! -f docs/package.json - cmds: - - | - python3 - <<'PY' - from pathlib import Path - import shutil - - for path in [Path("docs/.vitepress/cache")]: - if path.exists(): - shutil.rmtree(path) + shutil.rmtree(path, ignore_errors=True) PY