Merge pull request #109 from vdemeester/codecov-in-circle

Add test-coverage & codecov target and update circleci
This commit is contained in:
Daniel Nephin 2017-05-23 11:59:05 -04:00 committed by GitHub
commit e47cc91ac9
5 changed files with 31 additions and 3 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
/build/ /build/
cli/winresources/rsrc_386.syso cli/winresources/rsrc_386.syso
cli/winresources/rsrc_amd64.syso cli/winresources/rsrc_amd64.syso
coverage.txt
profile.out

View File

@ -12,7 +12,11 @@ clean:
# the "-tags daemon" part is temporary # the "-tags daemon" part is temporary
.PHONY: test .PHONY: test
test: test:
go test -tags daemon -v $(shell go list ./... | grep -v /vendor/) ./scripts/test/unit $(shell go list ./... | grep -v /vendor/)
.PHONY: test-coverage
test-coverage:
./scripts/test/unit-with-coverage
.PHONY: lint .PHONY: lint
lint: lint:

View File

@ -29,13 +29,16 @@ jobs:
docker run --name cross cli-builder make cross docker run --name cross cli-builder make cross
docker cp cross:/go/src/github.com/docker/cli/build /work/build docker cp cross:/go/src/github.com/docker/cli/build /work/build
- run: - run:
name: "Unit Test" name: "Unit Test with Coverage"
command: | command: |
if [ "$CIRCLE_NODE_INDEX" != "2" ]; then exit; fi if [ "$CIRCLE_NODE_INDEX" != "2" ]; then exit; fi
dockerfile=dockerfiles/Dockerfile.dev dockerfile=dockerfiles/Dockerfile.dev
echo "COPY . ." >> $dockerfile echo "COPY . ." >> $dockerfile
docker build -f $dockerfile --tag cli-builder . docker build -f $dockerfile --tag cli-builder .
docker run cli-builder make test docker run --name test cli-builder make test-coverage
docker cp test:/go/src/github.com/docker/cli/coverage.txt coverage.txt
apk add -U bash curl
curl -s https://codecov.io/bash | bash
- run: - run:
name: "Validate Vendor and Code Generation" name: "Validate Vendor and Code Generation"
command: | command: |

4
scripts/test/unit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eu -o pipefail
go test -tags daemon -v $@

15
scripts/test/unit-with-coverage Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eu -o pipefail
for pkg in $(go list ./... | grep -v /vendor/); do
./scripts/test/unit \
-cover \
-coverprofile=profile.out \
-covermode=atomic \
${pkg}
if test -f profile.out; then
cat profile.out >> coverage.txt
rm profile.out
fi
done