Skip to content

Development setup

This page outlines how to set up your development environment to build and develop with the DataRobot CLI.

GitHub CLI Recommendation: DataRobot recommends using the GitHub CLI (gh) for fork management. All examples use gh commands. See the GitHub CLI installation guide if needed. If you prefer manual git workflow, you can replace gh commands with equivalent git operations.

Prerequisites

Installation

Install task

Task is required for running development tasks.

macOS

brew install go-task/tap/go-task

Linux

sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin

Windows

choco install go-task

Set up the development environment

Clone the repository

# Fork and clone in one command
gh repo fork datarobot-oss/cli --clone --default-branch-only
cd cli

Install development tools

task dev-init

This will install all necessary development tools including linters and code formatters.

Install git hooks

task dev-init

task dev-init runs lefthook install automatically, which sets up git hooks that run quality checks before each commit. The hooks reuse Taskfile tasks (task precommit, task dupcheck) so checks are always consistent between local commits and CI. See Git hooks (lefthook) below for details.

Build the CLI

task build

The binary will be available at ./dist/dr.

Verify the build

./dist/dr self version

Available development tasks

To view all available tasks:

task --list

Common tasks

Task Description
task build Build the CLI binary.
task test Run all tests.
task test-coverage Run tests with a coverage report.
task lint Run linters and code formatters.
task fmt Format code.
task clean Cleanly build artifacts.
task dev-init Set up a development environment.
task install-tools Install development tools.
task run Run the CLI without building (e.g., task run -- templates list).
task dupcheck Check for duplicate code (jscpd).
task precommit Run pre-commit checks (format, tidy, vet, lint new changes).

Build the CLI

Always use task build for building the CLI. This ensures that:

  • The version information from git is included
  • The git commit hash is embedded
  • The build timestamp is recorded
  • The proper ldflags configuration is applied
# Standard build (recommended)
task build

# Run without building (for quick testing)
task run -- templates list

Running tests

# Run all tests (both unit and integration)
task test

# Run tests with coverage
task test-coverage

# Run specific test
go test ./cmd/auth/...

Linting and formatting

For linting and formatting, this project uses the following tools:

  • golangci-lint for comprehensive linting
  • go fmt for basic formatting
  • go vet for suspicious constructs
  • goreleaser check for release configuration validation
# Run all linters (includes formatting)
task lint

# Format code only
task fmt

Updating golangci-lint

When upgrading the Go version in go.mod, update golangci-lint if needed:

# 1. Check available versions at https://github.com/golangci/golangci-lint/releases
# 2. Update GOLANGCI_LINT_VERSION in Taskfile.yaml
# 3. Reinstall the binary
task install-tools

# 4. Verify linting works
task lint

golangci-lint is installed as a pre-built binary, so version mismatches with your project's Go version are handled automatically.

Git hooks (lefthook)

Lefthook enforces quality checks before each commit. It is a Go binary installed by task install-tools and wired up by task dev-init (which runs lefthook install).

Hooks run automatically on git commit. Run manually with task precommit. Bypass with LEFTHOOK=0 git commit (use sparingly). Configured hooks:

  • task precommit: formats via gofumpt, verifies Go files are formatted, runs go mod tidy, go vet, and golangci-lint run --new-from-rev HEAD (new changes only), verifies golangci-lint config, and checks go.mod/go.sum are tidy
  • task dupcheck: duplicate code detection via jscpd (threshold and exclusions in .jscpd.json)

Both hooks reuse Taskfile tasks so there is a single source of truth for quality checks. Configuration lives in lefthook.yml at the repository root.

Next steps