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>
Signed-off-by: Amit Singh <singhamitch@outlook.com>
  • Loading branch information
charlie0129 authored and semmet95 committed May 10, 2023
1 parent ebfbca9 commit 352d4e9
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 245 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/go-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
GOLANGCI_VERSION: 'v1.49.0'
USE_BUILD_CONTAINER: '1'

jobs:
detect-noop:
Expand Down Expand Up @@ -72,4 +73,4 @@ jobs:
${{ runner.os }}-gobuildcontainer-
- name: Test Container Build
run: make trigger-container-build
run: make container
7 changes: 3 additions & 4 deletions .github/workflows/release-binary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:

env:
GO_VERSION: '1.19'
USE_BUILD_CONTAINER: '1'

jobs:
kube-trigger:
Expand Down Expand Up @@ -43,7 +44,7 @@ jobs:
id: get_version
run: |
VERSION=$(make trigger-version)
echo ::set-output name=VERSION::${VERSION}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Build Binaries for All Platforms
run: make trigger-all-package
Expand All @@ -55,6 +56,4 @@ jobs:
fail_on_unmatched_files: true
prerelease: ${{ contains(steps.get_version.outputs.VERSION, 'alpha') || contains(steps.get_version.outputs.VERSION, 'beta') }}
files: |
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*.zip
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/kube-trigger-*.tar.gz
bin/kube-trigger-${{ steps.get_version.outputs.VERSION }}/*-checksums.txt
bin/kube-trigger-packages-latest/*
7 changes: 5 additions & 2 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- "v*"
workflow_dispatch: { }

env:
USE_BUILD_CONTAINER: '1'

jobs:
kube-trigger:
name: Release kube-trigger Images
Expand Down Expand Up @@ -56,7 +59,7 @@ jobs:
run: make trigger-variables

- name: Build and Push Images
run: make trigger-all-container-build-push
run: make trigger-all-container-push

manager:
name: Release manager Images
Expand Down Expand Up @@ -105,4 +108,4 @@ jobs:
run: make manager-variables

- name: Build and Push Images
run: make manager-all-container-build-push
run: make manager-all-container-push
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:
run: minikube start

- name: Run tests
run: make test
run: make test
98 changes: 0 additions & 98 deletions .github/workflows/upload-test-binary.yaml

This file was deleted.

11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# macOS leaves these everywhere on SMB shares
._*

# macOS trash
# macOS misc
.DS_Store

# Eclipse files
Expand Down Expand Up @@ -61,12 +60,10 @@ bin
# etcd
default.etcd

# Generated Dockerfile
# This is automatically generated by Make depending on which image you want to build.
Dockerfile
*.tmp

vendor

# Generated docker ignore
# This is automatically generated by Make depending on which image you want to build.
.dockerignore

vendor
2 changes: 1 addition & 1 deletion Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ ARG TARGETOS
ARG OS
ARG VERSION

COPY bin/${BIN}-${VERSION}/${BIN}-${VERSION}-${TARGETOS:-${OS:-linux}}-${TARGETARCH:-${ARCH:-amd64}} /${BIN}
COPY ${BIN}-${VERSION}-${TARGETOS:-${OS:-linux}}-${TARGETARCH:-${ARCH:-amd64}} /${BIN}

ENTRYPOINT ["/${BIN}"]
91 changes: 59 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,57 @@ include makefiles/common.mk

# ===== Common Targets for subprojects (trigger and manager) ======

SUBPROJS := $(patsubst %.mk,%,$(wildcard *.mk))
SUBPROJS := $(patsubst %.mk, %, $(wildcard *.mk))

# Run `make TARGET' to run TARGET for both foo and bar.
# For example, `make build' will build both foo and bar binaries.

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

# Default target, subprojects will be called with default target too
all: $(addprefix mk-all.,$(SUBPROJS));

# Default target for subprojects. make foo / make bar
$(foreach p,$(SUBPROJS),$(eval \
$(p): mk-all.$(p); \
))

# 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)));

# `help' is handled separately to show targets in this file.
help: # @HELP show general help message
help:
echo "GENERAL_TARGETS:"
grep -E '^.*: *# *@HELP' $(firstword $(MAKEFILE_LIST)) \
| sed -E 's_.*.mk:__g' \
| awk ' \
BEGIN {FS = ": *# *@HELP"}; \
{ printf " %-23s %s\n", $$1, $$2 }; \
'
echo
echo "Please run 'make all-help' to see the full help message for all subprojects."

all-help: # @HELP show help messages for all subjects
all-help: $(addprefix mk-help.,$(SUBPROJS))

# Run `make TARGET' to run TARGET for both kube-trigger and manager.
# For example, `make build' will build both kube-trigger and manager binaries.
Expand All @@ -33,58 +83,35 @@ $(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 ., ,$*))

# ===== Misc Targets ======
# ===== General Targets ======

# Go packages to lint or test
GOCODEDIR := ./api/... ./cmd/... ./controllers/... ./pkg/...

# Call `make generate' on all subprojects
generate: # @HELP generate code
generate: $(addprefix mk-generate.,$(SUBPROJS))

# Lint code
lint: # @HELP lint code
lint:
build/lint.sh $(GOCODEDIR)

# Check file header
checklicense: # @HELP check file header
checklicense:
hack/verify-boilerplate.sh

# Format svg images
svgformat: # @HELP format svg images, used in docs
svgformat:
hack/format-svg-image.sh

# Check possible issues before committing code
reviewable: # @HELP check possible issues before committing code, make your code ready to review
reviewable: generate checklicense lint
go mod tidy

# Run tests
test: # @HELP run tests
test: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
go test -coverprofile=cover.out $(GOCODEDIR)
Expand Down
6 changes: 3 additions & 3 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export GOOS="${OS}"
export GO111MODULE=on
export GOFLAGS="${GOFLAGS:-} -mod=mod "

printf "# BINARY output: %s\ttarget: %s/%s\tversion: %s\n" \
printf "# BUILD output: %s\ttarget: %s/%s\tversion: %s\n" \
"${OUTPUT}" "${OS}" "${ARCH}" "${VERSION}"

printf "# BINARY building for "
printf "# BUILD building for "

if [ -z "${DEBUG:-}" ]; then
if [ "${DEBUG:-}" != "1" ]; then
# release build
# trim paths, disable symbols and DWARF.
goasmflags="all=-trimpath=$(pwd)"
Expand Down
Loading

0 comments on commit 352d4e9

Please sign in to comment.