|
| 1 | +# Development Setup |
| 2 | + |
| 3 | +This guide covers setting up a macOS workstation for TFx development from scratch. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Install [Homebrew](https://brew.sh) if you don't have it: |
| 8 | + |
| 9 | +```bash |
| 10 | +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 11 | +``` |
| 12 | + |
| 13 | +## Install Dependencies |
| 14 | + |
| 15 | +Install the core tools: |
| 16 | + |
| 17 | +```bash |
| 18 | +brew install go goreleaser go-task |
| 19 | +``` |
| 20 | + |
| 21 | +| Tool | Purpose | |
| 22 | +|---|---| |
| 23 | +| `go` | Go compiler and toolchain | |
| 24 | +| `goreleaser` | Cross-platform builds and releases | |
| 25 | +| `go-task` | Task runner (provides the `task` command) | |
| 26 | + |
| 27 | +### Optional |
| 28 | + |
| 29 | +```bash |
| 30 | +brew install node # only needed for serving the docs site locally (task serve-docs) |
| 31 | +``` |
| 32 | + |
| 33 | +Verify everything is installed: |
| 34 | + |
| 35 | +```bash |
| 36 | +task doctor |
| 37 | +``` |
| 38 | + |
| 39 | +## Clone and Build |
| 40 | + |
| 41 | +```bash |
| 42 | +git clone https://github.com/straubt1/tfx.git |
| 43 | +cd tfx |
| 44 | +go mod download |
| 45 | +task go-build |
| 46 | +./tfx version |
| 47 | +``` |
| 48 | + |
| 49 | +## Common Tasks |
| 50 | + |
| 51 | +Run `task --list` to see all available tasks. Key ones: |
| 52 | + |
| 53 | +| Task | Description | |
| 54 | +|---|---| |
| 55 | +| `task doctor` | Verify all required tools are installed | |
| 56 | +| `task go-build` | Build the `tfx` binary for local development | |
| 57 | +| `task go-build-all` | Cross-platform snapshot build via goreleaser | |
| 58 | +| `task test` | Run unit tests | |
| 59 | +| `task test-all` | Run unit + integration tests | |
| 60 | +| `task go-upgrade` | Upgrade Go toolchain and all module dependencies | |
| 61 | +| `task serve-docs` | Serve the documentation site locally | |
| 62 | +| `task release-dry-run` | Simulate the full release pipeline locally | |
| 63 | + |
| 64 | +## Upgrading Dependencies |
| 65 | + |
| 66 | +To upgrade Go, goreleaser, and all module dependencies: |
| 67 | + |
| 68 | +```bash |
| 69 | +task go-upgrade |
| 70 | +``` |
| 71 | + |
| 72 | +This will: |
| 73 | +1. Upgrade `go` and `goreleaser` via Homebrew |
| 74 | +2. Update `go.mod` to the installed Go version |
| 75 | +3. Upgrade all module dependencies to their latest versions |
| 76 | +4. Run `go mod tidy` to clean up |
| 77 | + |
| 78 | +## Configuration for CLI / Integration Tests |
| 79 | + |
| 80 | +TFx requires a TFE/HCP Terraform instance for integration tests. Create `secrets/.env-int`: |
| 81 | + |
| 82 | +```bash |
| 83 | +mkdir -p secrets |
| 84 | +cat > secrets/.env-int << 'EOF' |
| 85 | +TFE_HOSTNAME=app.terraform.io |
| 86 | +TFE_TOKEN=your-api-token |
| 87 | +TFE_ORGANIZATION=your-org |
| 88 | +EOF |
| 89 | +``` |
| 90 | + |
| 91 | +Then run integration tests: |
| 92 | + |
| 93 | +```bash |
| 94 | +task test-integration-data |
| 95 | +task test-integration-cmd |
| 96 | +``` |
| 97 | + |
| 98 | +## Project Structure |
| 99 | + |
| 100 | +``` |
| 101 | +cmd/ # Cobra command handlers |
| 102 | + flags/ # Per-command flag structs |
| 103 | + views/ # Output/rendering for each command |
| 104 | +client/ # TFE API client wrapper |
| 105 | +data/ # Data fetching layer (API calls + business logic) |
| 106 | +output/ # Output system (tables, JSON, spinner, logger) |
| 107 | +tui/ # Bubble Tea TUI |
| 108 | +integration/ # Integration tests |
| 109 | +pkg/file/ # File utilities |
| 110 | +version/ # Version info (injected at build time) |
| 111 | +``` |
| 112 | + |
| 113 | +## Releasing |
| 114 | + |
| 115 | +See the release tasks: |
| 116 | + |
| 117 | +```bash |
| 118 | +task release:patch # bugfixes (x.y.Z+1) |
| 119 | +task release:minor # new features (x.Y+1.0) |
| 120 | +task release:major # breaking changes (X+1.0.0) |
| 121 | +``` |
| 122 | + |
| 123 | +Always update `CHANGELOG.md` before cutting a release. |
0 commit comments