Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 7 additions & 14 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,19 @@ jobs:
run: |
MAKE_IN_DOCKER=1 make lint-yamllint
- name: Run Codespell
uses: codespell-project/actions-codespell@master
with:
# can't reuse tools/codespell/.codespell.skip, shell is not supported
skip: .git,*.png,*.woff,*.woff2,*.eot,*.ttf,*.jpg,*.ico,*.svg,go.mod,go.sum
ignore_words_file: 'tools/codespell/.codespell.ignorewords'
check_filenames: true
check_hidden: true
run: |
MAKE_IN_DOCKER=1 make lint-codespell
- name: Run Golangci-lint
run: |
MAKE_IN_DOCKER=1 make lint-golint
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.46.2
args: --build-tags=e2e
- name: Build
run: make build-all
run: make build
- name: Test and report coverage
run: go test ./... -race -coverprofile=coverage.xml -covermode=atomic
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/.DS_Store
bin/
coverage.xml
26 changes: 16 additions & 10 deletions Makefile.targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,30 @@ help: ## Display this help

##@ Build

.PHONY: build
build: ## Build the envoy-gateway binary
@CGO_ENABLED=0 go build -a -o ./bin/${GOOS}/${GOARCH}/ github.com/envoyproxy/gateway/cmd/envoy-gateway
SUPPORT_ARCHS ?= amd64 arm64
SUPPORT_PLATFORM ?= linux darwin
# Generate three targets: build-${PLATFORM}-${ARCH}
# Run make build -n to see the result with dry run.
BUILD_BINARY_ARCHS = $(foreach TMP, $(SUPPORT_PLATFORM),$(addprefix build-$(TMP)-, $(SUPPORT_ARCHS)))

build-linux-amd64:
@GOOS=linux GOARCH=amd64 $(MAKE) build
# split by dash, $1 means index which starts from 1, $2 means the whole word
word-dash = $(word $2,$(subst -, ,$1))

build-linux-arm64:
@GOOS=linux GOARCH=arm64 $(MAKE) build
.PHONY: build $(BUILD_BINARY_ARCHS)
build: $(BUILD_BINARY_ARCHS) ## Build the envoy-gateway binary.
$(BUILD_BINARY_ARCHS): build-%:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks darwin binaries

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now make build replaces make build-all as build-all only support Linux, I will update for darwin,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might end up building something similar to what @Xunzhuo already did in #113, lets wait for @Xunzhuo to wrap up #113 and then see if any more optimizations are needed.
thanks !

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now:

root:[gateway]$ MAKE_IN_DOCKER=0 make build -n
make -f Makefile.targets.mk build
make[1]: Entering directory '/root/github/gateway'
CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" go build -a -o ./bin/linux/amd64/ github.com/envoyproxy/gateway/cmd/envoy-gateway
CGO_ENABLED=0 GOOS="linux" GOARCH="arm64" go build -a -o ./bin/linux/amd64/ github.com/envoyproxy/gateway/cmd/envoy-gateway
CGO_ENABLED=0 GOOS="darwin" GOARCH="amd64" go build -a -o ./bin/linux/amd64/ github.com/envoyproxy/gateway/cmd/envoy-gateway
CGO_ENABLED=0 GOOS="darwin" GOARCH="arm64" go build -a -o ./bin/linux/amd64/ github.com/envoyproxy/gateway/cmd/envoy-gateway
make[1]: Leaving directory '/root/github/gateway'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might end up building something similar to what @Xunzhuo already did in #113, lets wait for @Xunzhuo to wrap up #113 and then see if any more optimizations are needed. thanks !

Sure, I can wait.

Copy link
Copy Markdown
Member Author

@daixiang0 daixiang0 Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arkodg seems my implementation looks easier to maintain, please take a look, feel free to pick one.

@CGO_ENABLED=0 GOOS="$(call word-dash,$*,1)" GOARCH="$(call word-dash,$*,2)" go build -a -o ./bin/${GOOS}/${GOARCH}/ github.com/envoyproxy/gateway/cmd/envoy-gateway

build-all: build-linux-amd64 build-linux-arm64
.PHONY: clean
clean: ## Clean the build output directory.
@rm -rf bin

.PHONY: test
test:
@go test ./...
@go test ./... -race -coverprofile=coverage.xml -covermode=atomic

.PHONY: docker-build
docker-build: build-all ## Build the envoy-gateway docker image.
docker-build: build ## Build the envoy-gateway docker image.
@DOCKER_BUILDKIT=1 docker build -t $(IMAGE):$(TAG) -f Dockerfile bin

.PHONY: docker-push
Expand Down