diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..10e61cd7c --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,76 @@ +name: "Build and Test" + +on: + push: + branches: [ main ] + pull_request: + branches: ["*"] + +jobs: + #TODO(@Xunzhuo): add lint tools to do static code analyse. + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + coverage-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # test + - name: Run Coverage Tests + run: GOPROXY="https://proxy.golang.org,direct" make go.test.coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true + files: ./coverage.xml + verbose: true + + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + needs: [lint,coverage-test] + strategy: + matrix: + golang: + - 1.19 + steps: + - name: "Setup Go" + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: "checkout ${{ github.ref }}" + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: "Build Higress Binary" + run: GOPROXY="https://proxy.golang.org,direct" make build + + - name: Upload Higress Binary + uses: actions/upload-artifact@v3 + with: + name: higress + path: out/ + + conformance-test: + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v3 + + e2e-test: + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v3 + + publish: + runs-on: ubuntu-latest + needs: [conformance-test,e2e-test] + steps: + - uses: actions/checkout@v3 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6bf74b4c1..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "build and codecov" - -on: - push: - branches: [ main ] - pull_request: - branches: ["*"] - -jobs: - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - strategy: - matrix: - golang: - - 1.19 - steps: - - name: "set up go" - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: "checkout ${{ github.ref }}" - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - - name: "run go build" - run: GOPROXY="https://proxy.golang.org,direct" make build - - - name: "run go test and out codecov" - run: make prebuild; go test ./cmd/... ./pkg/... -race -coverprofile=coverage.out -covermode=atomic - - - name: "upload coverage" - uses: codecov/codecov-action@v3 diff --git a/.licenserc.yaml b/.licenserc.yaml index 71ab593cb..4c6f4a1bb 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -23,6 +23,7 @@ header: - '.gitmodules' - 'plugins/**' - 'CODEOWNERS' + - 'VERSION' comment: on-failure dependency: diff --git a/Makefile.core.mk b/Makefile.core.mk index 3ff9f2eb6..5a940ebb1 100644 --- a/Makefile.core.mk +++ b/Makefile.core.mk @@ -46,6 +46,10 @@ prebuild: submodule .PHONY: default default: build +.PHONY: go.test.coverage +go.test.coverage: prebuild + go test ./cmd/... ./pkg/... -race -coverprofile=coverage.xml -covermode=atomic + .PHONY: build build: prebuild $(OUT) GOPROXY=$(GOPROXY) GOOS=$(GOOS_LOCAL) GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) script/gobuild.sh $(OUT)/ $(BINARIES) @@ -86,7 +90,7 @@ include docker/docker.mk docker-build: docker.higress ## Build and push docker images to registry defined by $HUB and $TAG -export PARENT_GIT_TAG:=$(shell git describe --tags) +export PARENT_GIT_TAG:=$(shell cat VERSION) export PARENT_GIT_REVISION:=$(TAG) export ENVOY_TAR_PATH:=/home/package/envoy.tar.gz diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..4bc4a9161 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.5.3 diff --git a/go.mod b/go.mod index 9ecd84928..012b4de93 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ replace github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200 replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.5 require ( - github.com/agiledragon/gomonkey/v2 v2.2.0 + github.com/agiledragon/gomonkey/v2 v2.9.0 github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 github.com/dubbogo/gost v1.13.1 github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 diff --git a/go.sum b/go.sum index 89010dc37..cba96a216 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrU github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/agiledragon/gomonkey/v2 v2.2.0 h1:QJWqpdEhGV/JJy70sZ/LDnhbSlMrqHAWHcNOjz1kyuI= -github.com/agiledragon/gomonkey/v2 v2.2.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= +github.com/agiledragon/gomonkey/v2 v2.9.0 h1:PDiKKybR596O6FHW+RVSG0Z7uGCBNbmbUXh3uCNQ7Hc= +github.com/agiledragon/gomonkey/v2 v2.9.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/ahmetb/gen-crd-api-reference-docs v0.3.0/go.mod h1:TdjdkYhlOifCQWPs1UdTma97kQQMozf5h26hTuG70u8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/script/gobuild.sh b/script/gobuild.sh index d2a59713a..fe9de412e 100755 --- a/script/gobuild.sh +++ b/script/gobuild.sh @@ -69,6 +69,7 @@ if [[ -z ${BUILDINFO} ]];then fi while read -r line; do + echo -e "\n${line}" LD_EXTRAFLAGS="${LD_EXTRAFLAGS} -X ${line}" done < "${BUILDINFO}" @@ -77,7 +78,6 @@ if [ "${DEBUG}" == "1" ]; then OPTIMIZATION_FLAGS=() fi - time GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} ${GOBINARY} build \ ${V} "${GOBUILDFLAGS_ARRAY[@]}" ${GCFLAGS:+-gcflags "${GCFLAGS}"} \ -o "${OUT}" \ diff --git a/script/report_build_info.sh b/script/report_build_info.sh index 406ea3c45..c270579c3 100755 --- a/script/report_build_info.sh +++ b/script/report_build_info.sh @@ -35,7 +35,7 @@ if [[ -z "${IGNORE_DIRTY_TREE}" ]] && ! git diff-index --quiet HEAD --; then tree_status="Modified" fi -GIT_DESCRIBE_TAG=$(git describe --tags) +GIT_DESCRIBE_TAG=$(cat VERSION) HUB=${HUB:-"higress-registry.cn-hangzhou.cr.aliyuncs.com/higress"} # used by common/scripts/gobuild.sh