Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftr:Change verify to Makefile #831

Merged
merged 12 commits into from
Nov 3, 2020
Merged
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
13 changes: 4 additions & 9 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,13 @@ jobs:
go get -v -t -d ./...
fi

- name: License Check
- name: Verify
run: |
go fmt ./... && [[ -z `git status -s` ]]
sh before_validate_license.sh
chmod u+x /tmp/tools/license/license-header-checker
/tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]]
make verify

- name: Test
- name: Integrate Test
run: |
chmod u+x before_ut.sh && ./before_ut.sh
go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic
chmod +x integrate_test.sh && ./integrate_test.sh

- name: Coverage
- name: Post Coverage
run: bash <(curl -s https://codecov.io/bash)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ config_center/apollo/mockDubbog.properties.json
# vim stuff
*~
.*.sw?
/license-header-checker-linux/
/license-header-checker-linux.zip
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@ install: true
# define ci-stage
script:
# license-check
- echo 'start license check'
- go fmt ./... && [[ -z `git status -s` ]]
- sh before_validate_license.sh
- chmod u+x /tmp/tools/license/license-header-checker
- /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]]
# unit-test
- echo 'start unit-test'
- chmod u+x before_ut.sh && ./before_ut.sh
- go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic
- make verify
# integrate-test
- chmod +x integrate_test.sh && ./integrate_test.sh

Expand Down
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

VERSION ?= latest

GO = go
GO_PATH = $(shell $(GO) env GOPATH)
GO_OS = $(shell $(GO) env GOOS)
ifeq ($(GO_OS), darwin)
GO_OS = mac
endif
GO_BUILD = $(GO) build
GO_GET = $(GO) get
GO_TEST = $(GO) test
GO_BUILD_FLAGS = -v
GO_BUILD_LDFLAGS = -X main.version=$(VERSION)

GO_LICENSE_CHECKER_DIR = license-header-checker-$(GO_OS)
GO_LICENSE_CHECKER = $(GO_PATH)/bin/license-header-checker
LICENSE_DIR = /tmp/tools/license

ARCH = amd64
# for add zookeeper fatjar
ZK_TEST_LIST=config_center/zookeeper registry/zookeeper cluster/router/chain cluster/router/condition cluster/router/tag metadata/report/zookeeper
ZK_JAR_NAME=zookeeper-3.4.9-fatjar.jar
ZK_FATJAR_BASE=/zookeeper-4unittest/contrib/fatjar
ZK_JAR_PATH=remoting/zookeeper$(ZK_FATJAR_BASE)
ZK_JAR=$(ZK_JAR_PATH)/$(ZK_JAR_NAME)

SHELL = /bin/bash

prepareLic:
$(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(GO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(GO_PATH)/bin/)
ls /tmp/tools/license/license.txt || wget -P $(LICENSE_DIR) https://github.com/dubbogo/resources/raw/master/tools/license/license.txt

prepareZk:
ls $(ZK_JAR) || (mkdir -p $(ZK_JAR_PATH)&& wget -P $(ZK_JAR_PATH) https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/${ZK_JAR_NAME})
@for i in $(ZK_TEST_LIST); do \
mkdir -p $$i$(ZK_FATJAR_BASE);\
cp ${ZK_JAR} $$i$(ZK_FATJAR_BASE);\
done

prepare: prepareZk prepareLic

.PHONE: test
test: clean prepareZk
$(GO_TEST) ./... -coverprofile=coverage.txt -covermode=atomic

deps: prepare
$(GO_GET) -v -t -d ./...

.PHONY: license
license: clean prepareLic
$(GO_LICENSE_CHECKER) -v -a -r -i vendor $(LICENSE_DIR)/license.txt . go && [[ -z `git status -s` ]]

.PHONY: verify
verify: clean license test

.PHONY: clean
clean: prepare
rm -rf coverage.txt
rm -rf license-header-checker*
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,26 @@ https://dubbogo.github.io/dubbo-go-website (**Improving**)

## Quick Start

[dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples) shows how to use dubbo-go. Please read the [dubbo-samples/golang/README.md](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md) carefully to learn how to dispose the configuration and compile the program.
[dubbo-go-samples](https://github.com/apache/dubbo-go-samples) shows how to use dubbo-go. Please read the [dubbo-samples/golang/README.md](https://github.com/apache/dubbo-go-samples/blob/master/README.md) carefully to learn how to dispose the configuration and compile the program.

## Running unit tests

### Prepare
### Run

Mac/Linux
```bash
sh ./before_ut.sh
make verify
```

Windows
### Verify license

```bash
before_ut.bat
make license
```

### Run
```bash
go test ./...
### Run unit test

# coverage
go test ./... -coverprofile=coverage.txt -covermode=atomic
```bash
make test
```

## Build
Expand Down
22 changes: 10 additions & 12 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,27 @@ https://dubbogo.github.io/dubbo-go-website (**完善中**)

## 运行单测

### 准备
### 执行全部校验

Mac/Linux
```bash
sh ./before_ut.sh
make verify
```

Windows
### 校验许可证

```bash
before_ut.bat
make license
```

### 执行
```bash
go test ./...
### 执行单元测试

# coverage
go test ./... -coverprofile=coverage.txt -covermode=atomic
```bash
make test
```

## 编译

请移步 [dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples)
请移步 [dubbo-go-samples](https://github.com/apache/dubbo-go-samples)

## 如何贡献

Expand Down Expand Up @@ -211,4 +209,4 @@ go test ./... -coverprofile=coverage.txt -covermode=atomic
<tr></tr>
</tbody>
</table>
</div>
</div>
43 changes: 0 additions & 43 deletions before_ut.bat

This file was deleted.

43 changes: 0 additions & 43 deletions before_ut.sh

This file was deleted.

26 changes: 0 additions & 26 deletions before_validate_license.sh

This file was deleted.