Skip to content

Commit d2453d1

Browse files
committed
Add code coverage
1 parent 0b1dfe8 commit d2453d1

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
bin
1+
bin
2+
coverage.txt
3+
profile.out
4+
coverage.out

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ matrix:
1313
fast_finish: true
1414

1515
script:
16-
- go test
17-
- go test --race
16+
- make test-coverage

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1+
# general
2+
WORKDIR = $(PWD)
3+
14
# build CLI
25
LOCAL_TAG := $(shell git describe --tags --abbrev=0)
36
LOCAL_BUILD := $(shell date +"%m-%d-%Y_%H_%M_%S")
47
LOCAL_LDFLAGS = -s -X main.version=$(LOCAL_TAG) -X main.build=$(LOCAL_BUILD)
58

9+
# coverage
10+
COVERAGE_REPORT = coverage.txt
11+
COVERAGE_PROFILE = profile.out
12+
COVERAGE_MODE = atomic
13+
614
build-cli:
7-
go build -o bin/graphiql -ldflags "$(LOCAL_LDFLAGS)" cmd/graphiql/main.go
15+
go build -o bin/graphiql -ldflags "$(LOCAL_LDFLAGS)" cmd/graphiql/main.go
16+
17+
test:
18+
go test -v ./...
19+
20+
test-coverage:
21+
@cd $(WORKDIR); \
22+
echo "" > $(COVERAGE_REPORT); \
23+
for dir in `find . -name "*.go" | grep -o '.*/' | sort | uniq`; do \
24+
go test -v -race $$dir -coverprofile=$(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE); \
25+
if [ $$? != 0 ]; then \
26+
exit 2; \
27+
fi; \
28+
if [ -f $(COVERAGE_PROFILE) ]; then \
29+
cat $(COVERAGE_PROFILE) >> $(COVERAGE_REPORT); \
30+
rm $(COVERAGE_PROFILE); \
31+
fi; \
32+
done; \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Golang GraphiQL
22
[![GitHub version](https://badge.fury.io/gh/friendsofgo%2Fgraphiql.svg)](https://badge.fury.io/gh/friendsofgo%2Fgraphiql)
33
[![Build Status](https://travis-ci.org/friendsofgo/graphiql.svg?branch=master)](https://travis-ci.org/friendsofgo/graphiql)
4+
[![codecov](https://codecov.io/gh/aperezg/graphiql/branch/master/graph/badge.svg)](https://codecov.io/gh/aperezg/graphiql)
45
[![Go Report Card](https://goreportcard.com/badge/github.com/friendsofgo/graphiql)](https://goreportcard.com/report/github.com/friendsofgo/graphiql)
56
[![CDNJS](https://img.shields.io/cdnjs/v/graphiql.svg)](https://cdnjs.com/libraries/graphiql)
67
[![GoDoc](https://godoc.org/graphql.co/graphql?status.svg)](https://godoc.org/github.com/friendsofgo/graphiql)

0 commit comments

Comments
 (0)