Skip to content

Commit

Permalink
CI: collect golang unit test code coverage (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-chen authored Nov 2, 2020
1 parent 722c0fd commit de8bdbf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ jobs:
sudo apt install golang-1.14-go
- name: run test
run: |
make api-test
- name: upload coverage profile
working-directory: ./api
run: go test $(go list ./... | grep -v /e2e)
run: |
bash <(curl -s https://codecov.io/bash)
- name: run with custom port
working-directory: ./api
run: |
sed -i 's/8080/\# 8088/' conf/conf.json
go run main.go &
export GO111MOUDULE=on
export APISIX_CONF_PATH=$PWD/conf
sed -i 's/8080/8088/' conf/conf.json
go build -o ./manager-api
./manager-api > ./api.log 2>&1 &
sleep 2
cat ./api.log
cat conf/conf.json
- name: run with custom port
working-directory: ./api
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@
# limitations under the License.
#

export GO111MODULE=on

### license-check: Check apisix-dashboard source codes for Apache License
.PHONY: license-check
license-check:
ifeq ("$(wildcard .actions/openwhisk-utilities/scancode/scanCode.py)", "")
git clone https://github.com/apache/openwhisk-utilities.git .actions/openwhisk-utilities
cp .actions/ASF* .actions/openwhisk-utilities/scancode/
endif
.actions/openwhisk-utilities/scancode/scanCode.py --config .actions/ASF-Release.cfg ./
.actions/openwhisk-utilities/scancode/scanCode.py --config .actions/ASF-Release.cfg ./


### api-test: Run the tests of manager-api
.PHONY: api-test
api-test:
cd api/ && go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...


### help: Show Makefile rules
.PHONY: help
help: default
@echo Makefile rules:
@echo
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'

0 comments on commit de8bdbf

Please sign in to comment.