Skip to content

Commit

Permalink
Merge pull request #421 from zeeke/code-coverage
Browse files Browse the repository at this point in the history
Add Coveralls step in GH actions
  • Loading branch information
adrianchiris authored May 12, 2022
2 parents 7189b34 + dd8cf53 commit 4525a0e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/build-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
run: make build

test:
runs-on: ubuntu-latest
needs: build
Expand All @@ -42,16 +43,45 @@ jobs:
- name: Go test
run: make test

test-coverage:
runs-on: ubuntu-latest
needs: build
name: test-coverage
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.16.x

- uses: actions/checkout@v2

- name: Install hwdata
run: sudo apt-get install hwdata -y

- name: Go test with coverage
run: make test-coverage

- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: test/coverage/lcov.info

golangci:
name: Golangci-lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.16.x
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.37

shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.gopath/*
/build/*
/test/coverage*

# Created by https://www.gitignore.io/api/go,macos,linux,windows,visualstudiocode

Expand Down
15 changes: 7 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Tested with golangci-lint ver. 1.37
run:
timeout: 3m
skip-dirs:
- vendor/
- .github/
- deployments/
- docs/
- images/

linters-settings:
depguard:
list-type: blacklist
Expand Down Expand Up @@ -110,11 +117,3 @@ issues:
- lll
- stylecheck
- goconst

run:
skip-dirs:
- vendor/
- .github/
- deployments/
- docs/
- images/
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GOLINT = $(GOBIN)/golint
GOCOVMERGE = $(GOBIN)/gocovmerge
GOCOV = $(GOBIN)/gocov
GOCOVXML = $(GOBIN)/gocov-xml
GCOV2LCOV = $(GOBIN)/gcov2lcov
GO2XUNIT = $(GOBIN)/go2xunit
# Package info
BINARY_NAME=sriovdp
Expand Down Expand Up @@ -80,6 +81,9 @@ $(GOCOVMERGE): | $(BASE) ; $(info building gocovmerge...)
$(GOCOV): | $(BASE) ; $(info building gocov...)
$Q go get github.com/axw/gocov/...

$(GCOV2LCOV): | $(BASE) ; $(info building gcov2lcov...)
$Q go get github.com/jandelgado/gcov2lcov

$(GOCOVXML): | $(BASE) ; $(info building gocov-xml...)
$Q go get github.com/AlekSi/gocov-xml

Expand All @@ -102,8 +106,8 @@ test-xml: fmt lint | $(BASE) $(GO2XUNIT) ; $(info running $(NAME:%=% )tests...)
$(GO2XUNIT) -fail -input test/tests.output -output test/tests.xml

.PHONY: test-coverage test-coverage-tools
test-coverage-tools: | $(GOCOVMERGE) $(GOCOV) $(GOCOVXML)
test-coverage: COVERAGE_DIR := $(CURDIR)/test/coverage.$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
test-coverage-tools: | $(GOCOVMERGE) $(GOCOV) $(GOCOVXML) $(GCOV2LCOV)
test-coverage: COVERAGE_DIR := $(CURDIR)/test/coverage
test-coverage: fmt lint test-coverage-tools | $(BASE) ; $(info Running coverage tests...) @ ## Run coverage tests
$Q mkdir -p $(COVERAGE_DIR)/coverage
$Q cd $(BASE) && for pkg in $(TESTPKGS); do \
Expand All @@ -117,6 +121,7 @@ test-coverage: fmt lint test-coverage-tools | $(BASE) ; $(info Running coverage
$Q $(GOCOVMERGE) $(COVERAGE_DIR)/coverage/*.cover > $(COVERAGE_PROFILE)
$Q go tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
$Q $(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML)
$Q $(GCOV2LCOV) -infile $(COVERAGE_PROFILE) -outfile $(COVERAGE_DIR)/lcov.info

.PHONY: lint
lint: | $(BASE) $(GOLINT) ; $(info Running golint...) @ ## Run golint on all source files
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SR-IOV Network Device Plugin for Kubernetes

[![Travis CI](https://travis-ci.org/k8snetworkplumbingwg/sriov-network-device-plugin.svg?branch=master)](https://travis-ci.org/k8snetworkplumbingwg/sriov-network-device-plugin/builds) [![Go Report Card](https://goreportcard.com/badge/github.com/k8snetworkplumbingwg/sriov-network-device-plugin)](https://goreportcard.com/report/github.com/k8snetworkplumbingwg/sriov-network-device-plugin) [![Weekly minutes](https://img.shields.io/badge/Weekly%20Meeting%20Minutes-Mon%203pm%20GMT-blue.svg?style=plastic)](https://docs.google.com/document/d/1sJQMHbxZdeYJPgAWK1aSt6yzZ4K_8es7woVIrwinVwI)
[![Coverage Status](https://coveralls.io/repos/github/k8snetworkplumbingwg/sriov-network-device-plugin/badge.svg?branch=master)](https://coveralls.io/github/k8snetworkplumbingwg/sriov-network-device-plugin?branch=master)

## Table of Contents

Expand Down

0 comments on commit 4525a0e

Please sign in to comment.