Skip to content

Commit

Permalink
feat: add codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 26, 2019
1 parent 76cf8fd commit 99cf17f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 38 deletions.
72 changes: 37 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
defaults: &defaults
working_directory: /go/src/moul.io/golang-repo-template
docker:
- image: circleci/golang:1.12
environment:
GO111MODULE: "on"
version: 2.1

install_retry: &install_retry
run:
name: install retry
command: |
command -v wget &>/dev/null && wget -O /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)" || true
if [ ! -f /tmp/retry ]; then command -v curl &>/dev/null && curl -L -o /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)"; fi
chmod +x /tmp/retry
/tmp/retry --version
executors:
golang:
working_directory: /go/src/moul.io/golang-repo-template
docker:
- image: circleci/golang:1.12
environment:
GO111MODULE: "on"
DOCKER_IMAGE: moul/golang-repo-template

commands:
install-retry:
steps:
- run: command -v wget &>/dev/null && wget -O /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)" || true
- run: if [ ! -f /tmp/retry ]; then command -v curl &>/dev/null && curl -L -o /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)"; fi
- run: chmod +x /tmp/retry
- run: /tmp/retry --version
install-golangci-lint:
steps:
- run: /tmp/retry -m 3 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0

orbs:
codecov: codecov/codecov@1.0.2

version: 2
jobs:
go.build:
<<: *defaults
go-build:
executor: golang
steps:
- checkout
- *install_retry
- install-retry
- run: /tmp/retry -m 3 go mod download
- run: /tmp/retry -m 3 make install
- run: /tmp/retry -m 3 go test -v ./...
- run: /tmp/retry -m 3 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0
- run: /tmp/retry -m 3 make test
- install-golangci-lint
- run: PATH=$PATH:$(pwd)/bin /tmp/retry -m 3 make lint
- codecov/upload:
file: coverage.txt

docker.build:
<<: *defaults
docker-build:
executor: golang
steps:
- checkout
#- run:
# name: Install Docker Compose
# command: |
# umask 022
# curl -L https://github.com/docker/compose/releases/download/1.11.4/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
- setup_remote_docker:
docker_layer_caching: true
- *install_retry
- run: /tmp/retry -m 3 docker build -t moul/golang-repo-template .

- install-retry
- run: /tmp/retry -m 3 docker build -t ${DOCKER_IMAGE} .

workflows:
version: 2
build_and_integration:
main:
jobs:
- go.build
- docker.build
# requires: docker.build?
- go-build
- docker-build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*~
*#
.#*
coverage.txt

# Vendors
node_modules/
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ install:

.PHONY: test
test:
set -e; for dir in `find . -type f -name "go.mod" | sed -r 's@/[^/]+$$@@' | sort | uniq`; do \
(set -xe; cd $$dir; $(GO) test -v -cover -race ./...); \
done
echo "" > /tmp/coverage.txt
set -e; for dir in `find . -type f -name "go.mod" | sed -r 's@/[^/]+$$@@' | sort | uniq`; do ( set -xe; \
cd $$dir; \
$(GO) test -v -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \
if [ -f /tmp/profile.out ]; then \
cat /tmp/profile.out >> /tmp/coverage.txt; \
rm -f /tmp/profile.out; \
fi); done
mv /tmp/coverage.txt .

.PHONY: lint
lint:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![GitHub release](https://img.shields.io/github/release/moul/golang-repo-template.svg)](https://github.com/moul/golang-repo-template/releases)
[![Go Report Card](https://goreportcard.com/badge/moul.io/golang-repo-template)](https://goreportcard.com/report/moul.io/golang-repo-template)
[![CodeFactor](https://www.codefactor.io/repository/github/moul/golang-repo-template/badge)](https://www.codefactor.io/repository/github/moul/golang-repo-template)
[![codecov](https://codecov.io/gh/moul/golang-repo-template/branch/master/graph/badge.svg)](https://codecov.io/gh/moul/golang-repo-template)
[![Docker Metrics](https://images.microbadger.com/badges/image/moul/golang-repo-template.svg)](https://microbadger.com/images/moul/golang-repo-template)
[![Made by Manfred Touron](https://img.shields.io/badge/made%20by-Manfred%20Touron-blue.svg?style=flat)](https://manfred.life/)

Expand Down
6 changes: 6 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

func Example() {
main()
// Output: Hello World!
}

0 comments on commit 99cf17f

Please sign in to comment.