diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index e05331829f..a8d3cc3ea7 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -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: diff --git a/.gitignore b/.gitignore index 5ed1a0c03d..80441fb447 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **/.DS_Store bin/ +coverage.xml diff --git a/Makefile.targets.mk b/Makefile.targets.mk index 8328ecbfcf..4af22a8c7c 100644 --- a/Makefile.targets.mk +++ b/Makefile.targets.mk @@ -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-%: + @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