Skip to content

Commit

Permalink
ci: Fix codegen job (argoproj#2648)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Apr 8, 2020
1 parent a78ecb7 commit 8c29e05
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ E2E_EXECUTOR ?= pns
SWAGGER_FILES := $(shell find pkg/apiclient -name '*.swagger.json' | env LC_COLLATE=C sort)
MOCK_FILES := $(shell find . -maxdepth 4 -not -path '*/vendor/*' -path '*/mocks/*' -type f)

define backup_go_mod
# Back-up go.*, but only if we have not already done this (because that would suggest we failed mid-codegen and the currenty go.* files are borked).
@mkdir -p dist
[ -e dist/go.mod ] || cp go.mod go.sum dist/
endef
define restore_go_mod
# Restore the back-ups.
mv dist/go.mod dist/go.sum .
endef

.PHONY: build
build: status clis executor-image controller-image manifests/install.yaml manifests/namespace-install.yaml manifests/quick-start-postgres.yaml manifests/quick-start-mysql.yaml

Expand Down Expand Up @@ -212,25 +222,26 @@ endif
# generation

$(HOME)/go/bin/mockery:
$(call backup_go_mod)
go get github.com/vektra/mockery/.../
$(call restore_go_mod)

dist/update-mocks: $(HOME)/go/bin/mockery $(MOCK_FILES)
./hack/update-mocks.sh $(MOCK_FILES)
@mkdir -p dist
touch dist/update-mocks


.PHONY: codegen
codegen: dist/update-mocks
# Back-up go.*, but only if we have not already done this (because that would suggest we failed mid-codegen and the currenty go.* files are borked).
[[ -e dist/go.mod ]] || cp go.mod go.sum dist/
$(call backup_go_mod)
# We need the folder for compatibility
go mod vendor
# Generate proto
./hack/generate-proto.sh
# Updated codegen
./hack/update-codegen.sh
# Restore the back-ups.
mv dist/go.mod dist/go.sum .
$(call restore_go_mod)
make api/openapi-spec/swagger.json

.PHONY: manifests
Expand Down Expand Up @@ -267,8 +278,8 @@ lint: server/static/files.go $(HOME)/go/bin/golangci-lint
go mod tidy
# Lint Go files
golangci-lint run --fix --verbose --concurrency 4 --timeout 5m
ifeq ($(CI),false)
# Lint UI files
ifeq ($(CI),false)
yarn --cwd ui lint
endif

Expand Down Expand Up @@ -435,7 +446,9 @@ clean:
# swagger

$(HOME)/go/bin/swagger:
$(call backup_go_mod)
go get github.com/go-swagger/go-swagger/cmd/swagger
$(call restore_go_mod)

api/openapi-spec/swagger.json: $(HOME)/go/bin/swagger $(SWAGGER_FILES) dist/MANIFESTS_VERSION hack/swaggify.sh
swagger mixin -c 412 $(SWAGGER_FILES) | sed 's/VERSION/$(MANIFESTS_VERSION)/' | ./hack/swaggify.sh > api/openapi-spec/swagger.json
Expand Down

0 comments on commit 8c29e05

Please sign in to comment.