Skip to content

Commit

Permalink
Build: update build infra (kubevela#40)
Browse files Browse the repository at this point in the history
* update build infra

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

* update docs

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

* update docs

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

* update docs

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

* update docs

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>

---------

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
  • Loading branch information
charlie0129 authored and semmet95 committed May 10, 2023
1 parent 7ff63ed commit bc9fbd5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 157 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/go-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ on:
workflow_dispatch: { }

env:
GO_VERSION: '1.19'
# Keep this in sync with build/lint.sh
GOLANGCI_VERSION: '1.49.0'
GOLANGCI_VERSION: 'v1.49.0'
USE_BUILD_CONTAINER: '1'

jobs:
Expand Down Expand Up @@ -82,3 +80,4 @@ jobs:
- name: Test Container Build
run: make container
run: make container
10 changes: 0 additions & 10 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,3 @@ jobs:

- name: Run tests
run: make test

- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cover.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
98 changes: 0 additions & 98 deletions .github/workflows/upload-test-binary.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,6 @@ $(foreach p,$(SUBPROJS),$(eval \
$(p)-%: mk-%.$(p); \
))

# Common targets for subprojects, will be executed on all subprojects
TARGETS := build \
all-build \
package \
all-package \
container-build \
container-push \
all-container-build-push \
clean \
all-clean \
version \
imageversion \
binaryname \
variables \
help

# Run common targets on all subprojects
$(foreach t,$(TARGETS),$(eval \
$(t): $(addprefix mk-$(t).,$(SUBPROJS)); \
))

# `shell' only needs to be executed once, not on every subproject
shell: $(addprefix mk-shell.,$(word 1,$(SUBPROJS)));

mk-%:
echo "# make -f $(lastword $(subst ., ,$*)).mk $(firstword $(subst ., ,$*))"
$(MAKE) -f $(lastword $(subst ., ,$*)).mk $(firstword $(subst ., ,$*))
Expand Down
8 changes: 3 additions & 5 deletions hack/boilerplate/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ def file_extension(filename):

skipped_dirs = [
".git",
".go/gocache",
".go/gomodcache",
".go",
".idea",
".vscode",
"default.etcd",
"docs",
"build",
"bin",
"pkg/workqueue",
"vendors",
"bin",
"vendor",
]

# list all the files contain 'DO NOT EDIT', but are not generated
Expand Down
15 changes: 9 additions & 6 deletions makefiles/consts.mk
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ ifeq ($(OS), windows)
endif

# This holds build output and helper tools
DIST := bin
# This holds build cache
GOCACHE := .go
BIN_VERBOSE_DIR := $(DIST)/$(BIN)-$(VERSION)
# Full output path
OUTPUT := $(if $(FULL_NAME),$(BIN_VERBOSE_DIR)/$(BIN_FULLNAME),$(DIST)/$(BIN_FULLNAME))
DIST := bin
# This holds build cache, if build container is used
GOCACHE := .go
# Full output directory
BIN_OUTPUT_DIR := $(DIST)/$(BIN)-$(VERSION)
PKG_OUTPUT_DIR := $(BIN_OUTPUT_DIR)/packages
# Full output path with filename
OUTPUT := $(BIN_OUTPUT_DIR)/$(BIN_FULLNAME)
PKG_OUTPUT := $(PKG_OUTPUT_DIR)/$(PKG_FULLNAME)
29 changes: 18 additions & 11 deletions makefiles/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ all: build
# ===== BUILD =====

build-dirs:
ifeq (1, $(USE_BUILD_CONTAINER))
mkdir -p "$(GOCACHE)/gocache" \
"$(GOCACHE)/gomodcache" \
"$(DIST)"
"$(GOCACHE)/gomodcache"
endif
mkdir -p "$(BIN_OUTPUT_DIR)"

build: # @HELP build binary for current platform
build: # @HELP (default) build binary for current platform
build: gen-dockerignore build-dirs
ifeq (1, $(USE_BUILD_CONTAINER))
echo "# BUILD using build container: $(BUILD_IMAGE)"
docker run \
-i \
--rm \
--network host \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src \
Expand Down Expand Up @@ -105,13 +110,14 @@ all-package: $(addprefix package-, $(subst /,_, $(BIN_PLATFORMS)))

# ===== CONTAINERS =====

container-build: # @HELP build container image for current platform
container: # @HELP build container image for current platform
container: container-build
container-build: build-linux_$(ARCH)
printf "# CONTAINER repotags: %s\ttarget: %s/%s\tbinaryversion: %s\n" "$(IMAGE_REPO_TAGS)" "linux" "$(ARCH)" "$(VERSION)"
printf "# CONTAINER tag: %s\tname: %s\trepos: %s\tarch: %s\n" "$(IMAGE_TAG)" "$(IMAGE_NAME)" "$(IMAGE_REPOS)" "linux/$(ARCH)"
if [ "$(OS)" != "linux" ]; then \
echo "# CONTAINER warning: you have set target os to $(OS), but container target os will always be linux"; \
echo "# CONTAINER warning: container target os $(OS) is not valid, only linux is allowed and will be used"; \
fi; \
TMPFILE=Dockerfile && \
TMPFILE=Dockerfile.tmp && \
sed 's/$${BIN}/$(BIN)/g' Dockerfile.in > $${TMPFILE} && \
DOCKER_BUILDKIT=1 \
docker build \
Expand All @@ -121,7 +127,7 @@ container-build: build-linux_$(ARCH)
--build-arg "OS=linux" \
--build-arg "VERSION=$(VERSION)" \
--build-arg "BASE_IMAGE=$(BASE_IMAGE)" \
$(addprefix -t ,$(IMAGE_REPO_TAGS)) .
$(addprefix -t ,$(IMAGE_REPO_TAGS)) $(BIN_OUTPUT_DIR)

container-push: # @HELP push built container image to all repos
container-push: $(addprefix container-push-, $(subst :,=, $(subst /,_, $(IMAGE_REPO_TAGS))))
Expand Down Expand Up @@ -151,12 +157,13 @@ all-container-push: $(addprefix build-, $(subst /,_, $(IMAGE_PLATFORMS)))
# Example: make shell CMD="-c 'date'"
CMD ?=

shell: # @HELP launches a shell in the containerized build environment
shell: # @HELP launch a shell in the build container
shell: build-dirs
echo "# launching a shell in the containerized build environment"
echo "# launching a shell in the build container"
docker run \
-it \
--rm \
--network host \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src \
Expand Down Expand Up @@ -190,7 +197,7 @@ clean:
all-clean: # @HELP clean built binaries, build cache, and helper tools
all-clean: clean
test -d $(GOCACHE) && chmod -R u+w $(GOCACHE) || true
rm -rf $(GOCACHE) $(DIST)
$(RM) -r $(GOCACHE) $(DIST)

version: # @HELP output the version string
version:
Expand Down

0 comments on commit bc9fbd5

Please sign in to comment.