-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: spacewander <[email protected]>
- Loading branch information
1 parent
f3ea6c2
commit 4b7211e
Showing
141 changed files
with
1,762 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright The HTNN Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SHELL = /bin/bash | ||
OS = $(shell uname) | ||
IN_CI ?= | ||
|
||
TARGET_SO = libgolang.so | ||
PROJECT_NAME = mosn.io/htnn/api | ||
BUILD_IMAGE ?= golang:1.21-bullseye | ||
|
||
MOUNT_GOMOD_CACHE = -v $(shell go env GOPATH):/go | ||
ifeq ($(IN_CI), true) | ||
# Mount go mod cache in the CI environment will cause 'Permission denied' error | ||
# when accessing files on host in later phase because the mounted directory will | ||
# have files which is created by the root user in Docker. | ||
# Run as low privilege user in the Docker doesn't | ||
# work because we also need root to create /.cache in the Docker. | ||
MOUNT_GOMOD_CACHE = | ||
endif | ||
|
||
# We can't specify -race to `go build` because it seems that | ||
# race detector assumes that the executable is loaded around the 0 address. When loaded by the Envoy, | ||
# the race detector will allocate memory out of 48bits address which is not allowed in x64. | ||
.PHONY: build-test-so-local | ||
build-test-so-local: | ||
CGO_ENABLED=1 go build -tags so \ | ||
-ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${VERSION}(${GIT_VERSION})" \ | ||
--buildmode=c-shared \ | ||
-cover -covermode=atomic -coverpkg=./... \ | ||
-v -o plugins/tests/integration/${TARGET_SO} \ | ||
${PROJECT_NAME}/plugins/tests/integration/libgolang | ||
|
||
# Go 1.19+ adds vcs check which will cause error "fatal: detected dubious ownership in repository at '...'". | ||
# So here we disable the error via git configuration when running inside Docker. | ||
.PHONY: build-test-so | ||
build-test-so: | ||
docker run --rm ${MOUNT_GOMOD_CACHE} -v $(PWD):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} \ | ||
-e GOPROXY \ | ||
${BUILD_IMAGE} \ | ||
bash -c "git config --global --add safe.directory '*' && make build-test-so-local" | ||
|
||
.PHONY: integration-test | ||
integration-test: | ||
test -d /tmp/htnn_coverage && rm -rf /tmp/htnn_coverage || true | ||
$(foreach PKG, $(shell go list ./plugins/tests/integration/...), \ | ||
go test -v ${PKG} || exit 1; \ | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.