Skip to content

fix(build): auto-run api-gen when generated files are missing#18

Merged
isaacrowntree merged 2 commits into
triptechtravel:mainfrom
neptunix:fix/build-without-codegen
May 27, 2026
Merged

fix(build): auto-run api-gen when generated files are missing#18
isaacrowntree merged 2 commits into
triptechtravel:mainfrom
neptunix:fix/build-without-codegen

Conversation

@neptunix
Copy link
Copy Markdown
Contributor

@neptunix neptunix commented May 8, 2026

Problem

go build fails after a plain git clone because the generated API files (api/clickupv{2,3}/*.gen.go, internal/apiv{2,3}/operations.gen.go) are gitignored. This produces 14 compile errors for types that only exist in the generated code:

internal/apiv3/chat.go: undefined: GetChatChannelsParams
pkg/cmdutil/status.go: undefined: apiv2.GetSpace
... (14 total)

Any Dockerfile or CI pipeline that does git clone && go build is broken.

Fix

One line added to the build target — if the generated files are absent, run make api-gen first:

build:
	@[ -f api/clickupv3/client.gen.go ] || $(MAKE) api-gen
	go build ...

Verification

git clone https://github.com/triptechtravel/clickup-cli && cd clickup-cli
rm -f api/clickupv2/*.gen.go api/clickupv3/*.gen.go internal/apiv*/operations.gen.go
make build   # triggers api-gen then builds successfully

`go build` fails after a plain `git clone` because the generated API
files are gitignored. Add a guard to the `build` target that runs
`make api-gen` automatically if the files are absent, so
`git clone && make build` works out of the box.
Copy link
Copy Markdown
Contributor

@isaacrowntree isaacrowntree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful fix — solves the real "fresh clone → 14 compile errors" problem with minimal surface area.

Suggestion: apply the same guard to install and test

Both targets have the identical fresh-clone problem. Could either repeat the guard or factor it out:

```makefile
.PHONY: ensure-gen
ensure-gen:
@[ -f api/clickupv3/client.gen.go ] || $(MAKE) api-gen

build: ensure-gen
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/clickup

install: ensure-gen
go install -ldflags "$(LDFLAGS)" ./cmd/clickup

test: ensure-gen
go test ./...
```

Other note: this silently adds a network dependency to make build on fresh clones (api-gen curls the OpenAPI specs from developer.clickup.com). Acceptable since the alternative is failing the build outright, but worth a line in the README so airgapped/offline builders aren't surprised.

LGTM otherwise.

The original auto-gen guard only covered `make build`. Extract it into
a phony `ensure-gen` target so `install` and `test` also work after a
fresh clone without manual `make api-gen`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@isaacrowntree isaacrowntree merged commit 17625f6 into triptechtravel:main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants