Skip to content
Permalink
Browse files

[#524] Add Code Coverage Support (#533)

* Add Code Coverage Support

* Add codeclimate token

Co-authored-by: Ahmed Elsabbahy <aelsabbahy@users.noreply.github.com>
  • Loading branch information
pedroMMM and aelsabbahy committed Jan 20, 2020
1 parent 8afe631 commit 6abda7e83d9d35129f37278ef5ba8cf864b8be95
Showing with 72 additions and 44 deletions.
  1. +14 −0 .codeclimate.yml
  2. +3 −0 .gitignore
  3. +22 −8 .travis.yml
  4. +33 −36 Makefile
@@ -0,0 +1,14 @@
version: "2"

plugins:
gofmt:
enabled: true
golint:
enabled: true
govet:
enabled: true

exclude_patterns:
- "!**/**.go"
- "**/*_test.go"
- "resource/resource_list.go"
@@ -14,3 +14,6 @@ tmp/
/goss.yaml

/.idea

/c.out
/c.out.tmp
@@ -1,30 +1,44 @@
env:
global:
- secure: IH/xOtRl9rcek+YTz1s2lv2njdV1gob0AY21/kGhqUBH2sdztQ/02CteGz5E0c+LfqoUYQglLsejVCNLXQJI39CyZRzysB1wlVOz7YIPNaOLATtMGg0/8Mb7dpeqAV1u3agIi87q3ims1EkmGE9UGNj/qL75oTXBiozEfkbcsheH3Ju9CcO0i006UlNqAG4T++l1JZ4kPmr1r5eNjRu52oWQrlxaOYpZJGnT3qjxkvxcnI/Pgiem0+2aZ7Yluu0lA7UCFWyORoDRUz4pQR3uDG4ADPG4WcpJ601LDZyWtS7EOXVBgWZX9vV9ZVx63nK5w0W8NN6PQOuz0niN9iwR+FsShrPIsh6P9wVZfGifwXK4g2FL2XMBRuZCsQfrpRY6JbnuyGeMqN53ta95y0Yv4H65UQ7bulr4Lnic4+W52G/fl1VUYX8Bts+ecUydIu+afcDZ6GkpVLEURjaek99uO5ewHH7lfVAOQv4wUP8GFUyLXJumJZHvMzyiAXsTHdUZdm+Ap8EPzWFYYnMxySU39MEkIvhfG47X6sA7zAppuoNwd8vU4ZaxSdsme2InUSalETGJZ7ohL+M/tkTMyuyq8uLMRuwscNdgcCjGaHM19NQMrv4nsPmmzTeiDRoFk2wad07Mgsjy07esxw52rs3zAsa37+h74GYFWYo523AiYjw=

language: go

go:
- 1.13.x
- 1.13.x

os:
- linux

sudo: required
dist: trusty

services:
- docker
- docker

before_install:
- go get -u golang.org/x/lint/golint
install:
- go get -u golang.org/x/lint/golint
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter

before_script:
- ./cc-test-reporter before-build

script:
- make
- make test

after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -d

deploy:
provider: releases
api_key:
token:
secure: hEHCC4EN7iHz7pIWKRn2qw22NTqUxnuBp59wfAlLBtV26j5rHMzSu8mlxkJInusDUGLJiNLrZPRWN0mzOdIXalbUeLhlX7EflJgEj6Q0MchUR69LzCAp0KMIFL1Sfq0v81VgujRLUUy5utxDL8Er4tZknn2PpXAMzpO+ozjNRDhhSEM4iMXfY3bcOIMnx6XRgCjFCb036wlBgOfdgv5fwm2PP638DTKar4W6ZZbqCQByhJ5RyL3BMDPTT0moA/tYbG+FA6p6Rme1OcBkMnpsiJZoB3u8gxsNiEJ43/C2RcULW/18qqp2UVD5FipSDYP7GQ5ugKCbgpWXb0Ctl8o4hv1UsNl0XoyJhAt0PRp6vqnyy6LWB2FzX30Xj/vGIhO/IfiJvspHxpatTk7Esjr46K4u9ao/x63LX6F6yI1ZTfbzt2MhRYRjwh4ORNfqhysuzXChftX1S9hj6s6gO0/zqoOsRK/PK8DProbUn4bxrGOBzi16P0GEk4agWWUm74Pis9qCThXNW8MXEV936KvE1wb1RxTACYvFBtO2IM5eQ26t2Y7mGJd7FJup9LR4oUtUTSbYo5P2Sal6xntBKH5P4nwEtM+TtHoeSCKQ3X5i1VSdvAH7soEAly6rP5d5wwPhqqx9mgUPYO/3ulvxLJOYHamrbj6nlHDXnCEoj1ZMxX4=
file:
- release/goss-linux-amd64
- release/goss-linux-386
- release/goss-linux-arm
- extras/dgoss/dgoss
skip_cleanup: true
cleanup: true
on:
repo: aelsabbahy/goss
tags: true
@@ -7,22 +7,32 @@ TRAVIS_TAG ?= "0.0.0"
GO_FILES = $(shell find . \( -path ./vendor -o -name '_test.go' \) -prune -o -name '*.go' -print)
GO111MODULE=on

.PHONY: all build install test coverage release bench test-int lint gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32
.PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32

all: test-all test-all-32
all: test-all

test-all: fmt lint vet test test-int-all

install: release/goss-linux-amd64
$(info INFO: Starting build $@)
cp release/$(cmd)-linux-amd64 $(GOPATH)/bin/goss

test:
$(info INFO: Starting build $@)
go test $(pkgs)
{ \
set -e ;\
go test -coverprofile=c.out ${pkgs} ;\
cat c.out | sed 's|github.com/aelsabbahy/goss/||' > c.out.tmp ;\
mv c.out.tmp c.out ;\
}

lint:
$(info INFO: Starting build $@)
#go tool vet .
golint $(pkgs) | grep -v 'unexported' || true
golint $(pkgs) || true

vet:
$(info INFO: Starting build $@)
go vet $(pkgs) || true

fmt:
$(info INFO: Starting build $@)
@@ -36,14 +46,6 @@ bench:
$(info INFO: Starting build $@)
go test -bench=.

coverage:
$(info INFO: Starting build $@)
go test -cover $(pkgs)
#go test -coverprofile=/tmp/coverage.out .
#go tool cover -func=/tmp/coverage.out
#go tool cover -html=/tmp/coverage.out -o /tmp/coverage.html
#xdg-open /tmp/coverage.html

release/goss-linux-386: $(GO_FILES)
$(info INFO: Starting build $@)
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-X main.version=$(TRAVIS_TAG) -s -w" -o release/$(cmd)-linux-386 $(exe)
@@ -54,16 +56,31 @@ release/goss-linux-arm: $(GO_FILES)
$(info INFO: Starting build $@)
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "-X main.version=$(TRAVIS_TAG) -s -w" -o release/$(cmd)-linux-arm $(exe)



release:
$(MAKE) clean
$(MAKE) build

build: release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm

test-int: centos7 wheezy precise alpine3 arch
gen:
$(info INFO: Starting build $@)
go generate -tags genny $(pkgs)

clean:
$(info INFO: Starting build $@)
rm -rf ./release

build-images:
$(info INFO: Starting build $@)
development/build_images.sh

push-images:
$(info INFO: Starting build $@)
development/push_images.sh

test-int-64: centos7 wheezy precise alpine3 arch
test-int-32: centos7-32 wheezy-32 precise-32 alpine3-32 arch-32
test-int-all: test-int-32 test-int-64

centos7-32: build
$(info INFO: Starting build $@)
@@ -95,23 +112,3 @@ alpine3: build
arch: build
$(info INFO: Starting build $@)
cd integration-tests/ && ./test.sh arch amd64


test-all-32: fmt lint test test-int-32
test-all: fmt lint test test-int

gen:
$(info INFO: Starting build $@)
go generate -tags genny $(pkgs)

clean:
$(info INFO: Starting build $@)
rm -rf ./release

build-images:
$(info INFO: Starting build $@)
development/build_images.sh

push-images:
$(info INFO: Starting build $@)
development/push_images.sh

0 comments on commit 6abda7e

Please sign in to comment.
You can’t perform that action at this time.