Skip to content

Commit

Permalink
create a separate api module
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Mar 25, 2024
1 parent f3ea6c2 commit 4b7211e
Show file tree
Hide file tree
Showing 141 changed files with 1,762 additions and 616 deletions.
3 changes: 2 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ coverage:
if_ci_failed: error
ignore:
# test files
- "plugins/tests"
- "api/plugins/tests"
- "plugins/tests/"
- "controller/tests"
- "e2e/"
- "**/mock.go"
Expand Down
7 changes: 2 additions & 5 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,22 @@ header:
- '**/*.yaml'
- '**/*.yml'
- '**/*.toml'
# ignore generated file
- '**/*.pb.go'
- '**/*.pb.validate.go'
- 'zz_generated.deepcopy.go'
# ignore file controlled by tools
- '**/go.mod'
- '**/go.sum'
- 'buf.lock'
- 'controller/PROJECT'
# files can't add license
- '**/*.pb.validate.go'
- '**/*.json'
- '**/*.txt'
- 'VERSION'
- '.ignore_words'
# files from other projects
- 'site/assets/**'
- 'site/layouts/**'
- 'api/internal/cookie/cookie.go'
- 'controller/registries/nacos/config.go'
- 'pkg/cookie/cookie.go'
comment: on-failure
# remove below once skywalking-eyes v0.6.0 is released
language:
Expand Down
59 changes: 59 additions & 0 deletions api/Makefile
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; \
)
226 changes: 226 additions & 0 deletions api/internal/consumer/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4b7211e

Please sign in to comment.