Cleanup openapi generation (#4331)

Co-authored-by: oauth <woodpecker-bot@obermui.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Anbraten
2024-11-23 09:17:19 +01:00
committed by GitHub
parent 8e0aac4cab
commit 07c8765b72
26 changed files with 296 additions and 235 deletions

View File

@@ -109,15 +109,15 @@ clean: ## Clean build artifacts
clean-all: clean ## Clean all artifacts
rm -rf ${DIST_DIR} web/dist docs/build docs/node_modules web/node_modules
# delete generated
rm -rf docs/docs/40-cli.md docs/swagger.json
rm -rf docs/docs/40-cli.md docs/openapi.json
.PHONY: generate
generate: install-tools generate-swagger ## Run all code generations
generate: install-tools generate-openapi ## Run all code generations
CGO_ENABLED=0 go generate ./...
generate-swagger: install-tools ## Run swagger code generation
swag init -g server/api/ -g cmd/server/swagger.go --outputTypes go -output cmd/server/docs
CGO_ENABLED=0 go generate cmd/server/swagger.go
generate-openapi: install-tools ## Run openapi code generation and format it
go run github.com/swaggo/swag/cmd/swag fmt
CGO_ENABLED=0 go generate cmd/server/openapi.go
generate-license-header: install-tools
addlicense -c "Woodpecker Authors" -ignore "vendor/**" **/*.go
@@ -134,9 +134,6 @@ install-tools: ## Install development tools
hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install mvdan.cc/gofumpt@latest; \
fi ; \
hash swag > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install github.com/swaggo/swag/cmd/swag@latest; \
fi ; \
hash addlicense > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install github.com/google/addlicense@latest; \
fi ; \
@@ -196,7 +193,7 @@ test: test-agent test-server test-server-datastore test-cli test-lib ## Run all
build-ui: ## Build UI
(cd web/; pnpm install --frozen-lockfile; pnpm build)
build-server: build-ui generate-swagger ## Build server
build-server: build-ui generate-openapi ## Build server
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -tags '$(TAGS)' -ldflags '${LDFLAGS}' -o ${DIST_DIR}/woodpecker-server${BIN_SUFFIX} go.woodpecker-ci.org/woodpecker/v2/cmd/server
build-agent: ## Build agent
@@ -343,6 +340,6 @@ spellcheck:
.PHONY: docs
docs: ## Generate docs (currently only for the cli)
CGO_ENABLED=0 go generate cmd/cli/app.go
CGO_ENABLED=0 go generate cmd/server/swagger.go
CGO_ENABLED=0 go generate cmd/server/openapi.go
endif