Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip - Unify boilerplate #4941

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
20a87eb
Remove boilerplate
eapolinario Feb 23, 2024
a93934f
Copy boilerplate@f2bea1f979b36920e0cfd96d97bd0990616b1a4b
eapolinario Feb 23, 2024
4bea324
Remove flyteadmin/boilerplate
eapolinario Feb 23, 2024
4e1871a
Use parent boilerplate in flyteadmin
eapolinario Feb 23, 2024
bf9676f
Copy boilerplate in Dockerfile.flyteadmin.
eapolinario Feb 23, 2024
c3697c1
Fix linting
eapolinario Feb 24, 2024
017954f
Copy boilerplate in Dockerfile.flytescheduler
eapolinario Feb 24, 2024
495eeb7
Delete boilerplate from component directories
eapolinario Feb 24, 2024
1d981c7
Copy boilerplate in each of the remaining Dockerfile.$COMPONENT
eapolinario Feb 24, 2024
2732643
Remove `update_boilerplate` from all makefiles
eapolinario Feb 24, 2024
a4c17c4
Add make target to help build docker images locally
eapolinario Feb 24, 2024
29ca03f
Run `make goimports-all` followed by `make lint-all`
eapolinario Feb 24, 2024
aa5cc96
Regenerate mocks
eapolinario Feb 24, 2024
c9f245d
Decrease duplication in root Makefile and fix introduction of goimports
eapolinario Feb 24, 2024
4e8b253
Move COMPONENTS to the top of the file
eapolinario Feb 24, 2024
88292e9
Run `make goimports-all`
eapolinario Feb 24, 2024
2273956
Remove boilerplate from flyteplugins
eapolinario Feb 24, 2024
b48176d
Remove boilerplate from flyteidl and flytestdlib
eapolinario Feb 24, 2024
d768183
Remove check from the `build-component-image` make target
eapolinario Feb 24, 2024
0b2a2ae
Run `make generate-all`
eapolinario Feb 24, 2024
2f309c3
Remove goimports make targets and scritpts - rely solely on golangci-…
eapolinario Feb 26, 2024
a93c7b8
Fetch all tags in lint.yml
eapolinario Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.datacatalog
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \

WORKDIR /go/src/github.com/flyteorg/datacatalog

COPY boilerplate ../boilerplate
COPY datacatalog .
COPY flyteadmin ../flyteadmin
COPY flytecopilot ../flytecopilot
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.flyteadmin
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \

WORKDIR /go/src/github.com/flyteorg/flyteadmin

COPY boilerplate ../boilerplate
COPY datacatalog ../datacatalog
COPY flyteadmin .
COPY flytecopilot ../flytecopilot
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.flytecopilot
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apk add git openssh-client make curl

WORKDIR /go/src/github.com/flyteorg/flytecopilot

COPY boilerplate ../boilerplate
COPY datacatalog ../datacatalog
COPY flyteadmin ../flyteadmin
COPY flytecopilot .
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.flytepropeller
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apk add git openssh-client make curl

WORKDIR /go/src/github.com/flyteorg/flytepropeller

COPY boilerplate ../boilerplate
COPY datacatalog ../datacatalog
COPY flyteadmin ../flyteadmin
COPY flytecopilot ../flytecopilot
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.flytescheduler
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN mkdir /artifacts

WORKDIR /go/src/github.com/flyteorg/flyteadmin

COPY boilerplate ../boilerplate
COPY datacatalog ../datacatalog
COPY flyteadmin .
COPY flytecopilot ../flytecopilot
Expand Down
50 changes: 37 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ GIT_HASH := $(shell git rev-parse --short HEAD)
TIMESTAMP := $(shell date '+%Y-%m-%d')
PACKAGE ?=github.com/flyteorg/flytestdlib
LD_FLAGS="-s -w -X $(PACKAGE)/version.Version=$(GIT_VERSION) -X $(PACKAGE)/version.Build=$(GIT_HASH) -X $(PACKAGE)/version.BuildTime=$(TIMESTAMP)"
COMPONENTS := datacatalog flyteadmin flytecopilot flyteidl flyteplugins flytepropeller flytestdlib


.PHONY: cmd/single/dist
cmd/single/dist: export FLYTECONSOLE_VERSION ?= latest
Expand All @@ -26,10 +28,6 @@ compile: cmd/single/dist
linux_compile: cmd/single/dist
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags console -v -o /artifacts/flyte -ldflags=$(LD_FLAGS) ./cmd/

.PHONY: update_boilerplate
update_boilerplate:
@boilerplate/update.sh

.PHONY: kustomize
kustomize:
KUSTOMIZE_VERSION=3.9.2 bash script/generate_kustomize.sh
Expand Down Expand Up @@ -105,13 +103,39 @@ build_native_flyte:
--build-arg FLYTECONSOLE_VERSION=$(FLYTECONSOLE_VERSION) \
--tag flyte-binary:native .

.PHONY: go-tidy
go-tidy:
go-tidy-all: ## Run go mod tidy in all components
go mod tidy
make -C datacatalog go-tidy
make -C flyteadmin go-tidy
make -C flyteidl go-tidy
make -C flytepropeller go-tidy
make -C flyteplugins go-tidy
make -C flytestdlib go-tidy
make -C flytecopilot go-tidy
$(MAKE) $(addsuffix -go-tidy,$(COMPONENTS))

generate-all: ## Run `make generate` on all components
$(MAKE) $(addsuffix -generate,$(COMPONENTS))

lint-all: ## Lint all components
$(MAKE) $(addsuffix -lint,$(COMPONENTS))

test_unit-all: ## Run `make test_unit` on all components
$(MAKE) $(addsuffix -test_unit,$(COMPONENTS))

$(COMPONENTS:%=%-go-tidy):
make -C $(@:-go-tidy=) go-tidy

$(COMPONENTS:%=%-goimports):
make -C $(@:-goimports=) goimports

$(COMPONENTS:%=%-generate):
make -C $(@:-generate=) generate

$(COMPONENTS:%=%-lint):
make -C $(@:-lint=) lint

$(COMPONENTS:%=%-test_unit):
make -C $(@:-test_unit=) test_unit

.PHONY: build-component-image
build-component-image: ## Build a component image
# Check if COMPONENT is set and contained in COMPONENTS
ifndef COMPONENT
$(error COMPONENT environment variable is not set)
endif
@echo "Building $(COMPONENT) image"
@docker buildx build -f Dockerfile.$(COMPONENT) .
24 changes: 9 additions & 15 deletions boilerplate/flyte/golang_test_targets/Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

clean:
rm -rf bin

.PHONY: download_tooling
download_tooling: #download dependencies (including test deps) for the package
@boilerplate/flyte/golang_test_targets/download_tooling.sh
@../boilerplate/flyte/golang_test_targets/download_tooling.sh

.PHONY: generate
generate: download_tooling #generate go code
@boilerplate/flyte/golang_test_targets/go-gen.sh
@../boilerplate/flyte/golang_test_targets/go-gen.sh

.PHONY: go-tidy
go-tidy: ## Runs go mod tidy
go mod tidy

.PHONY: lint
lint: download_tooling #lints the package for common code smells
GL_DEBUG=linters_output,env golangci-lint run --deadline=5m --exclude deprecated -v

# If code is failing goimports linter, this will fix.
# skips 'vendor'
.PHONY: goimports
goimports:
@boilerplate/flyte/golang_test_targets/goimports

.PHONY: mod_download
mod_download: #download dependencies (including test deps) for the package
go mod download
Expand Down Expand Up @@ -50,8 +45,7 @@ test_unit_cover:
test_unit_visual:
go test ./... -coverprofile /tmp/cover.out -covermode=count
go tool cover -html=/tmp/cover.out

.PHONY: test_unit_codecov
test_unit_codecov:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
curl -s https://codecov.io/bash > codecov_bash.sh && bash codecov_bash.sh
21 changes: 10 additions & 11 deletions boilerplate/flyte/golang_test_targets/download_tooling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@ set -e
# List of tools to go get
# In the format of "<cli>:<package>" or ":<package>" if no cli
tools=(
"github.com/EngHabu/mockery/cmd/mockery"
"github.com/flyteorg/flytestdlib/cli/pflags@latest"
"github.com/golangci/golangci-lint/cmd/golangci-lint"
"github.com/daixiang0/gci"
"github.com/alvaroloes/enumer"
"github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
"github.com/EngHabu/mockery/cmd/mockery"
"github.com/flyteorg/flytestdlib/cli/pflags@latest"
"github.com/golangci/golangci-lint/cmd/golangci-lint"
"github.com/daixiang0/gci"
"github.com/alvaroloes/enumer"
"github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
)

tmp_dir=$(mktemp -d -t gotooling-XXX)
echo "Using temp directory ${tmp_dir}"
cp -R boilerplate/flyte/golang_support_tools/* $tmp_dir
cp -R ../boilerplate/flyte/golang_support_tools/* $tmp_dir
pushd "$tmp_dir"

for tool in "${tools[@]}"
do
echo "Installing ${tool}"
GO111MODULE=on go install $tool
for tool in "${tools[@]}"; do
echo "Installing ${tool}"
GO111MODULE=on go install $tool
done

popd
9 changes: 0 additions & 9 deletions boilerplate/flyte/golang_test_targets/goimports

This file was deleted.

3 changes: 0 additions & 3 deletions boilerplate/update.cfg

This file was deleted.

17 changes: 2 additions & 15 deletions datacatalog/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
export REPOSITORY=datacatalog
include boilerplate/flyte/docker_build/Makefile
include boilerplate/flyte/golang_test_targets/Makefile

.PHONY: update_boilerplate
update_boilerplate:
@curl https://raw.githubusercontent.com/flyteorg/boilerplate/master/boilerplate/update.sh -o boilerplate/update.sh
@boilerplate/update.sh
include ../boilerplate/flyte/docker_build/Makefile
include ../boilerplate/flyte/golang_test_targets/Makefile

.PHONY: compile
compile:
Expand All @@ -17,11 +12,3 @@ linux_compile: export CGO_ENABLED ?= 0
linux_compile: export GOOS ?= linux
linux_compile:
go build -o /artifacts/datacatalog ./cmd/

.PHONY: generate
generate:
@go generate ./...

.PHONY: go-tidy
go-tidy:
go mod tidy

This file was deleted.

2 changes: 0 additions & 2 deletions datacatalog/boilerplate/flyte/code_of_conduct/README.rst

This file was deleted.

12 changes: 0 additions & 12 deletions datacatalog/boilerplate/flyte/code_of_conduct/update.sh

This file was deleted.

14 changes: 0 additions & 14 deletions datacatalog/boilerplate/flyte/end2end/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions datacatalog/boilerplate/flyte/end2end/end2end.sh

This file was deleted.

This file was deleted.

Loading
Loading